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

01.09.2025
Nginx: “no ssl_certificate is defined for the listen … ssl directive” on custom port 8001

Sorry if this question was asked before but I tried the suggestions in there and still cannot resolved it. I’m running Django project behind Nginx on my VPS. Main project is at https://myproject.com (port 443) and works …

01.09.2025
How can I resolve this Django TemplateDoesNotExist error?

I'm working through the "Django 5 by Example" textbook, and am nearly finished with chapter 12, however at the very end when the text asks you to runserver and checkout http://127.0.0.1:8000/accounts/login, I get the following error: …

01.09.2025
I have a Django model called DataLog that stores API action logs. I need to delete this automatically after every 60 days

What is the best practice in Django to achieve this? Should I use a management command + cron job, django-crontab, or Celery beat for scheduling the deletion? Is there a way to make this automatic without having to call the …

01.09.2025
Запуск Redis из Docker

Настраиваю celery для Django. Поставил Docker, поставил Redis, как сделать так, чтобы при старте системы поднимался Redis из Docker, чтобы в виртуальном окружении его не поднимать? Или же Docker надо ставить в самом окружении проекта? ОС Centos 10.

01.09.2025
Как отобразить данные из mysql на сайте django?

Есть у меня две базы: DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', }, 'mysql_db': { 'ENGINE': 'django.db.backends.mysql', 'NAME': 'ИМя2', 'USER': 'ИМя1', 'PASSWORD': 'Пароль', 'HOST': 'Айпи', 'PORT': 'Порт', } } пытаюсь в странице отобразить информацию из …

01.09.2025
Catching an AI-Generated Bug in Django URL Handling

Recently, I was experimenting with Django URL customization and token-based encryption. I used AI "ChatGPT" to optimize code include these lines : url = url[1:] + req.request_token url = '/' + encrypt_text(url) + '/' But I spotted a subtle …

31.08.2025
Django enrich QuerySet

I have an Django Application that runs only locally on my machine. I have two diffrent tabels, with the transaction and the price. Now I want to enrich my transaction with the price. I wrote something similar already to calculate …

31.08.2025
Websocket with Cloudflare proxy closes connection instantly with code 1006

What is the issue or error you’re encountering I have create a Django app which run on a uvicron server on and AWS EC2. The EC2 is attached to a load balancer which is then connected to cloudflare proxy. If …

30.08.2025
Git is not making a conflict when I think it should be

I am learning how to deploy a django website and for that I have 2 copies of the code in 2 Git branches one for developing (master) and the other for deploying (deployment) with differint configuarations. I did some modification …

30.08.2025
What does shutil.rmtree(d, ignore_errors=True) do?

I was working with shutil module. My file structure looked like this projects/backend/--3-5 repos-- . In one of the repo's views.py I used for d in destDirs: shutil.rmtree(d, ignore_errors=True) destDirs = "projects/backend/repo1/static/file1 After that my whole file system got …

30.08.2025
How to containerize a Django App properly?

I have sucessfully developed a Django App. However, i made some changes to the admin-panel and actually I can only successfully deploy the App in my tes-environment when I migrate the base-"makemgrations" and copy afterwards the changed migrations files for …

30.08.2025
Django OneToOneField, Pyright: Cannot access attribute (reportAttributeAccessIssue)

I try to check my Django project with pyright. There is this OneToOneField, which pyright does not detect, when I use it: user.lala Error message of pyright: error: Cannot access attribute "lala" for …

30.08.2025
How can use jwt and allauth. and is combing the neccessary?

I. Have been try to combine both jwt and django allauth but i'm still considering that is not important I have read different documentation but i was not still satisfied please i need some advice And is my allauth email-verfication …

29.08.2025
Problem with setting default file storage to boto for s3 integration?

The default storage does'nt change! There by not letting me add images to the aws bucket and coz of that it shows an access denied message when i open the image url but in reality it just added the image …

29.08.2025
Django doesn't release database connections for re-use, long after request has finished

My django app loads several pages (images) at once, e.g. to show a document, and queries the database mainly to check permissions. Django keeps the connections alive, but doesn't re-use them. At some point the maximum number of connections of …

29.08.2025
Django-Tenant-Users: IntegrityError on permissions_usertenantpermissions_profile_id_key when creating a tenant

I’m using Django with django-tenants and django-tenant-users to manage multi-tenant accounts. I’m having an issue when creating a new tenant: When I try to create a new user + its tenant through my view, I get the following error: django.db.utils.IntegrityError: …

29.08.2025
My django app broke after windows reinstallation

Yesterday I reinstalled Windows and now my Django project’s Google login (using django-allauth v0.65.11) stopped working. I use a virtual environment and reinstalled the same dependencies (pip freeze matches exactly). Before the Windows reinstall, everything worked fine. Now, when …

28.08.2025
Specify in which order to apply filters in django_filters.FilterSet

Within a django_filters.FilterSet: class SomeFilter(django_filters.FilterSet): model = SomeModel fields = { "is_archived": ("exact",), } include_ancestors = django_filters.BooleanFilter(method="include_ancestors_filter") def include_ancestors_filter(self, queryset, name, value): pass how can I specify that the filter field include_ancestors should be applied after all other filter …

28.08.2025
How to implement recurring payments in Django using QuickBooks Payments (card-on-file vs vault token)?

I am building a Django-based subscription system and integrating it with QuickBooks Payments. My goal: Allow a customer to enter their credit/debit card details once. Store their card in a secure way. Charge them automatically every month (like Stripe …

28.08.2025
Django tenants seeing data in all schemas

So I migrated my app to django tenants, in my local, I don't have any issues, I create a tenant and I don´t see the same data as public, but in the prod environment I see the data from public …

27.08.2025
Issues with djangocms-text upgrade, configuration & custom settings not working in django app

I'm working on a project that uses django, djangocms, and djangocms-text-ckeditor. The project is old and desperately in need of updating, so i'm currently updating these major packages one at a time. Due to djangocms-text-ckeditor no longer being supported and …

27.08.2025
Custom Connection usage in graphene_django

I have a variation of the problem described here: Using DjangoFilterConnectionField with custom Connection in graphene_django The modified problem is as follows: Lets say I have a Django model class 'User', that has a field 'email_addrs' that is a …

27.08.2025
Django REST Framework: "No default throttle rate set for 'signup' scope" even though scope is defined

I’m trying to apply custom throttling for the signup endpoint in my Django REST Framework API. The goal is to allow only 5 signup attempts per hour for anonymous users. I created a SignupRateThrottle class that sets scope = "signup" …

27.08.2025
Why django migrate doesn't work even though I used make migration and it have not error

I create a new instance of Model an use makemigrations its work and this is my 0001_initial.py: class Migration(migrations.Migration): initial = True dependencies = [ migrations.swappable_dependency(settings.AUTH_USER_MODEL), ] operations = [ migrations.CreateModel( name='ProfileModel', fields=[ ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('avatar', models.ImageField(blank=True, …

27.08.2025
Django REST framework gives me csrf token missing when i am logged in for POST requests

I am making an API with django rest framework and django 5.2 when i send a POST request, if i be logged in it gives me an CSRF token missing error. but if i be logged out it gives me …

27.08.2025
Error: "get" is not a known attribute of "None" (reportOptionalMemberAccess)

I use PyRight to check my Django code. It complains about that class FooForm(ModelForm): def clean(self): cleaned_data = super().clean() start = cleaned_data.get("start_date") # <------- here error: "get" is not a known attribute of "None" (reportOptionalMemberAccess) …

26.08.2025
Django 1.5.1: diagnose and fix Report

I've been handed a rather old Django installation to support, with the specific request to re-enable a report that used to go out every week or so, but stopped showing up a few months ago. Django v 1.5.1 Python 2.7.3 …

26.08.2025
How to handle feature and permission-based authorization in Next.js without delaying initial render?

I’m building a multi-tenant SaaS application with Django Ninja as the backend and Next.js as the frontend. I’m running into a problem around handling RBAC permissions and org-level feature entitlements without causing bad UI behaviour. Current setup The app …

26.08.2025
Как мне отобразить определенную информацию в html странице django из базы sqlite3?

Создаю тестовый проект в Django rest api. Есть данные из sqlite3: [ { "id": 1, "title": "test", "content": "test", "idcard": "Card", "idmenu": "Info", "author": "Admin", "date": "3" }, { "id": 2, "title": "Name table1", "content": "table1 will be here", "idcard": …

25.08.2025
Patterns for testing web API permissions

I am working on a cookie cutter JSON web API. Think /items/<id> with your typical CRUD of delete, patch, get, and post. Recently, we started rolling out a new permissions model for the API, where certain operations are forbidden based …

25.08.2025
Django 'join' tabels

I have 3 Tabels in Django class Transactions(models.Model): public_key = models.ForeignKey(Keys, on_delete=models.CASCADE) txid = models.CharField(max_length=30) timestamp = models.DateTimeField() hash = models.CharField(max_length=64) block = models.IntegerField() amount = models.IntegerField() saldo = models.IntegerField() fee = models.IntegerField() fiat_CHF = models.FloatField(default=0) fiat_USD = models.FloatField(default=0) fiat_EUR …

25.08.2025
Django join where values not null

I have 3 Tabels in Django class Transactions(models.Model): public_key = models.ForeignKey(Keys, on_delete=models.CASCADE) txid = models.CharField(max_length=30) timestamp = models.DateTimeField() hash = models.CharField(max_length=64) block = models.IntegerField() amount = models.IntegerField() saldo = models.IntegerField() fee = models.IntegerField() fiat_CHF = models.FloatField(default=0) fiat_USD = models.FloatField(default=0) fiat_EUR …

25.08.2025
So many terminal messages when starting django runserver

When I start python manage.py runserver I get many messages similar to the following: File C:\Users\PC\OneDrive\Documents\DoseSaaS\DoseV3MasterSaaS\templates\admin\dose\tenant\change_list.html first seen with mtime 1754471094.0 to the point it fills the terminal window. How do I stop this? Could not find anything …

24.08.2025
Django REST Auth password reset email sends API URL instead of frontend React URL

I am using dj-rest-auth with Django as the backend and React.js as the frontend. I want the password reset email to point to my React frontend URL, not the default API endpoint. Sending: http://localhost:8000/api/auth/password/reset/confirm/{uidb64}/{token} Correct url: https://my-domain.com/password-reset/confirm/{uidb64}/{token} .env <pre class="lang-json …

23.08.2025
Show the text from a Json file in Django template

I am starting learn django,I have made some basic templates/views and want to show the text from a json file located in the assets/jsons folder.The file is called &quot;quotes.json&quot; The content of the json file: { &quot;emp_details&quot;: [ { &quot;emp_name&quot;: …

23.08.2025
Django cannot register oauth2_provider and rest_framework to INSTALLED_APPS

I am working on this weekend project, to learn Django and I am stuck. Before adding the REST framework (one to last commit in the repo), everything was working just alright. Once I added …

22.08.2025
Managing Django groups and permissions for custom users

For my Django projects, I am used to creating a custom user model and managing what my user can do for a specific route using a roles field like this: class User(AbstractBaseUser, PermissionsMixin): name = models.CharField(&quot;full name&quot;, max_length=255, blank=True) email …

21.08.2025
Stripe webhooks not firing in Django app during normal checkout flow

I'm integrating Stripe with my Django app (using Django REST Framework). I've set it up to accept POSTs, and when I use the Stripe CLI to trigger events, everything works perfectly. Example Stripe CLI command: stripe listen --forward-to localhost:8000/webhooks/api/v1/stripe-webhook/ …

20.08.2025
Django connection_created signal is causing problems when testing

In my django application I have a list of notification types and I want to allow customers to subscribe to one or more notification types. Each notification type has somewhat of a custom logic so the code of each notification …

20.08.2025
535, b'5.7.139 Authentication unsuccessful, basic authentication is disabled

I have a website that uses an email contact form. Recently been told it does not work. When I recreated the error in development I got the error 535, b'5.7.139 Authentication unsuccessful, basic authentication is disabled. I read online that …