"Вопросы и ответы" Django и Python, страница 2

23.06.2025
How to pass pk to form (ForeignKey) and views - from template when following link?

How to pass pk to the form (ForeignKey) and views - from the template when clicking on a link? Good day! I have a model. Which is displayed in the template. And the transition to another template is configured by …

23.06.2025
Best practice to create a django user connected to a stripe customer

I'm trying to create a simple website for selling a digital good. Frontend is html/js, backend is django (using allauth, with simple email registration and a Custom User model) and I'm using stripe to handle payments. I've implemented a checkout …

23.06.2025
Routing Problem from sign in page to a users account

The Issues is routing a user after creating an account on the webapp platform to the users dashboard created for the user. I can provide with the sign in and authcontext.js page which helps with this. signin.js import React, { …

23.06.2025
Can users and superusers have the same email/username in a Django application?

I have a CustomUser class for my users which is as follows. class CustomUser(AbstractBaseUser, PermissionsMixin): username = models.CharField(max_length=150, unique=True, null=True, blank=True) email = models.EmailField(max_length=240, unique=True) first_name = models.CharField(max_length=30, blank=True) last_name = models.CharField(max_length=30, blank=True) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) is_superuser …

23.06.2025
Indexing multiply nested models with django_elasticsearch_dsl

I'm trying to use Elasticsearch in my Django app. I have Lemma models that can have multiple Forms with one citation form that can, in turn, have multiple Spellings. I'm trying to execute a search on (1) the Lemma's citation …

22.06.2025
In django which logout option is best - custom logout or LogoutView? [duplicate]

Actually i'm using django 5.2.3 in that version LogoutView is always gives error. Any other way is there for LogoutView because i try all the way?............................................................................................................................................

22.06.2025
How can I make GrapesJS pages dynamic with real-time data from a Django backend in a React app?

I’m building a page builder application using GrapesJS, React, and Django (as the backend). I’ve successfully integrated GrapesJS into the React frontend, and I can design and save pages. However, I’m struggling to figure out how to make the created …

21.06.2025
Django static files not loading for one app when DEBUG=False [duplicate]

I'm working on a Django project with multiple apps (Home, student, login, etc.). When I set DEBUG = False in settings.py, the static files (CSS and JS) from my Home app load fine, but the static files from the student …

21.06.2025
How to change django default files storage to cloudinary storage for media files?

I am working on django project. It is working fine with local storage and decided to use cloudinary for media storage then for some reason the file storage is not changing to cloudinary media storage. Here's my settings.py file: <pre …

21.06.2025
Django - S3: collectstatic does not create new folder, even with all permissions and write privileges

Cursor ai called it a &quot;strange problem&quot;, so we're back to the original home of solutions. I upgraded django from 2.2 to 5.2, and upgraded my storages, tinymce,.. etc modules along with it. STORAGES = { 'staticfiles': { 'BACKEND': 'storages.backends.s3boto3.S3Boto3Storage', …

20.06.2025
Performance Degradation & Timeouts Since Django & Stack Upgrades

We’ve been experiencing significant performance issues and intermittent timeouts on our app ever since we upgraded: Django from v2.x to v4.2 Heroku stack from 20 to 22 Prior to these upgrades, our response times were solid and timeouts …

20.06.2025
Integrating New Google Maps Autocomplete API into Django Project

I'm using the new Google PlaceAutocompleteElement() API function (not the legacy google.maps.places.Autocomplete) and would like help integrating it into my Django project. Specifically, I want to add an address search bar to my application.html template. I've tried connecting the initMap() …

20.06.2025
Celery healthcheck fails in `set -e; cmd1;cmd2` and functions in `set -e; cmd1 && cmd2`

Problem docker compose fails app container for django celery app only in one of the 4 potential use cases. In each of the cases, the script in question is running inside the same django python docker image. The HOST OS …

20.06.2025
Node npm error - could not determine executable to run

I was trying to install tailwind css using npm on my python django project in vscode, and for some reason kept running into the following error messages: npm ERR! could not determine executable to run So then i tried it …

20.06.2025
Handle POST Request in DJANGO

I am new to DJANGO, and I am currently working on a project where I upload a file through a react page to a back-end handled by the DJANGO REST framework, after receiving the file I have to do some …

19.06.2025
Django - How to display image file in template

What I am trying to accomplish?: I uploaded multiple images(3) and I am trying to display each images in different image tag. Here is my code; How are you doing it?: I have attached my code to the question and …

19.06.2025
Can i connect my Youtube Channel Store to a Django E-commerce Website?

I am Django developer and I have a client who wants to connect his youtube store with the website that i'm gonna build with django. now i am confused that youtube will successfully connect the website or not. Anyone knows …

19.06.2025
How to select from the second field in the form - filtering data depending on the values of the first field?

Is it possible to somehow adapt something similar to my problem? I would like a list to appear in the form based on data from another list Select from the second field - filtering data - (contents) depending on the …

19.06.2025
Best resourcefor learning django restframework?

I am learning drf on my own and i am having difficulties in understanding all the things by researching and i am also not sure that i am doing it correclty. So help me by suggesting best resources except official …

19.06.2025
Why are my messages not showing in real-time using HTMX and WebSockets in Django?

I'm building a simple two-way chat system as a part of my web-app using HTMX WebSockets (htmx-ext-ws). The goal is to display incoming messages in real time without requiring a manual page refresh. The setup mostly works — messages are …

18.06.2025
Django/PostgreSQL: Unique constraint with a dynamic condition like expires_at > now()

I'm building a secure OTP system in Django. The model looks like this: class OTP(models.Model): MAX_ATTEMPTS = 3 DEFAULT_EXPIRE_IN_MINUTES = 1 class Purposes(models.IntegerChoices): LOGIN = 1, &quot;Login&quot; REGISTER = 2, &quot;Register&quot; VERIFY_PHONE = 3, &quot;Verify Phone&quot; VERIFY_EMAIL = …

18.06.2025
{"status":"error","message":"An unexpected error occurred","errors":"[Errno 5] Input/output error"}

This problem occurs when I create an order in my project. I hosted it on GoDaddy, and the problem occurred only after hosting. If I run this locally, it will create the order. Understand this error Error saving data: dl …

17.06.2025
Помогите прописать скрипт для сетапа

Есть ли у вас на сайте функция под заказ прописать скрипт для сетапа? Сама не умею . Пытаюсь найти специалиста, который в этом разбирается. На самом деле сетап не сложный. Насколько трудоёмкий, тоже не знаю. Надеюсь на понимание.

17.06.2025
How can I set up filtering in the form model of one field based on another when selecting?

I have 2 model tables. In the first table I have a form in the set in which there is one interesting field. This field can have the same values. If we consider the second table model - then in …

17.06.2025
Production server Bad Request (Error: ValueError: Unknown endpoint type: 'fd')

This morning, my production website went down with a &quot;Bad Request&quot; error. It was working the day before, and I made no changes that might have caused the error. Below is the traceback I got in the asgi.log file. I …

17.06.2025
How can I configure the wrapping of a large long line of text in a form Django?

I have a form with OneToOneField where data is loaded from another table model. But I often have large data sizes there and the displayed text does not fit into the window size. Is it possible to somehow configure the …

16.06.2025
Setup to deploy different django app do different environment(Prod/UAT)

I'm building an application using Django for backend and React for frontend and there's need to deploy do different environments, UAT and PROD. How do I set up the Nginx and Django environments? Please share your views or resources that …

16.06.2025
Django URL matching but displaying 'Page Not Found'

I'm getting a page not found error for a url I know is defined in urls.py - exact same code works on the qa server, but for some reason on the live server it gives a 404 error. <a href="https://i.sstatic.net/xVAnJmli.png" …

16.06.2025
Django project -createsuperuser Doesnt work [closed]

I am facing an issue while creating my superuser using the following command: ./manage.py createsuperuser, it seems that there is no error but the line where í can set my email and password doesnt appear enter image …

16.06.2025
Password doesnt get saved from the signup request in django-allauth

I have a django app and i am using django-allauth to authenticate users.I dont have anything complex setup right now, all i am trying to do is let the user signup through email and password and verify their email before …

16.06.2025
Django Multi-Database ValueError: "Cannot assign Role object: the current database router prevents this relation"

I'm encountering a ValueError in my Django application when trying to save a User object with a related UserRoleAssociation in the admin interface. The error occurs in a multi-database setup where both the UserRoleAssociation and Role models are intended to …

15.06.2025
How to access a Django site from another device on a local network

I'm running a Django site on my computer and I want to access it from another device on the same Wi-Fi network (for example, from a phone or another laptop). I tried running python manage.py runserver, but I can only …

14.06.2025
Unable to find GDAL library in conda env

I have a Django project configured with PyCharm. I am using a conda env for packages installations. I have installed gdal. But when I run server, I see: django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried &quot;gdal310&quot;, &quot;gdal309&quot;, &quot;gdal308&quot;, &quot;gdal307&quot;, …

14.06.2025
Не работает команда collectstatic в проекте Django

При вводе команды 'python manage.py collectstatic' в командную строку в Visual Studio 2022 выводится ошибка: 'You're using the staticfiles app without having set the STATIC_ROOT setting to a filesystem path.' Вроде как путь указан криво. А он указан вроде нормально, …

13.06.2025
Why is my selenium script blocked in production in headless mode, while it works completely fine in local enviroment? i use python

I have a selenium web scrapper, that runs well in my local development environment even in headless mode. However when i deploy it in production in a Linode Ubuntu VPS, somehow it fails with a Timeout exceeded message.Any help would …

13.06.2025
Shouldn't the call to django_stubs_ext.monkeypatch should be inside a TYPE_CHECKING check?

Simple question here about django_stubs_ext. Shouldn't the monkey patching occur only during TYPE_CHECKING ? Something like this: # settings.py if TYPE_CHECKING: import django_stubs_ext django_stubs_ext.monkeypatch()

13.06.2025
Pythonanywhere getting an error when deploying [closed]

Something went wrong :-( Something went wrong while trying to load this site; please try again later. Debugging tips If this is your site, and you just reloaded it, then the problem might simply be that it hasn't loaded up …

13.06.2025
How do I structure a Django REST Framework API backend when the frontend is already built?

I'm building a Visitor Management System (VMS), and I've been given a complete frontend to work with. My task is to build the API-based backend using Django and Django REST Framework, which I'm familiar with from smaller projects. However, I'm …

13.06.2025
Django-minify-html breaks Google Analytics injection

I'm running into an issue and would appreciate some pointers. I have a production Django app where I included Google Analytics using a context processor and conditionally render it in my base.html template like this: &lt;!-- Google Analytics --&gt; …

13.06.2025
Webapp deployment issue in shared hosting

Can anyone tell me how I can deploy my Django React-based webapp in my shared hosting