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

20.03.2025
I can develop a bulk massge software [closed]

How can I develop software that allows me to send bulk messages to customers via WhatsApp by importing a CSV file, using the official WhatsApp API, ensuring that my account remains active and does not get blocked? I need guidance …

20.03.2025
As django fresher developer what sequence of topics need to be done? [closed]

Please elaborate it I tried learning it with some tutorials of youtube, but not clear like its enough or not. I currently worked on shells, migrations, authentication and everything I need to do. I wanna land a good job as …

20.03.2025
How can I change device creation to be managed only through the Client model, and restrict direct device creation? [closed]

I currently have a system where devices can be created and managed through the Device model directly. However, I want to change it so that devices can only be added or deleted through the Client model, and not directly through …

20.03.2025
Hosting a web in local server

I built web with django, and hosted it in heroku. Now I am working for a bank and going to build dashboard, but I can not host it on heroku. It should be in the local server only as far …

20.03.2025
Form submit confirmation does not work in jQuery `ready()`

Working in Django, I am trying to update the items of a database through submitting a form. I need a confirmation dialog before submission. These are my lines on related code: $(document).ready(function(){ setInterval(function(){ $.ajax({ type: 'GET', url: 'http://127.0.0.1:8000/update_in_line_orders', success: function(response){ …

20.03.2025
Gemini 2.0 experimental image generation in django

I am working on a webapp with django backend. It is related to image generation with character consistency, we finally have a model that works well for that, gemini 2.0 flash experimental. I am generating a character with openAI and …

20.03.2025
Django session cookies not persisting

I have a Django API which upon successful login, uses the Set-Cookie Response Headers to set a sessionId and CSRF Token in the cookies. I had it working and all of a sudden it stopped, the cookies no longer persist. …

20.03.2025
404 error on Python App deployment on CPanel

Python==3.11.11 (server ver) Django==5.1.1 Hello, today I was to deploy my app on CPanel, and everything goes fine until the end, because when configurations are all done, the page put an 404 error: Not Found The requested URL was not …

20.03.2025
What is the best way to have row-level authorization in django with some constraints?

I have a django app which consists of multiple different models. These models are related to each others with database relations. And somehow these relations are making a hierarchy. For example: Model City can have multiple Libraries Model Library can …

20.03.2025
Create a Django custom Transform from an annotation

I've got an annotation for a foreign key field that I use frequently and would like to write a custom Django Transform which behaves similar to the annotation. The annotation that does what I would like is in this snippet: …

19.03.2025
Why does duplicating a Django filter condition change PostgreSQL’s query plan estimates?

I'm working on a Django project with PostgreSQL and have implemented a custom filter to select "active" records. The filter is defined as follows: def get_custom_filter(qs): return qs.filter( Q( Q(timestamp_field__lte=timezone.now(), related_obj__delay__isnull=True) | Q( related_obj__delay__lte=timezone.now(), type_obj__flag=False, timestamp_field__isnull=False, ) | Q(type_obj__flag=True, timestamp_field__lte=timezone.now()) …

19.03.2025
Why does my uwsgi app respond with prematurely closed connection?

I can serve my django app running uwsgi --socket lhhs/lhhs.sock --module lhhs/lhhs.wsgi --chmod-socket=664 And the django app runs quick and running python manage.py test shows it is fine. But uisng nginx and uwsgi-emperor I get upstream prematurely closed connection while …

19.03.2025
Django/CKEditor - config for extraProviders

How can I configure a simple extraProvider for local media in my CKEDITOR_5_CONFIGS in the settings.py file? I tested the configuration below via javascript and it worked fine, but when I switched to python, I got the error Uncaught CKEditorError: …

19.03.2025
I can't solve the migration problem in django

I put the oracle db that I was currently developing with django and oracle into the db that impdp and distributed it. However, the distribution db has a different schema name from the development db, so it is not possible …

19.03.2025
Deploy logs "--error-logfile/--log-file" railway with django

I'm deploying my django app for the very first time on railway. On railways in the project deployment details I see: enter image description here However when I go in the deploy logs I see this error …

19.03.2025
Error when applying migrations 'no password supplied', but I can connect to the database from the interpreter

I decided to revive my pet project that I wrote 2 years ago. First I had to update all dependencies, this is ok. But migrations are not performed when working with a local server. The pg_hba.conf file has md5. At …

19.03.2025
Как в Django Rest Framework перенести router.regiter() в декоратор

Написал декоратор который будет регестрировать в переданный router Viewset def register(router, prefix, basename=None): def decorator(viewset): if not prefix: raise ValueError('Не указано имя Viewset') if not issubclass(viewset, viewsets.GenericViewSet): raise ValueError('Wrapped class must subclass GenericViewSet.') router.register(prefix, viewset, basename) return viewset return decorator …

19.03.2025
Is there a way to define an authentication for webhooks in DRF Specacular

I have the following webhook definition change_event_webhook = OpenApiWebhook( name="AddonWebhook", decorator=extend_schema( summary="A Webhook event", description="Pushes events to a notification URL. ", tags=["webhooks"], request={"application/json": load_schema("myschema.json")}, responses={ "2XX": OpenApiResponse("Event was received successfully"), }, ), ) which produces the following …

19.03.2025
How to Automatically Copy Product Attributes to Variants in Django Models?

I am building an e-commerce website in Django where: A Product can have multiple variants. Each product has attributes (e.g., color, storage, display size). I want each variant to automatically inherit all attributes from the main product when it …

19.03.2025
Programmin Error at Routes , i am not getting why is the happening , please help me?

ProgrammingError at /routes/ column airline_app_route.route_id does not exist LINE 1: SELECT "airline_app_route"."route_id", "airline_app_route"."... ^ Request Method: GET Request URL: http://127.0.0.1:8000/routes/ Django Version: 5.1.7 Exception Type: ProgrammingError Exception Value: column airline_app_route.route_id does not exist LINE 1: SELECT "airline_app_route"."route_id", …

19.03.2025
How to cache python pip requirements of docker build progress?

I'm on a very slow internet connection, and the RUN pip install -r requirements.txt step of docker compose up --build keeps timing out halfway through. When I run docker compose up --build again, it looks like it restarts from …

19.03.2025
Django + Next cookies not being set when app is hosted

I have a Django app hosted on Google Cloud Run that upon logging in, sets a sessionid and csrftoken in the browser cookies. In my frontend Next app, which I am currently running locally, I redirect to an authenticated page …

19.03.2025
Ошибка при применении миграций no password supplied, но из интрпретатора могу подключиться к базе данных

Достал из загашника проект, который написал 2 года назад. Сначала пришлось все зависимости обновить, с этим ок. Но миграции при работе с локальным сервером не выполняются. В файле pg_hba.conf стоит md5. При этом, если подключаюсь к БД из интерпретатора через …

19.03.2025
Django Docker container unable to connect to Supabase PostgreSQL: Network is unreachable

I'm working on a Django project with Docker, and I'm trying to connect to a Supabase PostgreSQL database. On my local machine, I can connect to the database using the psql command, but when I try to connect from inside …

18.03.2025
How to specify the port of vscode debugger on a Django docker container?

I have a Django application inside a Docker container. I've configured the launch.json and tasks.json files to run my docker-compose file when the debugger runs: launch.json { "version": "0.2.0", "configurations": [ { "name": "Docker: Python - Django", "type": "docker", "request": …

18.03.2025
Should I learn Django first or understand web concepts like databases, APIs, and HTTP first?

I'm new to Django, and I'm currently learning from the official tutorial in the documentation. While going through it, I’ve noticed that many web-related concepts—such as databases, APIs, HTTP, and other web technologies—are mentioned frequently. I have a general understanding …

18.03.2025
Yarn build not generating index.html during Docker build, but works manually in container (Nginx, React, Gunicorn, Django)

I'm trying to set up a website with Nginx, React, Gunicorn, and Django using Docker. Everything works fine except for one issue: When I build the Docker container, the yarn build command doesn't generate the index.html file inside the container. …

18.03.2025
How to Order Queryset by EAV Attribute in Django Using django-filters?

I'm working on a Django project where I'm using an EAV (Entity-Attribute-Value) model to store dynamic attributes for my Product model. I need to allow users to filter and order products by price, which is stored as an EAV attribute …

18.03.2025
Django-allauth stuck on signup and headless=True confusion

I'm trying to setup django-allauth app to be used for authentication by a front end react app and a mobile app. There are some inconsistencies which most likely are just down to me not figuring out something. But ton's of …

17.03.2025
Signals with Channels updating one value at the time

I'm using a m2m signal that triggers django channels, to create a realtime update on a value. It works fine but if I go to the admin and update more than one at the same time (having multiple tabs opened) …

17.03.2025
Deployed Django Rest Framework API gives "Server got itself in trouble" on any call with payload

I am deploying my Django Rest API to a web server running on Ubuntu 24.04 LTS Linux and using the Apache web server. This web server is external; I have not set it up, and so some of the details …

17.03.2025
Error making django-oauth-toolkit migrations with add_token_checksum

I have a Django application that has been running for quite some time and I want to update the django-oauth-toolkit library. In this case the upgrade would be from version 2.4.0 to 3.0.1. The problem is that when I run …

17.03.2025
Cannot connect to websocket

I have app on Django Channels that use Daphne as a termination server and hosted on AWS EC2. So problem is, when i run app locally(or via ngrok) and try to connect everything is working, i have connection with websocket. …

17.03.2025
На сервере не работает smtp на django сайте

Сделал Django сайт, настроил отправку писем, задеплоил на сервере. Когда пользователь отправляет письмо, сервер стоит и падает с ошибкой 504. Я попробовал скачать с сервера все файлы и запустить сайт локально, письма отправлялись правильно. Настройки везде одинаковые, ошибка выглядит так …

17.03.2025
Template does not exists error in python anywhere

I have deployed my django app in python anywhere and getting below error : TemplateDoesNotExist at /topic/ cms_app\content.html I have two apps in my project. One is cms_app and other is users. My templates location is Content_Mgmnt/cms_app/templates /cms_app/content.html …

17.03.2025
Twilio TTS Mispronounces "Aradhya" – How to Fix It?

I’m using Twilio's text-to-speech (TTS) in a Django view to read out a message before connecting a call. However, Twilio mispronounces the name "Aradhya", and I’m looking for a way to fix it. Problem: Twilio reads "Aradhya" incorrectly, and I …

17.03.2025
Invalid Argument: X-Amz-Security-Token when my django-based website hosted by vercel tries to get static files from cloudflare r2

First of all: I have a R2 bucket on cloudflare that is public, allows any origins and any headers, and works completely fine. I'm using django-storages to storage and retrieve static files from that bucket, it works completely fine with …

17.03.2025
La commande makemigrations pools

I got stuck at the second step of the tutorial at docs.djangoproject.com/fr/5.1/intro/tutorial02/. When I run the makemigrations polls command, the result is: PS C:\Users\user\desktop\djangotutorial> python manage.py makemigrations polls Traceback (most recent call last): File "C:\Users\user\desktop\djangotutorial\manage.py", line 22, in …

17.03.2025
Django does not register apps [closed]

INSTALLED_APPS = [ # MY APPS: "learning_logs", # DEFAULT APPS: 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] My teacher has helped me, we even turned to AI, but nothing is working. For example, my teachers code runs perfectly on …

17.03.2025
Django MultiValueDictKeyError: 'category' When Submitting Form

'm working on a Django To-Do app, and I'm trying to implement an edit feature where users can modify a task's category and importancy. I have an edit.html template that contains a form, and when I submit it, I get …