Idk
https://docs.djangoproject.com/en/3.2/ref/settings/#login-redirect-url
No I mean if someone is already logfed in and trying to access the users/login, I want them to get redirected to home. Is that possible ?
Idk
*logged
Mirco
No I mean if someone is already logfed in and trying to access the users/login, I want them to get redirected to home. Is that possible ?
Yes just check if request.user.is_authenticated inside your Login view and redirect to LOGIN_REDIRECT_URL
Javad
I use VS Code
Also you can use django shell to see raw db quries. https://stackoverflow.com/questions/1074212/how-can-i-see-the-raw-sql-queries-django-is-running
Anonymous
Anyone here familiar with django? In my base.html template I have created a drop down list with multiple companies. Essentially When I’m a on the specific company that should be the active company as that would be the company in a currently updating. Right I can go into any of these companies but I am struggling to set an icon to the current page I am on. Any help would be appreciated
Idk
Yes just check if request.user.is_authenticated inside your Login view and redirect to LOGIN_REDIRECT_URL
Thanks. Just had to use redirect_authenticated_user=True as a parameter in LoginView
Doragonsureiyā
Your question is not related to Django. If it's a Python related question go to @Python group, otherwise please move to @PythonOfftopic group and ask there.
S Sidharth
Has anybody made a coding platform like hackerank with django? If so how to add c++, python compilers and interpreters to the back-end?
AMIR
How to creat(POST) a model using curl that one of the model's field is m2m? i try this👇 but does't work curl \ -H 'Content-Type: application/json' \ -X POST \ -d '{"Field_one": "some data", "m2m Field": [{"Field_two": "some data"}]}' \ http://127.0.0.1:8000/endpoint/
Shreehari
Hi, is it possible to pass query parameters(like ?list=active&xyz=ab) in reverse() or resolve()?
Mirco
Hi, is it possible to pass query parameters(like ?list=active&xyz=ab) in reverse() or resolve()?
Yes f"{reverse('your-url-name')}?your_param=foo" You can also use some uri builder to better parse when you have lots of params
Doragonsureiyā
thank you
You're welcome! 😊
Manish
Hi I want to create a rest api app in /admin/advisor/ Can please help me or atleast point me correct resources Thanks
Manish
Yes no luck 🥺
Mauricio
Woul someone help me to get my manage.py to work properly
Mauricio
Changes I made in .py files does not reload
Mauricio
I have to stop the project, and run it again
Mauricio
Already delete .pyc files and tried all the solutions available on stack overflow
Mauricio
By running the runserver ?
The changes don't reload automatically, I have to stop the project and run it again, every time
Mauricio
Yes, sir, I'm new with django
Mauricio
I have to stop the project (Ctrl+C on windows)
Mauricio
And run it again (python manage.py runserver)
Mirco
Yes, sir, I'm new with django
It's pretty strange, if you are able to run the runserver command The auto reload should work
Mauricio
Mauricio
I created a new virtual env, re install IDE and delete .pyc files
Mauricio
But the auto realod does not work properly
T I T T U
Anyone know how to without refresh templates? And which plugins is used for pycharm? Live edit is not in plugins in pycharms session
T I T T U
Harsh
No
Harsh
When you click on refresh its gonna call that page.
T I T T U
When you click on refresh its gonna call that page.
I'm asking any other plugins in pycharm for without refreshing templates pages
T I T T U
I'm asking any other plugins in pycharm for without refreshing templates pages
Early plugins is used for live edit in pycharm Currently, that plugin is not there
Chidiebere
My python codes aren’t working in my Django html template
Anonymous
Hello anyone know how to use docker with django project
Anonymous
any buddy help to replace some text from cookies like True to true etc
MRO
guys I have the following doubt:
MRO
I have the app1 that in models looks like this:
MRO
Contributor (models.Model): name = models.CharField (max_length = 100, unique = False) code = models.CharField (max_length = 20, unique = False)
MRO
In app2 what I have in models looks like this:
MRO
class Status (models.Model): status_2021 = models.CharField (max_length = 100, null = True, blank = True) status_2020 = models.CharField (max_length = 100, null = True, blank = True) class FileImg (models.Model): file_2021 = models.CharField (max_length = 100, null = True, blank = True) file_2020 = models.CharField (max_length = 100, null = True, blank = True)
MRO
How do I relate app2 to app1 in a way that when creating app1, does he create the related app2 already? even if it has nothing and all fields in app2 are null.
MRO
I tried to use the default property and it still didn't work
∆
Hi all, who know why after installing certbot site 404
Doragonsureiyā
Hi all, who know why after installing certbot site 404
Step 1: Open a browser Step 2: Write down https://google.com or https://duck.com and press Enter Step 3: In the search box, write down the same words you asked here Step 4: Read the first results
Doragonsureiyā
What are you talking about?
Ivan
Hello, I have created Django project based on Sqlite with 1 model. What is the proper way to fill this table with my data? As far as I remember, the best way to initialize the tables in Django projects is migration mechanism ? Am I right?
Doragonsureiyā
What are you talking about?
Raghavender
Module not found erroe:no module named with mysql. Connector mysql is not a package? Pls solve my question
Doragonsureiyā
Module not found erroe:no module named with mysql. Connector mysql is not a package? Pls solve my question
Please provide a full explanation including all the details that you consider relevant. Your statement is too broad and there is no clear way to answer you, you have to explain: - what you're doing - what you're expecting - what you're using - where you're running the script - what Python version you're using - what packages and their versions you're using - and the most important thing: show the code YOU wrote (read rule 5️⃣ for that) and more details, that way your chances to get help will increase
Raghavender
When I'm importing import mysql. Connector
Raghavender
I'm trying to connect python and mysql database
Raghavender
We need connector to connect python and mysql
Raghavender
I have installed connector even though same problem
Suprit
Please help me to solve this problem in Django.. 1)User sends request to app will automatically added(append) to queue. 2)If user is at first location then 30 seconds time is alloted to that first user and it will redirected to main page while other users are waiting in queue (other page will showing you are in queue) till first user will terminate his session. 3)After terminating first user, second user automatically getting to first and alloted 30 seconds and redirected to main page. 4)exited user will redirected to exit page. Please help me to solve this problem in django How can I do this with Multithreading, list and middleware
Suprit
I have tried bro
Doragonsureiyā
I have tried bro
Try harder until you get what you want! don't give up! 🦾
Suprit
Ok
Christof
How to check it and where
.
Hi guys. Can some1 explain how to do smth like this: I have models https://ghostbin.co/paste/p58p4 I need to register user not only with required fields, but with address to, which is field of Client model, which has foreign key to Adress model. So after user registration client instance also should be created with address Payload data to register is: { "first_name": "t", "last_name": "t", "email": "johndoe@test.com", "password": "qwerty", "address": 1 } So with using djoser i need to override UserCreateSerializer, which already validates all fields except address. I try to add address to my own class UserSignUpSerializer(UserCreateSerializer) such as PrimaryRelatedKeyField, but got errors. https://ghostbin.co/paste/p58p4
Deleted
https://stackoverflow.com/questions/67380016/how-to-achieve-function-of-create-folder-in-the-webpage
Suprit
def incoming_users(request): try: request.session['user_id'] = user_id_creation() except: print("*WARNING* - Unable to copy user id to session") userid = request.session['user_id'] print("userid = ",userid) return redirect('home/', userid=userid) def add_user_queue(userid): USER_QUEUE.append(userid) def user_id_creation(): global USER_COUNT USER_COUNT += 1 print("USER_COUNT = ", USER_COUNT) return USER_COUNT def home(request): try: add_user_queue() except: print("*WARNING* - Unable to add user to queue from home view") request.session['isactive'] = True print("USER_QUEUE from home= ", USER_QUEUE) return HttpResponse("This is Capture page for first user in queue")
Suprit
Hy guys please help me why I am not able to add user in a queue
Suprit
Output : - *WARNING* - Unable to add user to queue from home view USER_QUEUE from home= []
Anonymous
peer flood
Ahmed
use get_display_name
Darta
is it possible to change id field name in django admin? i change others with verbose_name but how about id? list_display = ['id','str', 'title', 'status', 'active']
Neo
how can i use drf throttle to block incorrect logins by ip and username, by default it is blocking based on ip address.?