Charly
G4st0n
default web server is a development server purposes, not the correct for deployment on prod
G4st0n
also not capable for security and performance settings required at some point
G4st0n
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
Rajat
Favas
Hi
Favas
Any idea about displaying search icon for many to many field as raw_id_field (proxy model)
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?
Ak
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
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?
Gumi
Демид
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
Neo
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.
Rajat
XYZ🤠
why does not it work? - '^media/(?<path>.*) $'
Maxim
XYZ🤠
XYZ🤠
XYZ🤠
why can't see files in media and static ? while the files are saved?
XYZ🤠
Files are saved
Maxim
XYZ🤠
do you need apache2?
mina
Hello
I am looking for a good book for Django Rest Framework.
Can you recommend some good books?
Maxim
カフ・アイン⁷⁰⁷
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
Mirco
so share the code of your view via pastebin and we'll tell u what's wrong
カフ・アイン⁷⁰⁷
Mirco
if your serializer is not valid you have to return 400 Bad request with serializer.errors
カフ・アイン⁷⁰⁷
Maxim
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
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?
Rajat
Демид
But how to run it? Django doesn't run any functions with my code once after start
Rajat
Демид
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
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
It is because django restart server 2 times
Демид
Rajat
How can I fix it?
I have spent lots time for scheduling t task my simple advice is to use celery
Демид
Rajat
Maxim
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
just read the Note section on https://docs.djangoproject.com/en/4.0/ref/applications/#django.apps.AppConfig.ready
Mihail
Morteza
Chiefchef
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 ...
Lucas
Chiefchef
Демид
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?