Govind
Hi, I'm getting below error, please help me to solve it.
Govind
'function' object has no attribute 'objects'
Govind
t_pic = Timeline.objects.filter(user=request.user)
Anonymous
Govind
yes
Govind
It's model name
Anonymous
'function' object has no attribute 'objects'
interesting, even the error, what kinda 'function' there, check your code thoroughly
wanderer
yes
paste the view fn here
wanderer
can you paste the respective view fucntion here
Govind
paste the view fn here
Can I send code here in this group?
wanderer
Can I send code here in this group?
only the respective view fn
Anonymous
Use pastebin
Govind
ok
Anonymous
ok
Show your model as well there
Govind
https://pastebin.com/8j5wwAiL
Govind
Views https://pastebin.com/SjRGFMGB
Ghorz
shared host? then you can't
You can. I've hosted several sites on namecheap.com shared hosting.
Akash
How can I do this in django template: {% for field in object.field_one, object.field_two %}{% endfor %} I want to take two django fields and loop for them as they use same html format.
Henry
Today I learned a great feature in django.db.models.ForeignKey. It can be created with a related_name option which adds a set of related objects in the foreign model: class Poll(models.Model): created = models.DateTimeField(auto_now_add=True) question = models.CharField(max_length=128) class Meta: ordering = ['created'] class Choice(models.Model): text = models.CharField(max_length=192) votes = models.IntegerField() poll = models.ForeignKey(Poll, related_name="choices", on_delete=models.CASCADE)
Henry
Then, when you create a Poll with some Choices you can access all choices through Poll instance poll.choices.all() What a stunning feature.
Akash
Then, when you create a Poll with some Choices you can access all choices through Poll instance poll.choices.all() What a stunning feature.
Even if you do not set related name django will use class name and add s to it for all your foreign keys. And you can access those objects
Mitchel
Good evening all😊 Plesse I'm in search for a django mentor Can anyone please be of help?
wanderer
can anyone please help me out
wanderer
i have a deadline
wanderer
please
Anonymous
Any video link or method? How can i host
on heroku try this youtu.be/V2rWvStauak
Doragonsureiyā
can anyone please help me out
Please don't ask meta questions like: "Any user of $x here?" "Anyone used technology $y?" "Hello I need help on $z" Just ask about your problem directly! With 60k+ people the probability that someone will help is pretty high. Also please read: http://catb.org/~esr/faqs/smart-questions.html
Doragonsureiyā
Good evening all😊 Plesse I'm in search for a django mentor Can anyone please be of help?
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Mitchel
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
I've gone through the Mozilla tutorial Thanks for your reply But I'm stuck on a problem and I want to figure it out, that's why I need help
Mitchel
Mitchel
Thank you
Akil
Hello i am new to django..can anyone tell me what is the right procedure to learn django..
Akil
From where should i start..?
Doragonsureiyā
From where should i start..?
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Anonymous
Do we access django administration after deployment
niTRO
Know how to Access Choices with REST APIs?
I am not sure that I got your question correctly, but I used Model.Choices.CHOICE with eval some time ago
niTRO
But I don't think it is the right way
Firmcode
Can someone help please. I noticed reverse lookup fail in Django when the foreignkey field has a related name on it. How does related_name affects reverse loopup?
Anonymous
https://github.com/Timothy-Wangwe/Jarvis-Lee/issues/3
Anonymous
I need some help guys.
inchidi
https://github.com/Timothy-Wangwe/Jarvis-Lee/issues/3
this is what you can do for this kind of issue. first, dont store your answer inside your question, you did a great job giving verbose name for your model already, so why inconsistent? so the end result should looks like: class Question(models.Model): test = models.ForeignKey(Test, models.CASCADE, null=True) question_text = models.TextField() and then by doing that, you can use your Answer model like this class Answer(models.Model): question = models.ForeignKey(Question, models.CASCADE, related_name='answers') answer_text = models.CharField(max_length=10) is_correct_answer = models.NullBooleanField(default=None) class Meta: unique_together = ('question', 'is_correct_answer',)
Anonymous
Can someone help please. I noticed reverse lookup fail in Django when the foreignkey field has a related name on it. How does related_name affects reverse loopup?
Same happened with me as well, an iexact lookup didnt work with foreign key entry, but exact worked, I tried to track it, but it seems to be a bug in django reported before
Anonymous
Hi guys, I am going to select entries with the condition for example, where a=5 or a=6, how can I do this with ORM? Any help or tip is appreciated
Anonymous
Rtfm and just google
I tried and got this Model.objects.filter(a=5).filter(a=6), but not working if you are so busy and dont wanna answer my question just skip it!
Anonymous
No, I will insist on normal questions, not things u can google and handle at one click
Could you please help me google this and send a link? I couldnt find myself
Muslim
Anonymous
Yup
It didnt work🤔
Muslim
It didnt work🤔
Then u should share code, expected and actual result, test case and logs via code sharing tools
inchidi
thats why there am using NullBooleanField with default None
inchidi
so you and your user just need to set True answer, and let the others None
inchidi
of course you can use Boolean fields and handle "only one Answer from question.answers.all() can be true" but imo its better if handled on db level
inchidi
if you have time, better create your own field to replace NullBooleanField with validation where False will trigger ValidationError
Anonymous
I also noticed setting the values to NULL work. Thanks a lot 👏🏾
inchidi
I also noticed setting the values to NULL work. Thanks a lot 👏🏾
note that not all db implement this behavior https://stackoverflow.com/a/35728152
inchidi
but i guess this shouldn't be a problem for you since you already understand the concept
Taru
Hello everyone Can anyone suggest me My dynamic URL routing is not working in my django ?