I'm getting the above error while executing the following method in my django rest framework project (Django==5.0.4, djangorestframework==3.16.1). def activate( self, subscription_date=None, mark_transaction_paid=True, no_multiple_subscription=False, del_multiple_subscription=False, ): if no_multiple_subscription: self.deactivate_previous_subscriptions(del_multiple_subscription=del_multiple_subscription) current_date = subscription_date or timezone.now() next_billing_date = self.plan_cost.next_billing_datetime(current_date) self.active = …
I am calling the LinkedIn organizationPageStatistics endpoint using the REST.li 2.0 API, but I keep getting a 400 PARAM_INVALID error related to the timeIntervals parameter. According to the official documentation (li-lms-2025-11), timeIntervals is an object, not a list. Error response …
Only Experts Can Answer this question. Which one is best for 2026 Python developers , Python Data science or Python Django? From both of these which one is easy to learn and high paid?
I am conducting an academic research study focused on comparing Code First (CF) and Database First (DBF) approaches in different ORMs. The goal of this survey is to collect objective, experience-based input from developers who have worked in real-world projects. …
Выдает такую вот ошибку, в чем дело? RuntimeWarning: Accessing the database during app initialization is discouraged. To fix this warning, avoid executing queries in AppConfig.ready() or when your app modules are imported. warnings.warn(self.APPS_NOT_READY_WARNING_MSG, category=RuntimeWarning) вот мой код в файле models.py: …
I'm implementing JWT authentication using Django REST Framework and djangorestframework-simplejwt in my project. I have an endpoint for updating a category. What I tried Verified that the JWT token is valid. Confirmed that the user is is_staff=True and …
While trying to create a custom QuerySet and a custom Manager for a django Model I stumbled upon the documentation sections 1 and 2 that use the manager's _db property and i would like …
I’m running a Django (ASGI) app on Heroku using Gunicorn with the Uvicorn worker to support WebSockets. Heroku has a hard 30-second request timeout. When a request exceeds 30 seconds, Heroku closes the connection as expected. Problem: Even after the …
I am implementing the Wright inbreeding coefficient (F) for individuals in a pigeon pedigree (Django application, relational database). The current implementation builds the pedigree using a breadth-first search (BFS) up to a fixed number of generations and computes F using …
I have done the guide and yet i still cannot get it to work correctly. These two screenshots are the closest i have come to success attempt1 attempt2 This is how …
I’m building a Django-based classifieds website. Previously, my search form populated districts and categories using database queries like: districts = ( AdPost.objects .filter(admin_verified=True) .values_list("district", flat=True) .distinct() ) To improve consistency and performance, I’ve now moved both district and category to …
I'd like to change background color for these headers for different color (not white): Like this: My models: from django.core.validators import MinValueValidator, MaxValueValidator from django.db import …
I have models: from django.db import models class Request(models.Model): class Method(models.TextChoices): POST = "POST", "POST" GET = "GET", "GET" PUT = "PUT", "PUT" DELETE = "DELETE", "DELETE" method = models.CharField( max_length=10, choices=Method, default=Method.GET, ) url = models.TextField() class Response(models.Model): request …
I am using django-tenants and created various aliases that all point to localhost. If the local development server is reachable via http://localhost:8000/ and I can login to the admin as expected. If I use e.g. http://other_url.local:8000/django-admin the …
I'm trying to add a row to my model, but it keeps coming back with: django.db.utils.ProgrammingError: relation "qmgr_def_rules" does not exist LINE 1: SELECT 1 AS "a" FROM "qmgr_def_rules" WHERE "qmgr_def_rules"... Some context: I have 3 different applications under …
In my django project admin I have an Order model. I display a bunch of information in the change page with the help of custom inlines. As I use a lot of related models, I want to …
Django's http response.py library provides an Http404 class that can be used to raise a "not found" exception which returns a 404 along with the following JSON payload: {"detail":"Not found."}. However there are no other HTTP error response classes that …
So I'm building a webhook functionality for a particular Django model, as in I trigger the webhooks for 2 events. One is for creation and one for modification, as in I wanna trigger them everytime an object of that model …
I'm somehow unable to make the field required, setting null and blank to True has no effect. # models.py from django.db import models class ExampleModel(models.Model): text_field = models.TextField() # tests.py from django.test import TestCase from .models import ExampleModel …
I am trying to handle multi-level menu with AlpineJS. Is it posible to insert single <ul> (or </li>) in the code below? <template x-if="item.has_children"> <!-- insert <ul> here--> </template> <template x-if="! item.has_children"> <!-- insert </li> here--> </template>
I’m encountering an issue when running Celery with PgBouncer and PostgreSQL after enabling idle connection timeouts. My stack includes: Django (served via Tornado) Celery (workers + beat) PostgreSQL PgBouncer (in front of PostgreSQL) Due …
Demo of the Project The Problem I am attempting to deploy a Django portfolio project to Render. While the project runs perfectly on my local machine using python manage.py runserver, the deployment fails during the build process. …
As a beginner web developer, I started my journey with HTML, PHP, and MySQL. I built only one real project, a school management system . One day, I saw someone working with React as a front-end developer. That moment really …
I'm trying to install OWASP PyGoat, and then create a secure version of it. I followed method 2 on the repository's site (https://github.com/adeyosemanputra/pygoat?tab=readme-ov-file#method-2), but running the "python3 manage.py migrate" command yielded the error message in this post's …
When building platforms with multiple Python services (FastAPI, Flask, Django, internal APIs), we kept facing the same issues: • Authentication duplicated across services • Roles and permissions drifting over time • Weak tenant isolation • No clear …
Here in settings.py I've added if os.environ.get("MOUNT_MEDIA"): MEDIA_ROOT = "/app/media" print("Using Railway mounted volume for MEDIA_ROOT") else: MEDIA_ROOT = BASE_DIR / "media" print("Using local folder for MEDIA_ROOT") MEDIA_URL = "/media/" in urls.py …
I want column foo (TextField 2500 chars) to have a width of 30% in admin view. Yet whatever I try, the columns widths remain equal (50% / 50%). td.foo {width: 30%;} has no effect at all. admin.py: class …
I want to change some css in static/admin/css/base.css After some attempts I now fail to understand the static-file concept at all. As a matter of fact I can delete the whole static directory without any effect/error …
So here's the issue. I am maintaining a somewhat large Django app and am tasked with creating a search bar that relies on elastic search data and need to in the near future convert a large number of Django DB …
I am trying to get the label attached to the relevant interger for the choice field. Although the API returns the interger, I cannot seem to be able to return the actual label value. This is the current return: [ …
These are my django models (only the FK s are written) class SellerBuyable(TimeStampMixin, GBSoftDeleteModel): seller = models.ForeignKey(Seller,related_name="seller_buyables",on_delete=models.CASCADE, null=True) buyable = models.ForeignKey(Buyable,on_delete=models.CASCADE,null=True,related_name="seller_buyables",related_query_name='seller_buyable') ... class CampaignItem(TimeStampMixin, GBSoftDeleteModel): campaign = models.ForeignKey(Campaign, related_name='items', on_delete=models.CASCADE) item = models.ForeignKey(SellerBuyable, on_delete=models.CASCADE, null=False) ... class Campaign(TimeStampMixin, …
I'm unable to mock timezone.now in the model's created field. The test fails due unmocked/current datetime. I tried patch('django.utils.timezone.now') to no avail. # app/models.py from django.utils import timezone class BaseModel(models.Model): created = models.DateTimeField(default=timezone.now, editable=False) class Meta: abstract = …
При создании и переименовании проекта ("Project") в админ-панели Джанго получается вместо простого "Заказ" - "('Заказ',)". Кнопка добавления ещё одного заказа так же обрамляется лишними скобками и кавычками + запятая ("Добавить ('Заказ',)"). Почему так происходит, учитывая, что в поле "Выберите Заказ …
I'm working on a website to track music practice and I'm trying to set up a query to show how many minutes you've spent with a certain instrument or song. I modeled this behavior using Khan Academy (to test the …
I'm recording voice via jquery then sending it to django view: views.py ... elif voice_value: #get voice voice_value = request.FILES.get('sound_file.wav') #read as bytes file_content_bytes = voice_value.read() #using pydub audio_bytes = file_content_bytes # Replace with your actual audio data audio_segment …
When I run python manage.py migrate I get this error: (venv) mac@MACs-MBP-2 backend % python manage.py migrate Traceback (most recent call last): File "/Users/mac/Documents/projects/community_app/backend/venv/lib/python3.11/site-packages/django/db/backends/base/base.py", line 279, in ensure_connection self.connect() File "/Users/mac/Documents/projects/community_app/backend/venv/lib/python3.11/site-packages/django/utils/asyncio.py", line 26, in inner return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File …
How to disable localization ONLY in Django admin (specifically /admin/jsi18n requests) while keeping it in the main site? I experiencing 503 errors on our production server due to a high volume of requests to the /admin/jsi18n endpoint when multiple …
I’m using Django + MySQL with django-allauth and Google OAuth. Login fails with this error: MultipleObjectsReturned: get() returned more than one SocialAccount The confusing part is that the database does not contain duplicates. Here is what I checked: 1. No …
Fairly new to django so there must be a lot I have no idea about. How can I assign user related permissions to user groups in a post migration signal? I have read everywhere that post migration signal can work …
I have a piece of code that sends a json to the server but form.onsubmit = async (e) => { e.preventDefault(); const formData = new FormData(form); const response = await fetch('api/get-comments/', { method: 'POST', body: formData }); if …