Charly
see: https://dev.to/guin/writing-a-django-data-migration-with-real-world-example-40m
Bola
Anyone with course on Django REST API should help me with it
Bola
what is your issue?
I only need it to learn some basics just like CRUD, signin, signup, forget password etc
The Inspired
not sure I understand
Bola
I said I need to learn Django REST framework
Bola
Just for learning purposes
Cc
Hi, if you want to learn you can search video tutorials in youtube, there are some that show the basic concepts, CRUD etc. I recommend you the DRF documentation is intuitive
The Inspired
...
Maryam
Hello، i have a problem with pgadmin and postgresql, I almost tried all the solutions but non of them worked for this problem, It’s not connecting to the server when i enter the password it says connection timeout expired
Doragonsureiyā
Hello، i have a problem with pgadmin and postgresql, I almost tried all the solutions but non of them worked for this problem, It’s not connecting to the server when i enter the password it says connection timeout expired
This is not a Django specific question, please delete your offtopic message. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
️امیر
In my google account settings app passwords is not available
You should enable 2-step verification first then you can search for app password in your Google account settings
aditya
then this is the wrong group to look up for cheating on interviews
Interview is done, I am just curious to know the answer
Vishal
1. Consider a situation where you need to migrate your database from MySQL to Postgresql , but at the same time live data for your site from users keep on coming, without downtime how would you migrate? 2. In production, migrations folder is deleted (database is still alive) so, if you want to change the table schema then how did you do that ? (Because current changes depends on previous migration)
Answer 1. Just dump a copy of your database and then restore that dumped file into the postgres database. And then write the configuration of your postgres database, in settings file, with your default database. Generally, at night most of the sites have low traffic, at that time you can switch your database. 2. If your migration file is deleted, just run make migrations command, and then run python manage.py migrate --fake, this command will run a fake command for your newly created migrations.
Alex
Interview is done, I am just curious to know the answer
was second question for Backend using django?
Lucky
Heya, I'm trying to set the default of a model column to currval(pg_get_serial_sequence('public.user','id')), as in https://stackoverflow.com/a/78741427/3423324#postgres-default-column-to-own-id I tried from django.contrib.auth.models import AbstractUser from django.db.models.expressions import Func from django.forms import IntegerField class CurrVal(Func): # noinspection SpellCheckingInspection function = "CURRVAL" output_field = IntegerField() class PgGetSerialSequence(Func): function = "pg_get_serial_sequence" class User(AbstractUser): substitute_user = models.ForeignKey('user.User', null=True, on_delete=models.SET_NULL, db_default=CurrVal(PgGetSerialSequence('public.user', 'id'))) However, it fails with user.User.substitute_user: (fields.E012) CurrVal(PgGetSerialSequence(F(public.user), F(id))) cannot be used in db_default. Any clue how I can get raw sql into the database default?
Kapil
I want to deploy my django project on hostinger any buddy can help me to do
‌‏bobus
Why don't you use youtube guide?
Ohotnik
I got this error: Request Method: GET Request URL: http://127.0.0.1:8000/ Django Version: 5.0.6 Exception Type: TemplateDoesNotExist Exception Value: products/index/ Exception Location: /home/salyh/first_project/venv/lib/python3.10/site-packages/django/template/loader.py, line 19, in get_template Raised during: products.views.index Python Executable: /home/salyh/first_project/venv/bin/python Python Version: 3.10.12 Python Path: ['/home/salyh/first_project/store', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/salyh/first_project/venv/lib/python3.10/site-packages'] Please help 🥺
Ohotnik
Can i send a photo?
Charly
Can i send a photo?
No, just answer the questions
Ohotnik
I created the app products in products directory and in directory is located my templates
Ohotnik
My English isn't good, i hope that you understand me
‌‏bobus
We understand da da
Anees
so your index path should be something like this. project-root/products/template/products/views/index.html
Anees
if your app name is store the it will be like /home/salyh/first_project/store/template/store/products/views/index.html
Man
I've configured Nginx to proxy requests for admin.myproject.com to my Django application running on port 8000. However, when accessing admin.myproject.com, it redirects to admin.myproject.com/admin and displays a "502 Bad Gateway" error. Here's my Nginx configuration for admin.myproject.com: `server { listen 80; server_name admin.myproject.com; location / { proxy_pass http://127.0.0.1:8000/admin/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; } }` I expect requests to admin.myproject.com to be proxied to http://127.0.0.1:8000/admin without displaying /admin in the browser. However, it currently adds /admin to the URL and results in a "502 Bad Gateway" error. The Django application is correctly configured to handle requests to /admin. Could you please provide guidance on why Nginx is appending /admin to the URL and causing this error? I'm seeking assistance to adjust my Nginx configuration so that requests to admin.myproject.com are correctly proxied to http://127.0.0.1:8000/admin without altering the URL displayed in the browser. Any help would be greatly appreciated.
Man
I've configured Nginx to proxy requests for admin.myproject.com to my Django application running on port 8000. However, when accessing admin.myproject.com, it redirects to admin.myproject.com/admin and displays a "502 Bad Gateway" error. Here's my Nginx configuration for admin.myproject.com: `server { listen 80; server_name admin.myproject.com; location / { proxy_pass http://127.0.0.1:8000/admin/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; } }` I expect requests to admin.myproject.com to be proxied to http://127.0.0.1:8000/admin without displaying /admin in the browser. However, it currently adds /admin to the URL and results in a "502 Bad Gateway" error. The Django application is correctly configured to handle requests to /admin. Could you please provide guidance on why Nginx is appending /admin to the URL and causing this error? I'm seeking assistance to adjust my Nginx configuration so that requests to admin.myproject.com are correctly proxied to http://127.0.0.1:8000/admin without altering the URL displayed in the browser. Any help would be greatly appreciated.
Man
remove "/" from here.
But it should redirect me to admin interface not main url
Alex
But it should redirect me to admin interface not main url
server { listen 80; server_name admin.myproject.com; location / { proxy_pass http://127.0.0.1:8000/admin; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_redirect off; } }
Alex
also make sure your allowed host are configured properly.
Alex
I want to deploy my django project on hostinger any buddy can help me to do
containerize it with docker, there are multiple docker template for django are available.
Priyanshu Pratap
Hey everyone i just have a doubt like when we make our rest api and uses jwt for authentication how django authenticate user like when we register the user and we get the access token as well as refresh token and store them in local storage of client and when the user sends the request to login then we send the generated tokens in headers to the login authentication endpoint of our backend. My question is how it authenticates the user on the basis of previously generated token during registration... is tokens gets stored in backend ? Like how it verify?
Pandu
i want to make a song plaform using react+django i'll add features like lyrics, song, blog, live chat. should i learn DRF or Django Ninja?
Pandu
i saw drf has builtin features like authentication , route permissions, but i hear ninja is faster. lightweight should i implement it mannually in ninja? or just learn drf?
Anees
Hey everyone i just have a doubt like when we make our rest api and uses jwt for authentication how django authenticate user like when we register the user and we get the access token as well as refresh token and store them in local storage of client and when the user sends the request to login then we send the generated tokens in headers to the login authentication endpoint of our backend. My question is how it authenticates the user on the basis of previously generated token during registration... is tokens gets stored in backend ? Like how it verify?
First of all its not secure to store the tokens locally you may save tokens in session and use cookies authenticate user. yes the token is usually a JWT token. Even if its not stored JWT tokens can be verified using JWT Secret. Further validity of token can be found using its expriry. The nataure of JWT token is that it can be read by anyone by you need JWT Secret to generate a specific token. so on server side when JWT data is recevied its is comapred to find out if the token is generated by a valid jwt secret. if that doesnt match it is treated as invalid. for more about jwt you can go to jwt.io
The Inspired
its not stored in the DB, though you can store it if you want to
The Inspired
oh someone already answered it, my bad.
Anees
Token is randomly generated for that authenticated user
No jwt tokens are generated based on JWT Secret they are not randam in any way.
Anees
i want to make a song plaform using react+django i'll add features like lyrics, song, blog, live chat. should i learn DRF or Django Ninja?
Django Ninja is easy to implement but less flexible to customize, so if you may need customizations in future you may go with DRF
Anees
If anyone has experince with browser fingerprints do contact me
Simran
Can someone please help me connect django and react
Simran
Use corsheaders
Yes but I'm not understanding
Simran
It's very confusing
Simran
I need to complete it in 2 days I've all set up ready
Priyanshu Pratap
What problem you are facing have you configured CORS in settings.py
Simran
I've used cors in settings
Alex
Yes I don't know how to run
it's hard to resolve issue without you sharing codebase or steps you took to connect the frontend and where you are facing the issue.
Tirth
Hello..I am new to django..can someone guide me where I can learn properly ?
Doragonsureiyā
Hello..I am new to django..can someone guide me where I can learn properly ?
Looking for Django tutorials? you can follow these three recommended ones: * Official documentation and tutorial * Tutorial from MDN * Tutorial from django-girls
Bekzod Juraev
Guys front or backend should handled Google authocation i did in drf entirely backend it is good?
Mirco
Guys front or backend should handled Google authocation i did in drf entirely backend it is good?
Frontend should get the token so the whole login flow DRF side you just have to validate and parse the token and protect your endpoints
Anees
Hello..I am new to django..can someone guide me where I can learn properly ?
Django offical documentation. Start with Getting Started
Arsham
Django offical documentation. Start with Getting Started
is there any pdf or something ? I checked the website its kinda complicated , the way they linked
Anees
is there any pdf or something ? I checked the website its kinda complicated , the way they linked
i think its well written bro. you just need to go from start let me share you a link. https://docs.djangoproject.com/en/5.0/intro/tutorial01/ if you complete this tutorial, its more then enough for a newb
Anees
i think it have 8 parts ,dont skips just finish one by one.
Arsham
what about "Code With Mosh" course?
Anees
I am not fan of courses. In last 14 years what i learn is to read the official documentation. Its verborse, does not contain unnecessary dicussion and you can always rely on it.
Anees
its upto you how you learn.
Jyothi
Hii I am connecting django with react
Jyothi
Can I do it without rest frame work
Jyothi
Anyone can explain the flow
Alex
Can I do it without rest frame work
nope, you need api framework