Tanjiro
my error https://nekobin.com/getorisidu
Fariba
Hello guys I have django project and use simplejwt for autentication I use access token and refresh token for autentication Set both of them in cookies and when send request set access token in header But when access token expired It doesn't be refreshed by refresh token Why? How update access token by refresh token?
The Inspired
my error https://nekobin.com/getorisidu
Not sure if its me, but I still dont see any code.
The Inspired
oh im sorry sir
Don't call me "sir" please 😅🙏. It makes me feel like an old man. 😢
Tanjiro
i just paste it and saved it then its gone. I tried opening it earlier and i can still see it
Tanjiro
its frustrating.
The Inspired
I tried, same problem
hmm... then I will have to take a look at the code
Sousa
Hi
Sousa
python manage.py runserver Traceback (most recent call last): File "/Applications/MAMP/htdocs/jsti_space/manage.py", line 11, in main from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Applications/MAMP/htdocs/jsti_space/manage.py", line 22, in <module> main() File "/Applications/MAMP/htdocs/jsti_space/manage.py", line 13, in main raise ImportError( ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
Sousa
Can you help me with this error? I'm a beginner at django.
Dafa
Can you help me with this error? I'm a beginner at django.
It's either there is no django installed or the virtual environment isn't activated. 1.Change the directory to your virtual environment folder and run "pip install django" 2.Run "Scripts/activate" to activate the virtual environment
Sousa
Django is installed and the virtual environment is activated, but the command does not recognize Python
Sousa
venv/bin/python manage.py runserver
Sousa
Why does it happen?
pranav
Why does it happen?
Python manage.py runserver
Sousa
└─ python manage.py runserver Traceback (most recent call last): File "/Applications/MAMP/htdocs/jsti_space/setup/manage.py", line 11, in main from django.core.management import execute_from_command_line ModuleNotFoundError: No module named 'django' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/Applications/MAMP/htdocs/jsti_space/setup/manage.py", line 22, in <module> main() File "/Applications/MAMP/htdocs/jsti_space/setup/manage.py", line 13, in main raise ImportError( ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
Sousa
└─ source venv/bin/activate
Sousa
└─ . venv/bin/activate
michael
Why does it happen?
Could be you are using the wrong interpreter... How many interpreters do you have on your system
Sousa
1
Sousa
Python 3.12.2
Sousa
I'm using ./venv/bin/python
Sousa
in vscode
Dafa
Open your python shell and "import django" If Django is installed correctly within your virtual environment, this command should execute without any errors.
Sousa
Select interpreter
Sousa
└─ django-admin --version 5.0.6
Sousa
instaled
Dafa
did you install the django in your virtual environment folder?
Sousa
Yes
Sousa
venv/lib/django
michael
Python 3.12.2
If you have the correct interpreter selected then this shouldn't be a problem coz if you installed Django with one interpreter and try to run it with another it won't work... I see you are using vs code... Check again the current interpreter selected in VS code
Sousa
It's as if python is not being recognized as a command within the virtual environment
Sousa
└─ python -m venv venv
Sousa
└─ source venv/bin/activate
Sousa
└─ pip install -r requirements.txt
Sousa
My requirements.txt Django==5.0.6 psycopg2-binary>=2.9.6,<2.10
Sousa
└─ django-admin startproject core .
Sousa
yes
Sousa
> Python: select interpreter
michael
Cool...if so then try to check if you can install and import other packages successfully in your venv
michael
Also Has deactivating and reactivating helped
Sousa
Also Has deactivating and reactivating helped
What command to disable and activate again?
michael
How can I install new packages to test?
The way you have installed Django with pip
Sousa
It's as if it doesn't recognize the python command within the environment, but it works if you type the absolute command ./venv/bin/python
michael
It's as if it doesn't recognize the python command within the environment, but it works if you type the absolute command ./venv/bin/python
To deactivate use the deactivate CMD Damn... I thought... Nywy have you worked with venv before... trying to figure out why this is a menace
Sousa
yes I already work with env
Un Poco Loco
Did you manage to solve it?
Run the code in the cmd in which the environment is activated
𝑀𝓇. 𝐿𝑒𝓋𝒾𝒶𝓉𝒽𝒶𝓃
Hi guys, I have a question Which coding method is better for large projects? FBV or CBV, and why?
Husen
Hello everybody. If I run the project through docker, will postgres create it?
KartiK
hello i was making e commerce website api with django rest framework now after making every API with authentication now the problem is if i register new user with auth/user then login it from auth/jwt/create then when i am going to carts end point then add few products then going to orders endpoint i am unable to add the cart it there but if i first add customer which i got it from auth/user directly from admin site then if i do these thing it is working idk what to do somebody plss tell me if i am doing something wrong also how the frond end is going to work with these api because i dont know front end yet.
Dhruv
OTPAdminSite.has_permission() missing 1 required positional argument: 'view'
Dhruv
how to solve to bug in OTP auth in error
David H
Hi Guys, I have a public django API, and when someone makes a request the credentials are sent base64-encoded. Does anyone know a django-solution for auth optimization in this case? Validating the credentials in each request could be a little slow for massive use due to mysql connections. I tought about making some Redis cache solution, but if there is a django one it would be nice. Thanks in Advance.
The Inspired
Hi guys, I have a question Which coding method is better for large projects? FBV or CBV, and why?
Depends on what you want. if the logic is simple, FBV will do. If you want more control over how you handle different types of requests, CBV are better. Ultimately it's upto you what you want to use
Madhur
Hi, I am getting the below error. Can anyone please help to understand what is this error. I am new to django. Exception Type: IntegrityError Exception Value: UNIQUE constraint failed: home_campaign.campaign_id Exception Location: /Users/madhurgujarathi/Documents/study/django/Campaign/venv/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py, line 329, in execute Raised during: django.contrib.admin.options.add_view and the model is class Campaign(models.Model): campaign_id = models.UUIDField(primary_key=True, default=uuid.uuid4(),unique=True, editable=False) campaign_name = models.TextField(max_length=20, null=False) campaign_type = models.CharField(max_length=10, choices=({"MANUAL": "Manual", "AUTOMATIC": "Automatic"}))
Chris
Guys anyone with a good tutorial on how to implement social application authentication using django-allauth
𝑀𝓇. 𝐿𝑒𝓋𝒾𝒶𝓉𝒽𝒶𝓃
Okay
So?
The Inspired
I want to create big project with api
use both. then keep whichever you like and remove the other one
Никайтос
so, I'm running a Django project with daphne server (for websockets) in docker compose. daphne doesn't work with staticfiles by default, so i'm trying to fix this with nginx container in my compose file. the problem is, i can't configure it the right way, staticfiles are still not loading :-( my docker-compose: https://pastebin.com/fLgaqF3k my nginx config file: https://pastebin.com/sNF5Jast It works perfectly fine with manage.py runserver, so the problem is not in my settings or static directory, it's somewhere in nginx configuration
𝑀𝓇. 𝐿𝑒𝓋𝒾𝒶𝓉𝒽𝒶𝓃
Ali Fallahi
Hello everyone, I hope you're all doing well. I've implemented authentication system with JWT and now during login, I'm returning an access and refresh token to the frontend. I also have an API endpoint that takes a refresh token and returns a new access token for the same user. This means whenever the frontend detects that the access token is expired, it sends a request to get a new access token, and if the refresh token is invalidated, it logs the user out completely. Now, my first question is whether this approach is correct? And my second question is about when and how to use a blacklist for token storage, as I haven't implemented logout functionality yet. Please advise on when to use the blacklist.
Levitybot
Hi, I am getting the below error. Can anyone please help to understand what is this error. I am new to django. Exception Type: IntegrityError Exception Value: UNIQUE constraint failed: home_campaign.campaign_id Exception Location: /Users/madhurgujarathi/Documents/study/django/Campaign/venv/lib/python3.11/site-packages/django/db/backends/sqlite3/base.py, line 329, in execute Raised during: django.contrib.admin.options.add_view and the model is class Campaign(models.Model): campaign_id = models.UUIDField(primary_key=True, default=uuid.uuid4(),unique=True, editable=False) campaign_name = models.TextField(max_length=20, null=False) campaign_type = models.CharField(max_length=10, choices=({"MANUAL": "Manual", "AUTOMATIC": "Automatic"}))
Not sure if anyone has answered the original question yet, sorry if this is a duplicate. The error you are getting is because there is a 'unique' constraint on 'campaign_id'. This is good, that looks like your primary key. Essentially the mistake you are making somewhere is trying to add a second campaign to the database with an identical 'campaign_id' to one that already exists in the database. This could be because you are using adding new rather than updating changes, or because you have an error with how new uuid's are generated and it is generating the same key twice (which it should not do).
Oviyan S
When I try to access the admin page in django It shows type error cannot mix str and non str How to resolve that error