Демид
django development server
Why I need to use nginx on production, but not django development server?
G4st0n
default web server is a development server purposes, not the correct for deployment on prod
Charly
Why I need to use nginx on production, but not django development server?
Because Django development server is not prepared to handle a lot of requests, nginx has a lot of features that are useful on a production environmente
G4st0n
also not capable for security and performance settings required at some point
G4st0n
Why I need to use nginx on production, but not django development server?
You can easy solve this things with django + docker
mahdi
Hello I have a question how to use access level in class base view
Марк
Hello. I need to help. I apologize in advance for mistakes (I don't know English very well). When sending a message to a chat where the user is not a member, an error 500 occurs. Help me process it. I tried with try, but for some reason it didn't work.
Марк
If anyone can help please email me
Демид
What should I do if ready() is executed several times? I have gunicorn, so I can't write --no-reload apps.py from django.apps import AppConfig from .update import start class UserConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'user' def ready(self): start()
Gumi
I'm confused at this moment.. so I want to store user phone number during registration and for that I'm extending User model with OneToOneField, but later how do I will verify which phone number belongs to which user?
ജിമ്പ്രു
Hi all I want to learn django with react and rest api framework. Any body plz tell me which documentation I should refer to install django with react and rest api. Thanks in advance
Favas
Hi
Favas
Any idea about displaying search icon for many to many field as raw_id_field (proxy model)
λ701
Because Django development server is not prepared to handle a lot of requests, nginx has a lot of features that are useful on a production environmente
i am having timeout errors using mailgun to send mails. https://stackoverflow.com/questions/72947475/gunicorn-keeps-timing-out-and-bad-gateway-upon-password-request-in-django-applic can anyone help me on this?
Of course
Hello, When I click on update button for updating existing data in model. I receive a Page Not Found error. How can i solve it?
Of course
check the method in your views.py for updating data
class UpdatedView(UpdateView): form_class = ReviewForm template_name = 'review/user_update.html' model = Review # fields = ['rating', 'review_text'] success_url = '/reviews'
Ak
I haven't used UpdateView function which is there in the parameter
Of course
Hello, When I click on update button for updating existing data in model. I receive a Page Not Found error. How can i solve it?
Демид
What should I do if ready() is executed several times? I have gunicorn, so I can't write --no-reload apps.py from django.apps import AppConfig from .update import start class UserConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'user' def ready(self): start()
Mohaali
Nahh
You can get the phone number by using the related field After getting the user you can access it like this user.phone_no
Gumi
You can get the phone number by using the related field After getting the user you can access it like this user.phone_no
#this is my custom model class Profile(models.Model): user = models.OneToOneField(User ,on_delete=models.CASCADE) id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) phone = models.IntegerField(unique=True, null=False, blank=False) phone_token = models.IntegerField() email_token = models.IntegerField() request_time = models.DateTimeField(auto_now=True) def __str__(self): return self.user.username #and this is what I am doing to verify print(User.objects.filter(username=data['username']).phone) #the error i am getting AttributeError: 'QuerySet' object has no attribute 'phone'
Mohaali
Use this print(User.objects.get(username=data['username']).profile.phone)
You should use get not filter, but if you use filter then check if the queryset exists using if queryset.exists(): # go on Then grab the item you want using the above method using queryset.get(username="")
Gumi
Use this print(User.objects.get(username=data['username']).profile.phone)
One thing I don't understand I've named my class as "Profile" then why here we using "profile"
Alex
One thing I don't understand I've named my class as "Profile" then why here we using "profile"
not much familiar with one-to-one related name use cases, but in other relationships, related names can be used in views to query multiple related objects from the database.
Veeresh_Ramachari
Hi i have problems in Django admin When we r in particular record page we need to move next and prev without going queue list
Veeresh_Ramachari
How can we perform this? Without pagination concept
Jindal
Hello, I have a problem in routing.py in django. Still not solved approx 2 weeks are passed away. Also it is working good on local host and showing error on Heroku about routing url path. Please help me to resolve this issue. Thanks in advance.
XYZ🤠
why does not it work? - '^media/(?<path>.*) $'
XYZ🤠
why can't see files in media and static ? while the files are saved?
XYZ🤠
Files are saved
XYZ🤠
do you need apache2?
mina
Hello I am looking for a good book for Django Rest Framework. Can you recommend some good books?
Doragonsureiyā
do you need apache2?
Are you talking about me?
カフ・アイン⁷⁰⁷
assert isinstance(response, HttpResponseBase), ( AssertionError: Expected a Response, HttpResponse or HttpStreamingResponse to be returned from the view, but received a <class 'NoneType'>
カフ・アイン⁷⁰⁷
can some body help me?
Mirco
so share the code of your view via pastebin and we'll tell u what's wrong
カフ・アイン⁷⁰⁷
Mirco
https://pastebin.pl/view/2dabe5a1
raise ValueError("ValueError exception thrown") has no sense
Mirco
if your serializer is not valid you have to return 400 Bad request with serializer.errors
カフ・アイン⁷⁰⁷
if your serializer is not valid you have to return 400 Bad request with serializer.errors
why its not valid? i do this like my rest frame work Course!
Maxim
why its not valid? i do this like my rest frame work Course!
we can't know that without seeing the code
Thealy
Hi everyone, I want to have two boxes to fill in both latitude and longitude . When I input latitude and longitude, I want that coordinate to intersect with my administrative boundaries as shapefile or whatever formats and return to show a box in details of commune, district and province. Could you please guide me how to conduct that in django? Thank You!
Ilsaf
Hi, i have two models Film and Person and they are connected through the model PersonFilm that have a field role(it is choices with values actor,writer and director) and FK for Film and Person. I need to get all Film fields and annotate 3 new fields as actor, writer and director that will contain all names of person with current role. It is real execute it in one query? Or i need to use Subquery
Mirco
why its not valid? i do this like my rest frame work Course!
1. has no sense, the exception itself 2. that's why your view return None
Gumi
#I am sending a list of messages in django template like this.. messages.error(request, list(verify_user.values())) #this is my html file, and I'm expecting iterate each list items and show as error message in my html page {% if messages %} {% for message in messages %} {{ message }} {% endfor %} {% endif %} #but the problem with this, I am getting error messages like this in my html page ['username is not available', 'password should be 8 to 16 characters long'] #I even tried to do {{ message[0] }} but I get an error Could not parse the remainder: '[0]' from 'message[0]'
Демид
How to run the function once after starting the Django server with gunicorn?
Демид
Which type of function do you want to run
I want to run a function that starts three BackgroundScheduler tasks
Демид
But how to run it? Django doesn't run any functions with my code once after start
Rajat
I want to run a function that starts three BackgroundScheduler tasks
You can use django celery and django celery beat if your project is big Or if you are using Linux then use cronjobs
Демид
I want to run once smth like this scheduler = BackgroundScheduler() def start(): global scheduler print('Started') scheduler.add_job(check_playlists, 'cron', hour=3, timezone='Europe/Moscow') scheduler.add_job(check_playlists, 'cron', hour=12, timezone='Europe/Moscow') scheduler.add_job(check_playlists, 'cron', hour=18, timezone='Europe/Moscow') I tried to add ready() in apps.py, but gunicorn start this function three times class UserConfig(AppConfig): def ready(self): start() pass
Rajat
How can I fix it?
I have spent lots time for scheduling t task my simple advice is to use celery
Демид
I have spent lots time for scheduling t task my simple advice is to use celery
Where can I read about starting functions after projects starts in celery?
Mihail
make your forms dynamic or save them by ajax there is many ways. i will say again, you can use django formset_factory to save the parent and the related objects in one single form
still can't understand, how to add and validate inline models without saving to base. I can't understand how to use formset_factory in my case
Of course
The issue could be in the success url
Yrs İ solve it by success url method
Chiefchef
I'm working with rest api and would like to consume some external api's . I don't have any in mind . Could you give me some examples of api I can consume eg a daily quote api ...
Демид
How to use global variables with gunicorn? I need to keep list list of active threads in global variable, but gunicorn has workers, so each worker have its own global variable. How to sync them?