Michael
Nope, I don't answer privately and it's prohibited by group rules So don't do it
Alright, i won't message you privately What if get blocked by the admin? cos i feel he's gonna block me soon
Neo
Also just pointing out that Mirco is an admin as well
Michael
I am having a problem with my blog app
Neo
and to share your code use a pastebin
Neo
!paste
Doragonsureiyā
Rule 5️⃣: To share code or error tracebacks, use an online pasting service like: - https://dpaste.org - https://linkode.org - https://hastebin.com - https://bin.kv2.dev If you posted a wall of text, go back and delete it.
Michael
i want to display all the categories from my admin, whenever i try using the for loop <ul> {% for category in category_list %} <li><a href="#">{{category.title}} (27)</a></li> {% endfor %} </ul>
Michael
it doesn't work
Neo
That's vague. What is the expected output and what is the actual output?
Neo
Well i can assume the expected output, but what is it that you see anyway? You should also share your view (as a pastebin)
Michael
it shows me blog.Category.None
Mirco
Can i upload an image using pastebin?
Nope, you can copy / paste code
Michael
1. https://dpaste.org/o9drB My template file 2. https://dpaste.org/b6R5j My views.py 3. https://dpaste.org/UCNkO My models.py 4. https://dpaste.org/sq0gc
Mirco
Oh... you mean like this? context_object_name
No I mean get_context_data method of views
Mirco
Ok, what's it for?
To inject context to be used in templates If you follow tutorials on official doc, for sure you will learn it
Michael
Do i need to create a view for any data i want to display in my templates? for example, i have a model called Post and another model called Categories, then i want to display the Postlist on my Homepage and also a sidebar that contains my Categories. Do i need to create a view (i.e class-based-view "Listview") to display the category in the sidebar (of the homepage) I already have a Listview for my Post model displaying all the posts from my database in the homepage
Michael
That's why you need context You can inject into the templates both the list of posts and categories
Alright, you didn't answer my question though Thanks.. i'll go read on get_context_data for more clarifications
Nana
class Topic(models.Model): File "C:\Users\setha\Desktop\online-django\boards\boardapp\models.py", line 14, in Topic board = models.ForeignKey(Board, related_name='topics') TypeError: ForeignKey.init() missing 1 required positional argument: 'on_delete'
Nana
What is the problem?
Maxim
What is the problem?
missing 1 required positional argument: 'on_delete'
Nana
please what value should give it?
Maxim
please what value should give it?
google foreignkey django or foreignkey on_delete django
Nana
Thanks alot
Michael
👍🏼
I have read through the docs, I think I know what's missing. Just like you said, I need get_context_data() to get additional information from the same model into my template Thanks for the help https://docs.djangoproject.com/en/4.0/topics/class-based-views/generic-display/
Michael
@warpigg sorry if I sounded rude to you.
saravana rajan
Anybody help me to done this in django ❤️Create a products API to list all the products based on rating (sort the products based on the high rated products) ❤️Create a order API (post) to order a product with quantity ❤️Create a product API to view/add rating and review ❤️Create a orders API to list all the orders done by the user (sort the products based on the high rated products) ❤️User can only see the orders which is completed by him ❤️Orders should be sorted based on the "order date" ❤️Return a product API to return product if damage (on return the quantity should increase)
Knowledge
add argument on_delete=CASCADE
This will delete the related models if parent model is deleted. if you want to retain them u can use NULL instead of CASCADE. PROTECT instead of CASCADE If you want to stop from deleting
Thelooneytoon_
Heyy i wanna add async functionality to my project but dont wanna use django wsgi. Is there anyother way to do that?
Leon
I am getting a template Does not exist error when I try to access a view via a URL what could be the reason
Alex
I am getting a template Does not exist error when I try to access a view via a URL what could be the reason
either wrong name or path of template in view or missing conf in settings.
Leon
I'm confused because I don't have any template for this project, maybe it might be missing config I guess but I can't figure out what it is
Shokhzod Samariddinov
Hi! I deployed project to cpanel but it does not see static file how to fix it
Ugochukwu
Class Plans(models.Model): name = models.CharField() duration = model.DurationField() min_value = models.IntegerField() max_value = models.IntegerField() Class Investments(models.Model): plan = models.ForeignKey(Plans, on_delete=models.Cascade) amount = models.IntegerField(max_value=None, min_value=None) Question: How do I set the minimum and maximum value of the investment amount attribute to be the minimum or maximum amount of the plan selected?
🦅
How can i send a pic to this group , because i have a question
🦅
I added like btn, but it’s not work 🙂
Ugochukwu
Add validator to form
Isnt it possible to do it at the model level first?
Ugochukwu
I tried to but how do I reference the attribute of instance of the selected plan. Instead of just putting a static value in the minValueValidator or MaxValueValidator. I tried something like: validators = (MinValueValidator(self.plan.min_value)) But I'm getting an error saying I cannot reference self
Nikita
Hello everyone. I have a django backend, where i used to commumicate with a rocket chat service through RocketChatAPI instance. I use this instance in different points of application. Where should i store this instance? i created a floder 'service' in my chat app, and at /chat/service/client i have method get_client. It returns instance or create it if client is None. Looks good? Or not?
Ewuru
Pip is not working on my terminal It's showing me this: no module named 'pip._vendor.requests' Please I need help, I can't install anything
Ti
Hello everyone! I am new in django. I try to use gunicorn and wsgi. I ran command gunicorn myproject.wsgi but an error is not found module name myproject.wsgi
Ti
Any idea?
OceanMan
Hello everyone! I am new in django. I try to use gunicorn and wsgi. I ran command gunicorn myproject.wsgi but an error is not found module name myproject.wsgi
Send a screenshot of your project structure or folders, let's see It could be that your project name is conflicting the wsgi
Ewuru
I just install the latest python 3.10.5 and it works
OceanMan
I just install the latest python 3.10.5 and it works
Nice one. It was definitely installation problem. Sometimes you can run the .exe as Administrator or as Sudo in Linux OS
OceanMan
But it was working before
Because you're new to it that's why you faced it
Ewuru
I was shocked that it was not later working, but am happy now
Ewuru
Because you're new to it that's why you faced it
Have done many projects, so have installed so many things using pip
OceanMan
Okay
Doragonsureiyā
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
Ulug'bek | Python Developer
AttributeError at /person/all/ Got AttributeError when attempting to get a value for field viloyat on serializer AllSerializer. The serializer field might be named incorrectly and not match any attribute or key on the Person instance. Original exception text was: 'Person' object has no attribute 'Viloyat'.