"Вопросы и ответы" Django и Python

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 "Bad Request" 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

12.06.2025
FileNotFoundError: Could not find module 'gdal.dll' when running Django with GeoDjango on Windows (Conda environment)

I'm working on a Django project using GeoDjango for spatial models. I'm on Windows 10, using a Conda environment (moodspend). When I try to run the server with: python manage.py runserver I get this error: (moodspend) PS C:\Users\ngari\Desktop\Ngari's Projects\moodspend\backend&gt; …

12.06.2025
Возможно ли сделать групповую обработку в админке Django?

Доброго времени суток! Я в Джанго новичок. Возможно ли такое организовать? Необходимо вывести три поля на форму, сделать по ним отбор, затем выбрать какое-то значение и записать его в тот набор, который получился в результате отбора? По одному полю нужно …

12.06.2025
How can I send a column from one field of the queryset model to the form?

Good day! I have a model table. And a form. I filter the query from the queryset model by certain criteria and send it to the code in views. From the filtered queryset I would like to take only one …

11.06.2025
How do I write a Django ORM query that returns a match based on an intersection of lists?

If I have, for example: from django.contrib.postgres.fields import JSONField class MyModel(models.Model): data = JSONField() GIVEN a model instance obj1, where data == ['apple', 'banana', 'orange'] GIVEN a model instance obj2, where data == ['banana', 'orange'] GIVEN a model instance …

11.06.2025
Should I really use React/Vue with Django instead of Alpine.js? [closed]

I have a page where user creates an instance. An instance has a bunch of characteristics and foreign key to product (which has category and name itself) and all the fields are static - just stylized selects and inputs, but …

11.06.2025
How can I convert the last / any row of a model / queryset into one dictionary? [closed]

Good day! I have a table model. I plan to take one row from it - one set of elements. To place it in an object - a dictionary. How can I place the last or first or a specific …

11.06.2025
React + React Native + Django AllAuth

I'm running a Django server which has API's I consume through a React Native and React applications. I want it to work for Google, Facebook, Instagram and Twitter. For this question I want to focus on the React Application and …

11.06.2025
Django Sitemap issue: GSC fail to fetch sitemap with error "Sitemap could not be read"

I created sitemap using django default sitemap from django.contrib.sitemaps.views import sitemap Here is the complete process #urls.py sitemaps = { 'static': StaticViewSitemap, 'blogpost_detail': BlogSitemap, 'portfolio-details': PortfolioSitemap, # Add others like 'posts': PostSitemap if needed } path( &quot;sitemap.xml&quot;, sitemap, …

11.06.2025
Django admin site is looking for a template: <project_name>.html ...I want to use the default template

My project's admin site was working earlier with everything kept at default. But I'm building the site and after lots of coding I get an error where it is asking for a template that has the name of the project. …

11.06.2025
How Does Connection Pooling Work In Django?

If I'm not wrong, currently there are two ways to have connection pooling in Django: Native Connection Pooling (Django 5.x) Using PGBouncer I want to know that how connection pooling works behind the scene in Django. In FastAPI, …

10.06.2025
How can I fill in related models separately through forms (OneToOneField)?

I have two table models. I write data to one of them using a form. I also want to write data to the other model table using a form. But I'm trying to link these tables. Use the first one …

10.06.2025
Gunicorn + Gevent + Opentelemetry

Anyone using Django + Gunicorn + Gevent + Opentelemetry in production? Would love to know how you got it to work. Seems like I can't seem to use BatchSpanProcessor or BatchLogRecordProcessor. I'm getting errors which seem to have many open …

09.06.2025
Role and Permission in Django DRF

I am implementing permission-roles in Django using DRF but not sure where i got stuck here Here are models: class User(): class Staff() user = models.ForeignKey( User, on_delete=models.CASCADE, related_name=&quot;staffs&quot;) business = models.ForeignKey( &quot;Business&quot;, on_delete=models.CASCADE, related_name=&quot;staffs&quot; ) role = models.PositiveSmallIntegerField (superadmin, …

09.06.2025
Is there a way to test blog post permissions in PyTest?

I've been trying to make the final test pass. I seem to be getting a 403 error, nothing that I'm not authorized to make a post. Even though I gave the test user authorization to post tests. I don't understand …

09.06.2025
How do I prevent a user from creating multiple objects within 24 hours in Django

I'm trying to prevent users from creating more than one Mining object within a 24-hour period in my Django project. I chose to use Django signals, specifically the pre_save signal, to enforce this rule globally—regardless of whether the object is …

09.06.2025
Trying to send basic string to Django Backend via POST request using axios but no data is sent

I've been trying a basic string to Django backend from frontend using axios.post call. Connection is ensured and backend side detects the request but the data is empty. Frontend side: const axios = Axios.create({ baseURL: API_URL, headers: { 'Content-Type': 'application/json', …

09.06.2025
How to get Custom Adapter to respect the 'next' URL query parameter

I am using allauth in my Django project and I have set up a custom account adapter which I have specified in settings.py - ACCOUNT_ADAPTER. My issue is once the user logs in in at a URL like /accounts/login/?next=/checkout/, my …

08.06.2025
Не работают ссылки на сайте в Django

Не работают ссылки, хотя вроде всё прописано верно. В файле urls.py: from django.urls import path from . import views urlpatterns = [ path ('', views.reg, name = 'Reg_page'), path ('about/', views.about, name = 'About') ] В файле views.py: def …

08.06.2025
Django Field errors not displaying

Here is my forms.py code: from .models import User class userRegistrationForm(forms.ModelForm): password = forms.CharField(widget = forms.PasswordInput()) confirm_password = forms.CharField(widget = forms.PasswordInput()) class Meta: model = User fields = ['first_name', 'last_name', 'username', 'email','password'] ``` Here is my views.py code: …

08.06.2025
Фоновые задания в Джанго

Никак не могу понять - с какой стороны подойти к такой задаче: В базу надо записывать данные с определенной периодичностью. Как в Джанго реализованы фоновые задачи, выполняемые по расписанию? В идеале было бы хорошо создать внутри скрипт и заполнять данными …

08.06.2025
Django - Testing async management command not working as expected

To give some context, i made a async function which works fine when testing manually but when I use Django's testcases, the query is not returning anything back inside the async block, if I try the same query outside, it …