R@kesh
What is pytest
#
R@kesh
It is an ide
#
What is pytest
To test the individual code snippets by importing pytest library it is similar to unit test
M Latif
#
Jap
How to i manage many2many selection from font form and nested categories in forms
Paul
Hi everyone, i am having a bad time understanding how can i redirect a user after editing a form to be redirected to the same page.
The application has multiple rooms where users can enter their messages and after editing i wish to redirect to the same room where message was posted.
I cannot use two primary keys inside a function and i feel like i am missing something.
https://www.toptal.com/developers/hastebin/raw/zehakeyaki here is the code.
Thank you for your time.
Sunken
Can somebody help me to fix this?
ImportError: cannot import name 'ThreadSensitiveContext' from 'asgiref.sync'
~:$
Kirill
hi! have a problem in prod in admin django 4, 403 and "CSRF verification failed. Request aborted.". Works on dev server. I dont use SSL, dont override anything, cookie is set successfully, middleware is turned on in settings but i have no domain: access prod by ip. config: CSRF_COOKIE_AGE
31449600
CSRF_COOKIE_DOMAIN
None
CSRF_COOKIE_HTTPONLY
False
CSRF_COOKIE_NAME
'csrftoken'
CSRF_COOKIE_PATH
'/'
CSRF_COOKIE_SAMESITE
'Lax'
CSRF_COOKIE_SECURE
False
CSRF_FAILURE_VIEW
'django.views.csrf.csrf_failure'
CSRF_HEADER_NAME
'HTTP_X_CSRFTOKEN'
CSRF_TRUSTED_ORIGINS
['my ip']
CSRF_USE_SESSIONS
False. any hints pls?
Chaitanya
Chaitanya
Try to use it. It could be the error. Letsencrypt provide free ssl certificate. It's easy to deploy. Try thier website for instructions for your web server
Kirill
thanks but it looks too complex: need to install snapd (which doesnt starts in ubuntu 20 for some reason because it uses systemd and systemd is not used by default), then need to install certbot, etc.. became too complex since django 2 to deploy without ssl
Kirill
worked with CSRF_TRUSTED_ORIGINS = ['http://' + IP + ':8000']
Dmitry
Hey, people! Is template inside a template a good idea? (somewhere it must be plain text, somewhere it's a plot in matplotlib, somewhere it's a test with ABC, etc). What is the best way to implement this thing in Django?
toygar
SuperN00b
hi guys , I am deploying a django app that include websocket, using nginx only , note that for testing I run server by manage.py scripts
SuperN00b
the problem I met now is that websocket can not connect
SuperN00b
and this is my nginx conf
SuperN00b
`server {
# root folder of your application
root /home/ubuntu/django-battleship/;
listen 80;
charset utf-8;
client_max_body_size 100m;
# place where logs will be stored;
# folder and files have to be already located there, nginx will not create
access_log /home/ubuntu/django-battleship/logs/nginx-access.log;
error_log /home/ubuntu/django-battleship/logs/nginx-error.log;
location / {
proxy_pass http://localhost:8000;
}
location /ws/ {
proxy_pass http://localhost:8000/ws/;
}
# static files folder, I assume they will be used
location /static/ {
alias /home/ubuntu/django-battleship/static/;
}
# media files folder
location /media/ {
alias /home/ubuntu/django-battleship/media/;
}
proxy_set_header Host $host;
}`
Sai
Doragonsureiyā
Sai
For the channels read django official doc
SuperN00b
Use daphne
there is no way to avoid using some asgi support server friend ?
Sai
Sai
Maxim
SuperN00b
SuperN00b
Sai
Брат
https://dpaste.org/SnpO
Sai
Брат
user2 should be equal to some user's username
Брат
which logged in
Брат
It is like you wanna add some friend, but you need to pick yourself too(your user), to be friends. Thereby, I wanna that field to be set automatically.
Mr Sourav
class userProfile(models.Model):
person = models.ForeignKey(User, on_delete=models.CASCADE)
bio = models.TextField(max_length=500, null=True, blank=True)
Please tell me, by which query I can get this bio of user? This user model is django's default user model.
Mr Sourav
Id? Which id I've to pass?
Mr Sourav
user.id will return current user's bio?
DN
Mr Sourav
DN
user = User.objects.get(id=pk)
Bio = user.bio
Mr Sourav
https://pastebin.com/zkj06j9p
DN
Import models in ur views n then fire a query
user = userProfile.objects.get(id=pk)
Mr Sourav
Bro ur model class name is not User it's userProfile, check it once
In that case query is returning the object according to id. Suppose a person's user.id ==3 and user profile.id==4. And another person has vice-versa. Then django is showing the object to the person whose user.id is 3, whose userprofile I'd is 3. It's not matching with the users. It's complicated to understand but please...
DN
Mr Sourav
amirHosseinZibaei
How to serve media files in production through cpanel
Pavel
Hi everyone!
I'm making a Django Rest Framework application with a JWT authentication with tokens stored in HttpOnly cookies. Authentication is performed via reading the access cookie. I'm using a dj-rest-auth library for this purpose, but I'm a little confused of the security aspect of such method. Knowing that having authentication data stored in cookies can be used to perform CSRF attack, how can one protect their web against such attacks for a specific case I've described above? All cookies are set to be SameSite=Lex.
Do I need to also send X-CSRFTOKEN header obtained from the backend? That would mean that every request to the api will need to have that header. What should be the optimal setup having all those libraries?
Adjetey
Hello
Adjetey
Please am having a small issue
Adjetey
Django contact form not showing the sender's email
Nestor
quick question, what's the use of serializers fields in DRF if you can define what fields to serialize in Meta class?
luci._
Hello Goodnight.
I am developing a small app that expects to receive between 200-400 visits a day and host about 100-300 users. It is a tutorial blog, the idea is that each user can upload between 1-6 photos.
I want to deploy this project, but I don't know where. Any recommendations? I have seen ec2, gcloud, firebase, heroku, Lightsail. Sincerely, I look for the most economical option and that is easy to orchestrate the storage, bbdd and ci. I appreciate your help
Anshu
luci._
oh excellent I did not know that option, do you know if it can hold docker?
Rohan
luci._
thank you im going to try it.
Sp
Is there any people from kerala india who can teach me django and help me to do a project with individual assistance
Doragonsureiyā
Doragonsureiyā
Crygo
Is there a relationship between 3 models? For example models(forum,topic,post)Can I access like forumobj.topics.post_set_all?
Sivakanish
Guys does anyone know how to do crud operations In django can you please help me with code
Anshu
Sivakanish
fateme
I wrote an ajax function , to use in django admin where the user is creating .to populate the city field based on state field that select on drop down mood. But I cant absolutely find the element id of state field. can any one help me? ( state and city field have fk to the State and City model)
Sivakanish
Naresh
How to redirect next page while data is insert in django
Mirco
Naresh
It's not working