Anonymous
hey people. I don't remember. In django there is filter which can help print out in template view for example 156 characters for example i use function in model def(self): return self.description[:268]
Anonymous
but in template there is other option
Anonymous
post.desctption | and i don't remember
Kirill
How to make sure query.delete() won't delete related objects from other model with FK on_delete=CASCADE?
cj
How to make sure query.delete() won't delete related objects from other model with FK on_delete=CASCADE?
.delete() will delete all other related entries if ForeignKey has on_delete=CASCADE
Kirill
cj
I know. How to get if the deletion would be and prevent
change the on_delete value to any other option, depending on what fits your needs
Alejandro
hello ... when uploading a file have you ever received this error: 'ascii' codec can't encode character '\xe9' in position 46: ordinal not in range(128)
Alejandro
???
V
I want to learn django rest framework, but i can't find any good resources on internet. Can someone please suggest some good drf resources... 😊
V
https://www.django-rest-framework.org/tutorial/quickstart/
Any good video tutorials? Not official documentation
Anonymous
Which relationship I will will in django for one agent having many employees?
Shivam
Which relationship I will will in django for one agent having many employees?
Probably ForeignKey in the employee model if one employee can only have one Agent
Anonymous
Ok
Anonymous
Probably ForeignKey in the employee model if one employee can only have one Agent
How I will get name of those employees can I get name of all employees realted to an agent...
Anonymous
?
Shivam
Rest framework or just django
Anonymous
{{request.user.myagent}} ?
Anonymous
myagent is the foreign key in employee model?
Aditya
Can someone plz tell me How to achieve this in django?? "URL is valid for the active encrypted session for 60 seconds and after that the URL will be expired and will display URL is expired Message."
Piyush
Hello Is there any method to use Django as backend for Android??? Please help
Toony
Hi, I ran into a problem. I have two models inherited from one, the first is public, and the second is created when editing the first, so moderation is organized. How can I copy an image from an additional model to the base, and delete the additional one? I am using django's ContentFile but it does not overwrite the image based
Anonymous
Django Rest Framework and write your APIs
Hi I have to show my workers realted to agent .... How I will implement this inhave make a foreign key in worker model relationship with agent
Mirco
Lenin
Can anybody suggest me some good courses on low level programming like assembly (x86-64) and C?
Doragonsureiyā
Can anybody suggest me some good courses on low level programming like assembly (x86-64) and C?
looks like you need an offtopic group, please continue this conversation at @pythonofftopic
Lenin
Okay thanks
Mirco
Okay thanks
👍🏻
⎊ GNU/Aryan ⎊
What is the best resource to learn about Django querysets ??
Anonymous
Study.
Which part of rest framework study to do the above
Mirco
All
Anonymous
Omg
Mirco
Start with the tutorial
Anonymous
Ok
Mirco
And then you will able to write first endpoints in a while
Velociraptor
Hi ... How to implement the child form in parent Detailview?
Gil
Anyone please tell
Official docs + and play and test and play and test and play
Roman
Hi guys , if anyone worked with rest framework , I am wondering If I have 2 method in serializer(update and create) when does update invoked ? When create except duplicate key or what ?
Ayomide
But a detailed example is in the docs
David
guys I'm a little confused, let's see if you can explain, please. The issue is that I am trying to integrate channels to perform a real time chat but I do not know how to install redis, if by pip install in the virtual environment, or should I download redis and install it on the computer as such.
Roman
When you use it into an update view
Okay but if I want if the entry exist to update it , otherwise create. And this is POST view how can I invoke such save ?
Aditya
Plz help How I decativate url after 60 second in django Thanks in advance😊
Mirco
But how I invoke update ?
By using an Update view
Roman
By using an Update view
So if the method is update , save() will call update ?
Mirco
No, it will use the update you set into the serializer to know what you wanna update
Mirco
Study better DRF docs and you will find all answers
Kirill
SomeQuerySet is a Queryset object, returned by sth like Model.objects.filter(pk__gt=10). How to find some element by condition IN SomeQuerySet. I've tried SomeQuerySet.get(...), but in makes another query to database instead of looking up in ready SomeQuerySet.
Shreehari
How can i add fields during runtime in django rest. Problem: In User model there's a field for adding few preferences. By default it should be 3. if user wants, he should be able to add more preferences for the preferences field. How should i approach this ?
Xavier
How can i add fields during runtime in django rest. Problem: In User model there's a field for adding few preferences. By default it should be 3. if user wants, he should be able to add more preferences for the preferences field. How should i approach this ?
u should go with foreign key or many to many relationship make a model of preference and then connect it to user model, with foreign key u can just connect the preference model to user
Luis
SomeQuerySet is a Queryset object, returned by sth like Model.objects.filter(pk__gt=10). How to find some element by condition IN SomeQuerySet. I've tried SomeQuerySet.get(...), but in makes another query to database instead of looking up in ready SomeQuerySet.
Instead of doing SomeQuerySet.get(field2=value2) you can do SomeQuerySet.filter(field2=value2) that give you a queryset with just only one 'element' and maybe, more direct SomeQuerySet.filter(field2=value2).first()
Dixit
I've so simple query, I'm new to django. There a star I want to print for certain number of times. <ul> {% for i in range ( num ) %} 🌟 {% endfor %} And I'm getting an error, such a noob question but please ♥️
Dixit
Thank you much for your replies but ... What do you don't write code in templates ?
Dixit
Is there another way ? 😳
cj
Thank you much for your replies but ... What do you don't write code in templates ?
because templates are used to show final results only, not to deal with logic
Gigil
It's not secure to write logic in template I think
cj
build the list in the views, then show it on the template, yes you can make basic iterations on it too
Dixit
I'm writing functions in views.py and using render method I pass Template names
Dixit
Is it a wrong or inefficient way ? Or am I doing right ?
Gigil
Is it a wrong or inefficient way ? Or am I doing right ?
That's correct. In view create a list and pass it as context hope it fixes
Dixit
Thank you 💕
raven
It's not secure to write logic in template I think
there's something like this to make your template dumb, view short and Model smart
V
Anu good resources of django-rest-framework other than official documentation?
raven
Anu good resources of django-rest-framework other than official documentation?
django for api by william vincent book , CodingWithMitch YouTube channel