Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ajax request in django
I implemented the post like feature using ajax in the Django project, but it doesn't work. And it gives a 404 error in the console. template.html <script> $(document).ready(function(){ $(".line-button").click(function(){ var post_id = $(this).closest("post").data("post-id"); var button = $(button); $.ajax({ type: 'POST', url: 'like-post/', data: {'post_id': post_id, 'csrfmiddlewaretoken':'{{csrf_token}}'}, success: function(data){ if(data.liked){ button.text('unLike'); }else{ button.text('Like'); } $(".likes-count").text(data.post_likes_count); } }) }) }) </script> views.py @require_POST def like_post(request): post_id = request.POST.get("post_id") post = get_object_or_404(Post, id=post_id) if request.user in post.likes.all(): post.likes.remove(request.user) liked = False else: post.likes.add(request.user) liked = True post_likes_count = post.likes.count() response_data = { 'liked': liked, 'post_likes_count': post_likes_count } return JsonResponse(response_data) urls.py path('like-post/', views.like_post, name="like_post"), -
Python Django Rest Framework
what is the difference between decorator @api_view and @csrf_exempt in project level django rest framework? I need the difference and which is better to develop the project. -
Django Summernote: How to delete attachment files from server when removing them from admin?
When I delete a file from the Attachment model (which is provided by django-summernote), the record is removed from the database, but the actual file remains on the server. I want to make sure that whenever an attachment is deleted, its file is also removed from the filesystem. -
MySQL DB Optimization
I am working on a table where compared data of colleges have been stored. But facing difficulty to query data in low response time. I am creating an API to get some analytics data within 300ms but a simple query on this table takes more than 1-2 sec. I am thinking of re-design the table or create another table in different format. Tried multiple ways but couldn't find the right solution. Tech stack - MySql, Django, DRF Table name - compared_college. Columns - id, college_1, course_1, college_2, course_2, college_3, course_3, college_4, course_4 So basically each college has a course which are compared. Max 4 college-course combination can be compared at once and there entry goes into this table. Each course is mapped to a college and a domain and level. But a college can b mapped to multiple course. Master Tables and column- College - id, name, published Course - id, name, published, domain, level Now compared_collge has more than 40lakh rows. I want some analytics data - Top 10 most compared colleges based on domain or level or without domain-level filter. Top 10 most compared combination of college (pair) based on domain or level or without filter. Top 10 … -
Tailwind CSS is overriding static css in Django
The problem I am having is whenever I try to use tailwind and css (as static), the tailwind overrides the static css file. I tried moving tailwind invokation tags after, before static css invokation, but it didn't work. Whenever I remove tailwind from my template, the static css starts working. How can I use both ? I need to use css file to change properties in django forms. HTML- {% load tailwind_tags %} {% tailwind_css %} <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>{% block title %} {% endblock %}</title> {% load static %} <link rel="stylesheet" href="{% static 'base.css' %}"> </head> <body> <div class="bodydiv"> {% block body %} {% endblock %} </div> </body> </html> CSS- body{ background-color: aqua; } settings.py- """ Django settings for tweeterproject project. Generated by 'django-admin startproject' using Django 5.1.2. For more information on this file, see https://docs.djangoproject.com/en/5.1/topics/settings/ For the full list of settings and their values, see https://docs.djangoproject.com/en/5.1/ref/settings/ """ from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/5.1/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = 'django-insecure-9piqti35i-q&85=cebmg*td+g=ut#f$k+t0cttav^_sb8izu-)' … -
Django + allauth email first authentication
I have a django rest api app where I want to setup a custom authentication flow. Here is how I want it to work. Sign Up User enters email User gets email verification code User enters verification code User adds a password User selects a username and a display name User selects a plan User enters billing information (may not be necessary if they choose a free plan) User is now fully logged in! Login User enters email (if account doesnt exist or is not past step 4 of signup transfers to step 2 of signup) User enters password (only works if past step 4) User is routed to step 5-8 of signup if they are not completed User logs in Social Signup I want this to essentially bypass signup steps 1-4 and link a social account. It seems allauth requires you to signup with a password, and I cannot figure out how to get this flow to work. I am also wondering the correct way to implement this. I was thinking about using another module thats not allauth, however most other modules do not have support for other social apps. How should I go about implementing this? -
How do I use Django for another project?
I am trying to start a project using Django. I used Django once, and now I would like to use it again, but this time in a different folder. I keep getting stuck in the terminal trying to execute the commands to install Django. This is what I keep on seeing. $ pip install pipenv Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: pipenv in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (2025.0.3) Requirement already satisfied: certifi in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (from pipenv) (2025.6.15) Requirement already satisfied: packaging>=22 in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (from pipenv) (25.0) Requirement already satisfied: setuptools>=67 in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (from pipenv) (80.9.0) Requirement already satisfied: virtualenv>=20.24.2 in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (from pipenv) (20.31.2) Requirement already satisfied: distlib<1,>=0.3.7 in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (from virtualenv>=20.24.2->pipenv) (0.3.9) Requirement already satisfied: filelock<4,>=3.12.2 in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (from virtualenv>=20.24.2->pipenv) (3.18.0) Requirement already satisfied: platformdirs<5,>=3.9.1 in c:\users\shawonne shann\appdata\roaming\python\python313\site-packages (from virtualenv>=20.24.2->pipenv) (4.3.8) Shawonne Shann@Latitude-E5450 MINGW64 /c/codingprojects/selfpace/selfpacefolder $ pipenv install django bash: pipenv: command not found What should I do -
How to persist multi-step form data between views in Django without committing to DB?
One-line project/context. Short description of the problem and constraints. Minimal code: models, the two views, form classes, snippets of urls.py. Exact observed behavior or error. Alternatives tried (session, temp model) and why they’re insufficient. Ask: “Given X and Y, which approach best ensures Z, and how to implement it? -
iOS/web Auth Client ID Handling for Google Sign In
To preface, I'm not asking for a direct fix here, I'm just curious if what I'm doing is the appropriate auth flow for setting dynamic client ID based on device platform. I am 2 applications that use the same Django Allauth backend. One of them is for web, and the other is in Flutter (iOS). Both applications would call an endpoint that routes to GoogleDirectLogin(APIView) note that the implementation I currently have a method get_client_id that dynamically use the appropriate client ID based on device type (X-Client-Type) class GoogleDirectLogin(APIView): permission_classes = [AllowAny] def post(self, request): # Get token from request token = request.data.get('id_token') or request.data.get('access_token') if not token: return Response( {'error': 'Missing token in request'}, status=status.HTTP_400_BAD_REQUEST ) # importing middleware is crucial for checking multiple client ID based on JSON Header value from auth_backend.middleware import get_client_id # Import from middleware client_id = get_client_id(request) print(f"using client ID: {client_id}") try: # Verify Google token identity_data = id_token.verify_oauth2_token( token, google_requests.Request(), client_id, clock_skew_in_seconds=10 ) # Validate issuer if identity_data.get('iss') not in ['accounts.google.com', 'https://accounts.google.com']: return Response( {'error': 'Invalid token issuer'}, status=status.HTTP_400_BAD_REQUEST ) # # Exchange token with your internal API response = requests.post( settings.INTERNAL_API_CALL_GOOGLE, json={'access_token': token} ) response.raise_for_status() auth_data = response.json() return Response({ 'access': auth_data['access'], … -
Flaky Circle CI tests (django): ImportError: cannot import name "task" from "app.tasks" (unknown location)
Sometimes, I have many flaky test failures due to one error: ImportError: cannot import name 'task_import_events_to_db' from 'app.tasks' (unknown location) It seems the tests fail because of this import error. Meanwhile, other branches pass without issues, and tests also pass normally after merging. App is in INSTALLED APPS, locally everything works. But not on circle ci Stack: Django, PostgreSQL, Redis -
KeyError 'email' for django-authtools UserCreationForm
I am experiencing an error for which I can’t find an origin. I believe the error stems from GitHub - fusionbox/django-authtools: A custom User model for everybody!, and disclaimer, I have asked this same question on the project’s GitHub repository over a year ago, but nobody has answered, hopefully someone may have some insights here. Every now and then Django complains that email is not in self.fields[User.USERNAME_FIELD], when I try to open the admin 'Add user' form, see below I can see that email isn’t in self.fields but why it isn’t is not clear to me. What absolutely confuses me is that the error is sporadic: If I experience the error in my main browser window, I don’t in a new Incognito window Restarting the app makes the error go away, for some time, but then it reappears, and the only way to solve it is to restart the app. My UserCreationForm, a child of authtools’s UserCreationForm, looks like this class UserCreationForm(UserCreationForm): """ A UserCreationForm with optional password inputs. """ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["password1"].required = False self.fields["password2"].required = False # If one field gets autocompleted but not the other, our 'neither # password or both password' validation … -
Django check at runtime if code is executed under "runserver command" or not
I've a project based on django that wrap some custom code, this code during import load some heavy file before to be executed. I need to check if imports are executed under "runserver command" or not, in this way I can prevent loading heavy files during django installation. How can i check if code is executed under runserver command -
Django REST project doesn’t detect apps inside the “apps” directory when running makemigrations
I have a Django REST project where I created a directory called apps to store all my apps. Each app is added to the INSTALLED_APPS list in my settings file like this: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', # APPS 'apps.accounts.apps.AccountsConfig', 'apps.ads.apps.AdsConfig', ] But when I run python manage.py makemigrations, Django doesn’t detect any changes — it seems like it doesn’t recognize my apps at all. Can anyone help me figure out what might be wrong? Thanks a lot -
Cannot query "admin": Must be "ChatMessage" instance in Django
In View Function it can show this error Request Method:GETRequest URL:http://127.0.0.1:8000/inbox/Django Version:4.2.25Exception Type:ValueErrorException Value:Cannot query "admin": Must be "ChatMessage" instance.Exception Location:D:\Socialmedia\.venv\lib\site-packages\django\db\models\sql\query.py, line 1253, in check_query_object_typeRaised during:core.views.messages.inboxPython Executable:D:\Socialmedia\.venv\Scripts\python.exePython Version:3.9.13Python Path:['D:\\Socialmedia', 'C:\\Users\\ER-RPJ\\AppData\\Local\\Programs\\Python\\Python39\\python39.zip', 'C:\\Users\\ER-RPJ\\AppData\\Local\\Programs\\Python\\Python39\\DLLs', 'C:\\Users\\ER-RPJ\\AppData\\Local\\Programs\\Python\\Python39\\lib', 'C:\\Users\\ER-RPJ\\AppData\\Local\\Programs\\Python\\Python39', 'D:\\Socialmedia\\.venv', 'D:\\Socialmedia\\.venv\\lib\\site-packages'] def inbox(request): if request.user.is_authenticated: user_id = request.user chat_messages = ChatMessage.objects.filter( id__in=Subquery( User.objects.filter( Q(chat_sender__chat_receiver=user_id) | Q(chat_receiver__chat_sender=user_id) ).distinct().annotate( last_msg=Subquery( ChatMessage.objects.filter( Q(sender=OuterRef('id'), receiver=user_id) | Q(receiver=OuterRef('id'), sender=user_id) ).order_by('-id')[:1].values_list('id', flat=True) ) ).values_list('last_msg', flat=True).order_by('-id') ) ).order_by('-id') context = { 'chat_messages': chat_messages, } return render(request, 'chat/inbox.html', context) In My model class ChatMessage(models.Model): user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name='chat_user') chat_sender = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name='chat_sender') chat_receiver = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True, related_name='chat_receiver') message = models.TextField() is_read = models.BooleanField(default=False) date = models.DateTimeField(auto_now_add=True) mid=ShortUUIDField(length=7,max_length=25,alphabet='abcdefghijklmnopqrstuvwxyz') # def __str__(self): # return self.user class Meta: verbose_name_plural = 'Chat messages' -
Is it reasonable to use Cloud storage for async webhook processing on Cloud Run
I'm processing webhooks on Cloud Run (Django) that need async handling because processing takes 30+ seconds but the webhook provider times out at 30s. Since Cloud Run is stateless and spins up per-request (no persistent background workers like Celery), I'm using this pattern: # 1. Webhook endpoint def receive_webhook(request): blob_name = f"webhooks/{uuid.uuid4()}.json" bucket.blob(blob_name).upload_from_string(json.dumps(request.data)) webhook = WebhookPayload.objects.create(gcs_path=blob_name) create_cloud_task(payload_id=webhook.id) return Response(status=200) # Fast response And then our cloud task calls the following endpoint with the unique path to the cloud storage url passed from the original webhook endpoint: def process_webhook(request): webhook = WebhookPayload.objects.get(id=request.data['payload_id']) payload = json.loads(bucket.blob(webhook.gcs_path).download_as_text()) process_data(payload) # 30+ seconds bucket.blob(webhook.gcs_path).delete() My main query points: Is GCS + Cloud Tasks the right pattern for Cloud Run's model, or is storing JSON directly temporarily in a django model a better approach since Cloud Tasks handles the queueing? Should I be using Pub/Sub instead? My understanding is that pubsub would be more appropriate for broadcasting to numerous subscribers, currently I only have the one django monolith. Thanks for any advice that comes my way. -
Django ORM: Add integer days to a DateField to annotate next_service and filter it (PostgreSQL)
I am trying to annotate a queryset with next_service = last_service + verification_periodicity_in_days and then filter by that date. I am on Django 5.2.6 with PostgreSQL. last_service is a DateField. verification_periodicity lives on a related SubCategory and is the number of days (integer). Models (minimal): # main/models.py class Category(models.Model): name = models.CharField(max_length=100) class SubCategory(models.Model): category = models.ForeignKey(Category, on_delete=models.CASCADE, related_name='subcategories') name = models.CharField(max_length=100) verification_periodicity = models.IntegerField() # days class Asset(models.Model): sub_category = models.ForeignKey(SubCategory, on_delete=models.PROTECT) last_service = models.DateField(null=True, blank=True) Goal: Compute next_service = last_service + verification_periodicity days in the database, expose it in the API, and support filtering like ?next_date__gte=2025-12-06. What I tried: Simple cast and multiply: from django.db.models import ExpressionWrapper, F, DateField, IntegerField from django.db.models.functions import Cast qs = qs.annotate( next_service = ExpressionWrapper( F('last_service') + Cast(F('sub_category__verification_periodicity'), IntegerField()) * 1, output_field=DateField() ) ) This does not shift by days and later caused type issues. Filtering by the annotated date also did not work as expected. Using a Python timedelta: from datetime import timedelta qs = qs.annotate( next_service = F('last_service') + timedelta(days=1) * F('sub_category__verification_periodicity') ) This produced a duration in seconds in the serialized output. Example: "next_service": "86400.0" for one day, rather than a proper date. I need a date. Errors seen along … -
Stuck with django asgi server (dpahne) and aws eb (with docker)
I’m trying to deploy a Django application that uses Channels + ASGI + Daphne on AWS Elastic Beanstalk with the Docker platform. My container builds successfully, migrations run, and Daphne starts properly on 0.0.0.0:8000. Logs show the ASGI server is running without errors. The issue is that Elastic Beanstalk is not routing traffic to the Daphne server inside the Docker container. Here’s what’s happening: docker logs shows Daphne listening on 0.0.0.0:8000 The container starts cleanly (no errors) curl <container-ip>:8000/ works curl http://localhost/ on the host does not reach Daphne /health/ returns nothing because Django had no route (fixed now) Elastic Beanstalk environment loads but the site doesn’t respond externally It seems like NGINX inside EB is not proxying requests to the container I think I need a correct NGINX proxy config or a proper EB .config file that routes traffic to the container’s internal IP/port. Can someone provide a working example of: ✅ Dockerfile ✅ entrypoint.sh ✅ EB .ebextensions config for ASGI/Daphne ✅ NGINX proxy config for forwarding WebSocket + HTTP traffic ✅ Any extra EB settings needed for Channels Basically, I need the correct setup so EB can forward all traffic to Daphne inside a Docker container. Any working … -
unable to access my EC2 ubuntu server with public ip:8000 [closed]
I associated public elastic ip address to my EC2 instance , Installed Virtual environment properly, python manage.py runserver 0.0.0.0:8000 is executed properly Postgresql is connected at port 5432 properly. Port 22, 80, 443 firewall are allowed properly here is the security group screen shot attached here are outbound rules when I run the sudo ufw status verbose I get the following it indicates my all needed ports are properly attached my routing tables , Network ACL are also set properly but when I try to access my server I get following errors. -
Django Not Saving Form Data
I fill the Django form in contact.html file. But form data is not saved in database or another place. There is no error or warning while saving the form data. Form screenshot: Form screenshot. views.py: from .forms import CnForm def contact(request): template = loader.get_template('contact.html') form = CnForm(request.POST or None) if form.is_valid(): form.save() context = {'form': form } return HttpResponse(template.render(context, request)) models.py: from django.db import models class FModel(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) def __str__(self): return self.first_name forms.py: from django import forms from .models import FModel class CnForm(forms.ModelForm): class Meta: model = FModel fields = "__all__" contact.html: <div class="contact-container"> <form action = "" method = "post"> {% csrf_token %} {{ form }} <input type="submit" value="Submit"> </form> </div> -
403 Forbidden: "CSRF Failed: CSRF token missing." on DRF api-token-auth/ after applying csrf_exempt
I'm encountering a persistent 403 Forbidden error with the detail: CSRF Failed: CSRF token missing. This happens when trying to obtain an authentication token using Django REST Framework's built-in api-token-auth/ endpoint. Context I am sending a POST request from Postman (using raw and application/json for the body). The CSRF protection is interfering because Postman, as an external client, doesn't handle session cookies or CSRF tokens. I attempted to fix this by explicitly applying the @csrf_exempt decorator to the view in my urls.py, but the error remains. Configuration and Code Here are the relevant snippets from my project setup: 1. settings.py (Middleware and DRF Authentication) My middleware includes CSRF protection, and I have SessionAuthentication enabled, which seems to be causing the conflict. MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", ] REST_FRAMEWORK = { 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'PAGE_SIZE': 10, 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.TokenAuthentication', 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ( 'rest_framework.permissions.IsAuthenticated', ), } 2. urls.py (Where csrf_exempt is applied) This is how I'm currently trying to exempt the view. I have imported csrf_exempt from django.views.decorators.csrf. from django.contrib import admin from django.urls import path,include from rest_framework.authtoken import views from django.views.decorators.csrf import csrf_exempt from api import views as api_views urlpatterns = [ path("home/",include("expenses.urls")), path("admin/", admin.site.urls), path("api/",include("api.urls")), … -
'django.db.utils.ProgrammingError: relation "users_user" does not exist' error while running ' python manage.py migrate_schemas --shared'
AccrediDoc - Multi-tenant Accreditation Management System A comprehensive Django-based multi-tenant accreditation management system designed for healthcare organizations in India. Manage NABL, NABH, ISO 15189 and other healthcare accreditations with ease. Features Multi-tenant Architecture: Secure, isolated environments for multiple organizations Document Management: Upload, version, and track accreditation documents with expiry alerts Compliance Tracking: Monitor compliance status with interactive checklists and evidence tracking User Management: Role-based access control with different user roles Accreditation Types: Support for multiple accreditation standards and clauses Reporting: Generate comprehensive compliance and performance reports Audit Logging: Complete audit trail for all system activitieswhile running migration for sharred schema i got following error it is multitenant Django app with five different apps System check identified some issues: WARNINGS: ?: (staticfiles.W004) The directory 'D:\workik_projects\AccrediDoc_V3\static' in the STATICFILES_DIRS setting does not exist. [standard:public] === Starting migration [standard:public] System check identified some issues: WARNINGS: ?: (staticfiles.W004) The directory 'D:\workik_projects\AccrediDoc_V3\static' in the STATICFILES_DIRS setting does not exist. [standard:public] Operations to perform: [standard:public] Apply all migrations: admin, auth, contenttypes, django_celery_beat, sessions [standard:public] Running migrations: [standard:public] Applying admin.0001_initial... Traceback (most recent call last): File "D:\workik_projects\AccrediDoc_V3\acc_venv\lib\site-packages\django\db\backends\utils.py", line 103, in _execute return self.cursor.execute(sql) psycopg2.errors.UndefinedTable: relation "users_user" does not exist The above exception was the direct cause of … -
Django: Annotate queryset based on the existence of many-to-many relationships
I am using Django 5.2 with Postgres 17 and try to modify the queryset of a ListView for row-based access control. Items are to be included in the queryset either if the user is part of a project that is directly related with the item, or if the project that is related with the item is set to be "visible". The user is presented with different information and interaction possibilities in the front end depending which of the two options ("accessible" vs "visible") was true. The following solution in theory yields the right result: def get_queryset(self): queryset = self.model.objects.all() if self.request.user.is_superuser: return queryset.annotate(accessible=Value(True)) # Cache all projects that the user is part of. A project is a Django-group # (one-to-one relationship) with some additional attributes. user_projects = Project.objects.filter(group__in=self.request.user.groups.all()) # Get all items that the user can access and mark them accordingly. accessible_items = ( queryset .filter(groups__project__in=user_projects) .annotate(accessible=Value(True)) ) # Get all items that the user can see (but not access), and mark them accordingly. visible_items = ( queryset .filter(groups__project__in=Project.objects.filter(visible=True)) .exclude(groups__project__in=user_projects) .annotate(accessible=Value(False)) ) return accessible_items.union(visible_items) The approach is simple enough and I'm not too concerned about efficiency, but there is a significant drawback. I'm using a union of two querysets, and … -
Django views spawn the error "cleansed = [self.cleanse_setting("", v) for v in value]" and go in infinite loops
I have two views that spawn these messages in "sudo systemctl status gunicorn": gunicorn: Nov 07 10:46:36 mysite gunicorn[2107]: cleansed = [self.cleanse_setting("", v) for v in value] Nov 07 10:46:36 mysite gunicorn[2107]: File "/home/mysite/anaconda3/envs/mysite/lib/python3.10/site-packages/django/views/debug.py", line 135, in cleanse_setting The whole site works, but any view.py that accesses a certain class spawn these errors. The views were totally working with no problem. I added 4 fields to the class's 'models.py' then removed them and migrated the database with: python manage.py makemigrations python manage.py migrate after that, the error started to show. Any help would be appreciated. -
appAccountToken not sent to backend during Apple coupon (reward) redemption using StoreKit 2
I'm integrating Apple In-App Purchases with StoreKit 2 in an iOS app. The backend (Django) handles subscription verification and links each transaction to a user using appAccountToken. Everything works fine for normal subscription purchases — the app sets the appAccountToken correctly, and it reaches the backend through the transaction data. However, during coupon / reward redemption (using Apple’s Reward Redemption Sheet), the appAccountToken is not included in the transaction payload that Apple sends to the backend. As a result, my backend can’t associate the redeemed subscription with the correct user account. How can we ensure that the appAccountToken is included (or reattached) during reward / coupon redemption using StoreKit 2? Is there any recommended way to set or restore the appAccountToken during the reward redemption flow? -
Upgrading Django to 5.2.7 causing error wth rest_framework_simplejwt as django.utils.timezone is depreciated
I am upgrading my Django project to v5.2.7. After installing requirements.txt with the upgraded versions of all libraries, I ran the command to validate the code python manage.py check But it is throwing error ImportError: Could not import 'rest_framework_simplejwt.authentication.JWTAuthentication' for API setting 'DEFAULT_AUTHENTICATION_CLASSES'. ImportError: cannot import name 'utc' from 'django.utils.timezone' (...\envs\localenv\Lib\site-packages\django\utils\timezone.py). Requirements.txt asgiref==3.8.1 certifi==2023.11.17 Django==5.2.7 django-cors-headers==4.3.1 djangorestframework==3.14.0 mysqlclient==2.2.0 PyJWT==2.8.0 pytz==2023.3 newrelic==9.0.0 djangorestframework_simplejwt==5.2.0 sqlparse==0.4.4