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

21.12.2024
My is the block content on django is displaying below the footer

This is the base.html the block content is between the header and the footer <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <h1>header</h1> {% block content %} {% endblock content %} <h1>footer</h1> </body> </html> …

21.12.2024
Django Function Update

I'm doing the update function but I get a message Page not found enter image description here views.py def detalle_tarea(request, tarea_id): if request.method == 'GET': tarea = get_object_or_404(Tarea, pk=tarea_id) form = TareaForm(instance=tarea) return render(request, 'tarea_detalles.html', {'tarea': tarea, …

21.12.2024
How to get my favicon at `example.com/favicon.ico` in my Django project?

Google currently does not show my website's favicon in its search results and I learned that it is becuase it should be located at example.com/favicon.ico. I'm looking for a simple way to do this, hopefully without relying on redirects. I've …

21.12.2024
Django view to PNG

I'm writing django webapp, and part of it is to generate view and convert it to png image. (any ideas other then below are appreciated). I've looked at some tools to convert "html to png", but there is mainly problem …

20.12.2024
How to make Django's Browsable API Renderer generate correct URLs with an /api/ prefix when behind Nginx?

I'm deploying a Django application using the Django Rest Framework (DRF) on a server behind Nginx. The application is accessible via https://my-site.com/api/ where /api is routed to the Django application. However, when I access the API's browsable …

20.12.2024
SessionStore object has no attribute 'get_session_cookie_age'

I have a Django project, everything goes well, but when I tried to handle the expiration of the session I got confused In a test view print(request.session.get_session_cookie_age()) give me this error SessionStore' object has no attribute get_session_cookie_age According to the …

20.12.2024
На какой бесплантый хостинг опубликовать сайт, сделанный да django?

Знает ли кто нибудь как полностью бесплатно опубликовать сайт на django через какой нибудь хостинг? Если да, то дайте ссылку на этот хостинг, и по возможности видео о нём, если таковое есть.

20.12.2024
Javascript fetch return 403 on Apache Server

Struggling with this issue for a few days now so any help is greatly appreciated. I managed to deploy my django project on a Linux server and it works fine apart from the model form submit. On the local development …

20.12.2024
Can i save changes in the value before redis key expires

I could not find better solution. I have IDs and ranks in my Redis. Is it possible for me to save the changed ranks to the database before the Redis key expires?. can I trigger some function before it expires …

20.12.2024
CVAT OpenID Connect login doesn't show on Login page

I am trying to set up CVAT to support login using a custom IdP with OpenID Connect. I tried to make changes to base.py and docker-compose.override.yml to configure the server, but once I build and launch CVAT, nothing happens. I …

20.12.2024
Access токен продолжает жить после выхода, drf

Генерирую токены, получаю refresh и access токены. Когда я по /logout передаю refresh токен, то он больше не действует, но access токены, полученные, с помощью этого рефреш токена, продолжает работать, до его срока истечения. Как избавиться от такого поведения, и …

20.12.2024
Django Rest Framework login failure

I'm trying to make DRF work without custom serializers, views and urls, just using the default ones, but there is an issue with my login. Whenever i create a user on /api/v1/auth/register (this happens successfully) and then try to log …

20.12.2024
How to use uv run with Django in a PyCharm Docker environment?

I am developing a Django application using a Docker environment in PyCharm. Until now, I have been using pip for package management, but I am considering using uv to potentially reduce container build times. I managed to install uv in …

19.12.2024
Что нужно знать о базе данных чтобы работать с фреймворком джанго?

Всем привет,кто-нибудь работает с Джанго? Что нужно знать о базе данных,Чтобы работать с этим фреймворком? Моя база данных- PostgreSQL

19.12.2024
Не работает utf-8 в web-терминале на python c flask

Простейший web-терминал, сам по себе он работает, но любая команда(например ping), вывод которой подразумевает кирилицу, првращается в кашу из символов, в чём может быть проблемма и как это можно пофиксить? …

19.12.2024
How to integrate a Stripe Terminal Reader to POS application using Django?

I am developing a POS system using Django. I have a Stripe account, and through the system I am developing, I can process payments using credit or debit cards, with the money being deposited into my Stripe account. This is …

19.12.2024
Django with S3Boto3Storage - After upload, bucket didn't change

I'm using these configuration: MEDIA_ROOT = os.path.join(BASE_DIR, 'media') DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' AWS_ACCESS_KEY_ID = '*****' AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY") AWS_STORAGE_BUCKET_NAME = '****' AWS_DEFAULT_ACL = 'public-read' AWS_S3_FILE_OVERWRITE = False AWS_S3_ENDPOINT_URL = 'https://****' AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } AWS_MEDIA_LOCATION = 'media' PUBLIC_MEDIA_LOCATION = …

19.12.2024
Django ConnectionResetError: [Errno 54] Connection reset by peer

I'm trying to setup a project to send email from my local machine(MacOS) using django. But I see this error File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ConnectionResetError: [Errno 54] Connection reset by peer This is code snippet that …

19.12.2024
Getting Server Error (500) when setting debug to false due to manifest not including css files

I have an app that I've built using Django and React + Vite. Everything runs fine with Debug set to True, but once I set it to false I get a Server Error with the console output of: ValueError: Missing …

19.12.2024
How can i solve? django - ValueError: ModelForm has no model class specified

I don't understand, what is the wrong. could you please let me know? which one do i need adjust? ValueError at /blog/15/ ModelForm has no model class specified. error messege picture which one do i need …

19.12.2024
How to extend a User's profile to save data in Django

I'm new to Django and I'm attempting to build a website where a user can view a DB of books and related authors and add any book to their 'favourites'. I've been searching lots and I can't find a satisfactory …

19.12.2024
Invalid_client when trying to authenticate with client_id and client_secret using django oauth toolkit and rest framework

I’m running a Django service that exposes endpoints via Django REST Framework. I want to secure these endpoints using Django OAuth Toolkit for authentication. When I create an application from the admin panel, I use the following settings: <a href="https://i.sstatic.net/Kh6elhGy.png" …

19.12.2024
Reverse ForeignKey orm django

Hi i am new to django orm , can some body help me i have data models in django . class userprofile(models.model): foreignkey User related_name='fU' class A(models.model) foreignkey userprofile related_name='fa' Class B(models.model): forign key A related_name=&quot;fb&quot; class C (models.model): foreignkey …

19.12.2024
Why does updating to psycopg 3.x cause database timeouts?

I have a Django 5.x app. I've been using psycopg2, and I'm now trying to update to psycopg 3. This is pretty simple: I uninstalled everything to do with psycopg2 and installed psycopg[binary]. However, when I run my test suite …

19.12.2024
RuntimeError: Model class modules.firebase-push-notifications.models.Notification doesn't declare an explicit app_label

Error RuntimeError: Model class modules.firebase-push-notifications.models.Notification doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS. for some reason i do not get this error when i try run manage.py runserver but if i use vscode debugger, this …

19.12.2024
Retrieve exect previous or next occurrence of a recurring event from Google Calendar

I have a recurring event in Google Calendar, and I need to fetch either the previous and next occurrence of this event, based on a given event ID. Specifically, I want to retrieve the event details for the exact occurrence …

19.12.2024
Django + ODBC Driver 17 for SQL Server: Raw query can't process list or tuple arguments

Code I wrote a function that wraps Django's standard processing for raw SQL queries. def run_mssql_query(query, connection=&quot;prod&quot;, args=None): &quot;&quot;&quot;Method will run query on MSSQL database Args: query (str): MSSQL Query connection (str): Which connection to use. Defaults to &quot;prod&quot;. Returns: …

19.12.2024
Using different table for authentication and simple jwt - Django rest framework

Im a bit new to Django REST and Django as a whole, how do you use a different table for auth since my api is looking for auth_user , it keeps saying &quot;[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid …

19.12.2024
Override the accounts/login/ in Django

So I'm using django.contrib.auth.urls and I would prefer to continue that. But I want the accounts/login url to be replaced with users/c-login or whatever. I would really like to understand why this is not working: my urls.py (project): from core …

19.12.2024
Sending serial port-data via websocket in Django framework

I need to visualize data on Django-based webserver; which data is captured on serial port, like a stream. I use python **serial ** package to listen on the serial port, and I store these data in DB. I also have …

18.12.2024
How to Automatically Detect PySpark Home Path from PyInstaller Executable?

In my local development environment, I can easily run a PySpark application without configuring anything. However, on the server, we are using PyInstaller for EXE deployment. PyInstaller does not include the PySpark libraries' _internal folder in the executable, so I …

18.12.2024
Race condition with django GET

I wrote a function in Django which looks roughly like this: @login_required def make_appointment(request): existing_appointments = Appointment.objects.all() print('existing_appointments = ', len(existing_appointments)) new_appointment = Appointment() new_appointment.save() # ... And I call this from javascript using the following code: for(i=0; i&lt;2; …

18.12.2024
Static file references differ on servers with same configuration

I'm using Django 5.1.3 for a project and the template references to the static files, despite being identical on three different servers, don't all point to the same relative location. The template tag {% static 'mystyle.css' %} is rendered in …

18.12.2024
QuotaGuard Heroku Django and Azure SQL DB

Import pandas as pd from PIL import Image from sqlalchemy import create_engine from sqlalchemy.pool import NullPool from dotenv import load_dotenv import socks import socket import os import io load_dotenv() CLIENT_ID = os.getenv(&quot;CLIENT_ID&quot;) TENANT_ID = os.getenv(&quot;TENANT_ID&quot;) CLIENT_SECRET = os.getenv(&quot;CLIENT_SECRET&quot;) DB_SERVER = …

18.12.2024
Classed Based Views : Why do URL parameters in Django/DRF go into `self.kwargs` instead of another attribute (e.g., `self.url_params`)?

While working with Django/Django Rest Framework, I noticed an inconsistency in how URL parameters are acccessed in class-based-views. Problem Description In Generic Class Based Views, I can access URL parameters in two different ways - depending on the …

18.12.2024
Cart in Django is not updating in frontend but working fine in database

I'm making an ecom site. When customer select Product size from dropdown boxes, it sends the correct selected size in backend but showing default value in frontend. My HTML code for this: &lt;select class=&quot;form-select form-select-sm&quot; id=&quot;size-cart{{ product.id }}&quot;&gt; {% for …

18.12.2024
There is problem in inegrate onlyoffice text editor in react and python django

Enter image description here see using docker i take onlyoffice container then create api and integrate in react during run the code document not open in text editor help me to solve these issue if not then …

18.12.2024
Поиск по сайту django

На главной странице отображается таблица со всеми протоколами, необходимо сделать поиск на сайте по Наименованию задачи (task_name) и должна выводится такая же таблица как и на главной, но с задачами, которые пытаются найти. Перепробовав разные способы, пересмотрев различные видео, у …

18.12.2024
AWS Instance EC2 - Ubuntu stops after sometime [closed]

I am new to AWS. I had my Python Django project setup to host on AWS using EC2 INSTANCE WITH UBUNTU. It works when i run the project. After a while, may be 5 minutes later, when the site or …

18.12.2024
Error 500 - Internal Server Error on Django on Production server

I’m facing an issue with my Django application running in production on CPanel, and I'm using Passenger for WSGI. The application works fine on the local machine but on the live server it only works the root route (/), but …