Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Search query when the search sentence is less than characters
Good afternoon. A question. How can such a search be implemented in Django ORM(or SQL query) There is an arbitrary table with the field name "description". There is one entry, and the value of the field "description" is python. How to formulate a database search query to get this record if the incoming sentence looks like this: python-is a great programming-language. Thank you. Requests of the form ` Entry.objects.get(headline__icontains="Lennon") are not suitable because there are fewer characters in the searched sentence -
Styles in css file not showing on html template
css not linking in django iam trying to create an ecommerce website for my project and made a css file and linked it to the base template. But those results are not to be seen. settings.py STATIC_URL = "static/" STATICFILES_DIRS = [ os.path.join(BASE_DIR,"static"),] Base template css linking <link rel="stylesheet" type="text/csss" href="{% static '/css/custom.css' %}"> CSS body{font-family: 'Roboto', sans-serif; background-color:#D3D3D3; } .text-center{ font-family:roboto; } .card-title{ font-weight:bold; font-family:'Roboto', sans-serif; } /*footer*/ .foot{ background-color:blue; position:fixed; bottom:0; left:0; height:10px; width:100%; } h2{ font-family:'roboto',sans-serif; } /*cart-icons*/ .custom_icon{ margin:7px; font-size:20px; color:blue; } /*invoice*/ .inv{ display:block; } urls.py from django.urls import path from cart import views app_name='cart' urlpatterns=[ path('cart_view',views.cart_view,name='cart_view'), path('add_cart/<int:p>',views.add_cart,name='add_cart'), path('add_cart/<int:p>',views.add_cart,name='add_cart'), path('minus/<int:p>',views.minus,name='minus'), path('delete/<int:p>',views.delete,name='delete'), path('order',views.order,name='order'), path('invoice',views.invoice,name='invoice'), ] I linked the css to base template, but not seeing any results, inline styling is working though. project structure -
Get value of a field from a foreigKey in Django Models
I have two classes in my Database in Django class Test(models.Model): sequenzaTest = models.ForeignKey("SequenzaMovimento", null=True, on_delete=models.SET_NULL) class SequenzaMovimento(models.Model): nomeSequenza = models.CharField(max_length=50, blank=False, null=False) serieDiMovimenti = models.TextField(blank=False, null=False, default="") Now, every Test object created can be associated with just one SequenzaMovimento object. Different Test objects can have the same SequenzaMovimento Now, I know the primary key of my Test. How do I find the serieDiMovimenti inside the SequenzaMovimento object which is linked to the Test object? I can get the sequenzaTest from the Test object with testo_sequenza = Test.objects.get(pk=idObj) testo_sequenza.sequenzaTest but I can't find to understand how access serieDiMovimenti -
Access json field's dict value which is inside list using queryset
I have django model named Blog with fields title, data class Blog(models.Model): title = models.CharField(max_length=100) data = models.JSONField(default=dict) I have about ten of instances with data field value like Instance 1 [ { "name": "random" } ] Instance 2 [ { "name": "fact" } ] Instance 3 [ { "name": "fact" } ] Instance 1 [ { "name": "random" } ] Instance 1 [ { "name": "random" } ] And I am trying to sort the the blogs based on data field name key is used, and show it like random, 3 fact, 2 and I am intending it to do it more efficiently with database functions. top_used_names = Blog.objects.annotate( name=RawSQL("REGEXP_REPLACE("data", '^.\*\\"name\\": \\"(.\*?)\\".\*$', '\\\\1')", params=\[\]) ).values('name').annotate( count=Count('name') ).order_by('-count')\[:5\] but It showed me errors. then I tried using top_used_names = Blog.objects.annotate( name=Cast(KeyTextTransform("name", "data"), output_field=TextField()) ).values("name") it also showed me errors. I have spent hours but it is still showing the error Any help would be much Appreicated. -
Dynamic django inline_formset using pure javascript
I was searching on working examples for django inline_formset with javascript and found this post Add a dynamic form to a django formset using javascript in a right way. In the process, I tried to convert the Jquery portion into pure javascript? I have tried const btnAddMoreImg = document.querySelector('#add-image-button'); btnAddMoreImg.addEventListener('click', (evt) => { evt.preventDefault(); let count = document.querySelector('#item-images').children.length; let tmplMarkup = document.querySelector('#images-template').innerHTML; let compiledTmpl = tmplMarkup.replace(/__prefix__/g, count); $('#item-images').append(compiledTmpl); // how to convert this to pure javascript? // update form count document.querySelector('#id_images-TOTAL_FORMS').setAttribute('value', count + 1); }) This works but there is still this jquery code $('#item-images').append(compiledTmpl) which I tried to change to document.querySelector('#item-images').append(compiledTmpl), but the end result would be a string of html tags instead of a new form added. -
Django - INTEGRITY ERROR on column that no longer exists
I am getting this error: IntegrityError at /register/ null value in column "total_daily_mission_progress" violates not-null constraint DETAIL: Failing row contains (363, 0, 374, free, 0, null, unranked, 0, , odifj@gmail.com, 0, f, [], 0, {}, {}, t, null, null, null, null, null, {}, null, null, No phone number set, This user has not set a description yet., /static/images/profilepictures/defaultavatar.png, {}, {}, {}, {}, {}, 0). However, the column total_daily_mission_progress no longer exists in my UserDetail model. I deleted it a while ago and migrated. However, this issue comes up every time I try to create a new UserDetail model. Why is this occuring? I don't have the total_daily_mission_progress anywhere in my code. And how can I fix it? EDIT: Here is my output after running python3 manage.py showmigrations --verbosity 2 [X] 0001_initial (applied at 2022-12-29 19:39:10) [X] 0002_logentry_remove_auto_add (applied at 2022-12-29 19:39:10) [X] 0003_logentry_add_action_flag_choices (applied at 2022-12-29 19:39:10) auth [X] 0001_initial (applied at 2022-12-29 19:39:09) [X] 0002_alter_permission_name_max_length (applied at 2022-12-29 19:39:11) [X] 0003_alter_user_email_max_length (applied at 2022-12-29 19:39:11) [X] 0004_alter_user_username_opts (applied at 2022-12-29 19:39:11) [X] 0005_alter_user_last_login_null (applied at 2022-12-29 19:39:12) [X] 0006_require_contenttypes_0002 (applied at 2022-12-29 19:39:12) [X] 0007_alter_validators_add_error_messages (applied at 2022-12-29 19:39:12) [X] 0008_alter_user_username_max_length (applied at 2022-12-29 19:39:12) [X] 0009_alter_user_last_name_max_length (applied at … -
Django Application not getting registered in admin site
I have created new application in Django project but it is not showing in admin page . I have updated the admin.py file as well I am looking for solution to get my app registered in admin page . I have tried everything I could find in google . admin.py file from django.contrib import admin # Register your models here. from .models import * admin.site.register(packagedrop) Modle class packagedrop(models.Model): pkgID = models.AutoField(primary_key=True) envname = models.CharField(max_length=64) CreatedDate = models.DateField(auto_now_add=True) product = models.CharField(max_length=64) prodhier = models.CharField( max_length=25) prodversion = models.CharField( max_length=40) initiator = models.CharField(max_length=100) Description = models.TextField(max_length=200) Status = models.CharField(max_length=100, default='Submitted' ) updated_time = models.DateTimeField(auto_now_add=True) -
Deploying Django Web App with GPU-Intensive Deep Learning Models?
What is the recommended approach for deploying my Django web application that includes multiple components (database, views, authentication) alongside GPU-intensive Deep learning models (e.g., deezer/spleeter and pyannote/speaker-diarization)? Should I deploy everything on a single server with a powerful GPU, or is it better to separate the deep learning models and deploy them on a dedicated server with a powerful GPU while deploying the web application on a traditional server (e.g., DigitalOcean, Heroku) within a Docker container, and then call the models from the web app? Please give me recommandations about the bests (cheapest) GPU servers providers. -
django: allow allowed_hosts to work with debug = True also
I have a requirement that my django app ALLOWED_HOSTS=["somedomain.com"] work when DEBUG=True Because it only works for DEBUG=False Can anyone suggest how to achieve this. -
Why django-social-auth in djoser don't find client_id in authorization_url if client_id is provided
Why django-social-auth in djoser don't find client_id in authorization_url if client_id is provided I trying authenticate user with djoser + django-social-auth(front: Vue, back: django). When I request to http://127.0.0.1:8000/auth/o/google-oauth2?redirect_uri=http://localhost:8080, url response with client_id=None in authorization_url. Here are my settings and response. AUTHENTICATION_BACKENDS = [ 'fapp.auth_backend.AuthWithEmailAndPasswordOnly', 'social_core.backends.google.GoogleOAuth2', ] DJOSER = { 'PASSWORD_RESET_CONFIRM_URL': '#/password/reset/confirm/{uid}/{token}', 'USERNAME_RESET_CONFIRM_URL': '#/username/reset/confirm/{uid}/{token}', 'ACTIVATION_URL': '#/activate/{uid}/{token}', 'SOCIAL_AUTH_ALLOWED_REDIRECT_URIS': [ 'http://localhost:8080', 'http://localhost:8000' ], 'SOCIAL_AUTH_GOOGLE_OAUTH2_CLIENT_ID': '***' } And response "authorization_url": "https://accounts.google.com/o/oauth2/auth?client_id=None&redirect_uri=http://localhost:8080&state=dpcVJ92tDbxvxMvmn4m3wiCOTw5b0Pcx&response_type=code&scope=openid+email+profile" After this response I tried go to authorization_url with changed client_id to SOCIAL_AUTH_GOOGLE_OAUTH2_CLIENT_ID and it's work fine. -
How to filter data on many to many fields and apply ANY and OR operators in Django
I have 3 Models defined in my code Day, AllocationType and EmployeeAllocation. I am trying to solve a problem for following scenarios. Scenario 1: If person A is allocated to project P1 from 01-06-2023 to 30-06-2023 for dyas M,T,W,T,F. If end user try to allocate person A in that date period or days then end user should get a validation error. Person A is allocated. Scenario 2 If person B is allocated to project P2 from 01-06-2023 to 30-06-2023 for days M,W,F. If end user try to allocated person B than end user should able to allocated Person B between 01-06-2023 and 30-06-2023 for days T,T. I am novice in Django and not able to figure out how to write a condition for checking above scenarios. Model Definitions class Day(models.Model): Name = models.CharField(max_length=10) def __str__(self): return self.Name class AllocationType(models.Model): Name = models.CharField(max_length = 100) ColorCode = models.CharField(max_length = 50) def __str__(self): return self.Name class EmployeeAllocation(models.Model): Employee= models.ForeignKey(Employee, null=False, on_delete= MY_PROTECT, related_name='employee_allocation') Project= models.ForeignKey(Project, null=False, on_delete=MY_PROTECT, related_name='employe_allocation_project') AllocationType = models.ForeignKey(AllocationType, null=False, on_delete=MY_PROTECT, related_name="employee_allocation_type") StartDate = models.DateField() EndDate = models.DateField() Days = models.ManyToManyField(Day, null=False, blank=False, related_name='emoloyee_allocation_day') Comments = models.CharField(max_length=200, null=True, blank=True) def get_absolute_url(self): return reverse('employee-allocation-list') def __str__(self): return self.Employee.FirstName -
How to filter Django ManyToManyField by Id
I have two models: class Category(models.Model): name = models.CharField(max_length=255) class Company(models.Model): name = models.CharField(max_length=255) category = models.ManyToManyField(Category, related_name='companies') products = models.TextField() bulletpoints = models.TextField() website = models.CharField(max_length=750) articles = models.TextField() Now I want to filter the Objects in the Company model by the id of the categories, which I put them in. I tried several options including everything from that question: https://stackoverflow.com/questions/2218327/django-manytomany-filter for example: Company.objects.filter(companies__in=[category_id]) Company.objects.filter(companies__id=category_id) Company.objects.filter(category_id=category_id) Company.objects.filter(companies__id__in=category_id) -
Prefetch and merge two reverse foreign key of same model in queryset
I have a problem, maybe somone has a solution for me. I have two models: class Task(models.Model): class Meta: db_table = "task" class Rule(models.Model): to_task = models.ForeingKey(Task, related_name="to_task_rules") from_task = models.ForeignKey(Task, related_name="from_task_rules") class Meta: db_table = "rule" I want to loop into tasks and display all concerned distinct rules by current task by prefetching to_task_rules and from_task_rules in a field task_rules, but without success Django does not seems to provide way to do that. I try to make prefetch with to_attr="task_rules", but, we cannot use twice same name. # This solution does not work. to_attr cannot be have same name twice. # In this case, i do not known how filter for having distinct results Task.objects.prefetch( Prefetch("from_task_rule", queryset=Rule.objects.all(), to_attr="task_rules"), Prefetch("to_task_rule", queryset=Rule.objects.filter(...), to_attr="task_rules") ) Anybody have an idea, excluded to prefetch during loop for preventing N+1 query ? Thanks -
What are alternative options for configuring Postfix for sending newsletter emails through Django?
I am trying to send a newsletter from my site. On average, 500 emails should be sent per mailing list. I'm trying to set up Postfix to do this and send emails through it. smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination myhostname = example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases mydomain = example.com myorigin = $mydomain mydestination = www.$mydomain, $myhostname, localhost.localdomain, localhost, localhost.$mydomain, $mydomain relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = loopback-only inet_protocols = all milter_default_action = accept milter_protocol = 2 smtpd_milters = inet:127.0.0.1:8891 non_smtpd_milters = inet:127.0.0.1:8891 I want to send emails using django. And I use postfix mailing user, but when I try to send an email, nothing happens. EMAIL_HOST = 'localhost' EMAIL_PORT = 25 EMAIL_HOST_USER = 'mailing@example.com' EMAIL_HOST_PASSWORD = '******' EMAIL_USE_TLS = True EMAIL_USE_SSL = False SERVER_EMAIL = 'mailing@example.com' DEFAULT_FROM_EMAIL = 'mailing@example.com' What am I doing wrong and how to fix it? Or maybe there are alternative options for my task, thanks in advance. Set up postfix to send emails using Django. The error does not occur, but the letters do not come. -
Module 'projectname' has no attribute 'celery'
I want to call a url after a hour so I added celery and with the help of ChatGPT I did upto here taskapp/tasks.py (Newly Created but not registered in settings.py told by ChatGPT) from celery import shared_task import requests @shared_task def call_url_task(): # Perform the task you want to execute every hour response = requests.get("https://myurl.com") # Replace with your desired URL # Process the response or perform any other actions if needed if response.status_code == 200: print("URL called successfully.") and Here's my views.py of actual app starting lines from taskapp.tasks import call_url_task from celery.schedules import crontab from celery.task import periodic_task @periodic_task(run_every=crontab(minute='*')) def schedule_task(): call_url_task.delay() # Call the task asynchronously using delay() settings.py from celery import Celery app = Celery('projectname') app.config_from_object('django.conf:settings', namespace='CELERY') ... CELERY_BROKER_URL = 'redis://localhost:6379' CELERY_RESULT_BACKEND = 'redis://localhost:6379' Error I am facing: $ celery -A projetname worker --loglevel=info Usage: celery [OPTIONS] COMMAND [ARGS]... Try 'celery --help' for help. Error: Invalid value for '-A' / '--app': Unable to load celery application. Module 'projectname' has no attribute 'celery' I tried checking the installation of Redis and Celery and they are installed already. I couldn't find solution for my problem on ChatGPT even. Have I done something wrong? I have also seen … -
Django model constrains
I am trying to create an Asset management system and the model AssetLog is responsible of making sure that a user is assigned to a single computer and a computer is assigned to a single user. And i have managed to set that up but now, Trying to update an object from current to previous is now not allowing me to do so even using the Django Admin panel class AssetLog(models.Model): Used = "U" Previous = "P" Current = "C" status_choices = [ (Used, "Used"), (Previous, "Previous"), (Current, "Current"), ] status = models.CharField( max_length=1, choices= status_choices, default=Current, ) user_id = models.ForeignKey(Account,on_delete=models.CASCADE) asset_num = models.ForeignKey(Computer,on_delete=models.CASCADE) allocated_on = models.DateTimeField(auto_now_add=True) updated_on = models.DateTimeField(auto_now=True) Location = models.ForeignKey(Location,on_delete=models.CASCADE) def clean(self): # Checking if the user and the computer have been logged a = AssetLog.objects.filter(Q(asset_num=self.asset_num) & Q(user_id=self.user_id)).exists() b = AssetLog.objects.filter(Q(asset_num=self.asset_num)).exists() c = AssetLog.objects.filter(Q(user_id=self.user_id)).exists() try: if a: computer = AssetLog.objects.get(asset_num=self.asset_num) if computer.status == 'C': msg = 'The Asset is being used by- ' + computer.user_id.first_name raise ValidationError(msg) elif b: computer = AssetLog.objects.get(asset_num=self.asset_num) if computer.status == 'C': msg = 'The Asset is being used by- ' + computer.user_id.first_name raise ValidationError(msg) elif c: computer = AssetLog.objects.get(user_id=self.user_id) if computer.status == 'C': msg = 'The User has a machine allocated to … -
How to save stripe user info for next transaction in Django Rest framework?
Is it possible to store user data after first payment of stripe for next transaction so that he doesn't need to provide card information again like FIVERR? I actually want a system to save the card information with Django rest framework. You can see my stripe payment system. I actually totally confused between it possible or not. Please tell me what response will come and what info will come as input from the frontend. import stripe # Set your API key stripe.api_key = 'sk_test_51N' c_amount = 1 # Create a PaymentIntent with the order amount and currency intent = stripe.PaymentIntent.create( amount=100*c_amount, currency='usd', payment_method_types=['card'], ) print("client_secret:",intent['client_secret']) print("amount:",intent['amount']) print("payment_id:",intent['id']) -
('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)
I am successfully able to send an HTTP GET request using Python 3.9. However, when attempting the same request using Django 4.2 and Python 3.10, it fails to work as expected. import requests headersa = { 'accept': 'text/plain', 'x-api-key': 'pgH7QzFHJx4w46fI~5Uzi4RvtTwlEXp' } url = "https://10.11.11.66:1003/config/v6/servers" try: response = requests.get(url=url, headers=headersa, verify=False, timeout=50) print(response.text) except requests.exceptions.RequestException as e: print("An error occurred:", e) When I use Python 3.9, I am able to send an HTTP GET request without any issues, and it functions correctly. However, when I attempt to send the same HTTP GET request within the context of a Django 4.2 project using Python 3.10, I encounter errors or unexpected behavior. -
sqlite3.OperationalError: no such table: auth_user
I'm developing a simple app using Django. I am done with the development and I'm trying to push to Heroku server. I get this error if I try to create a superuser You have 21 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, journpys, sessions. Run 'python manage.py migrate' to apply them. Traceback (most recent call last):`File "/app/.heroku/python/lib/python3.10/site-packages/django/db/backends/utils.py", line 89, in _execute return self.cursor.execute(sql, params) File "/app/.heroku/python/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py", line 328, in execute` return super().execute(query, params) sqlite3.OperationalError: no such table: auth_user I need help in fixing this error. Thanks. All migrations have been done locally and using the Heroku run python manage.py migrate command with no issues. I have also looked at some articles on solutions to this error but none seemed to work. -
Django URL Namespace: Do All URLs Require Prefixes?
I created a URL namespace by specifying app_name in the app's URL module. However, now I am getting a NoReverseMatch error when using a named URL in my template without the namespace prefix. Is the namespace prefix required for all URLs if one is specified (even if there is no ambiguity)? -
create dynamic html templates to serve all clients in my django project
I created a customer registration system for a monthly water consumption billing system now my system for each customer that I add I have to create a new table in the database and create the same html templates again to be able to work on the entire billing process now I have to change the way of adding a customer so I don't have to make several forms for each customer now I want to make a single form to serve all customers and I will also make a single table in the database to register more customers a billing table which will have the client's foreign key so I don't know how to start making dynamic forms just click on it to open the form and show only the customer data I want to invoice I ask for help on how to do this process -
Is there a better and more efficient way to check if a parameter is in request data to apply to django query filter?
I am building a REST API using Django, in the views I want to query models based on an unknown quantity of fields (as supplied in the front end as required). Previously I have been checking every combination possible for the incoming parameters to see if they are in the request data - if so, apply them to the query. However as the number of possible parameters increase (one of my current projects has 6 possible parameters), the number of permutations becomes too large. Is there a more efficient way of achieving the below? if 'A' in request.GET['A'] and 'B' in request.GET['B'] and 'C' in request.GET['C']: query_1 = model_1.objects.filter(a=request.GET['A'], b=request.GET['B'], c=request.GET['C']) elif 'A' in request.GET['A'] and 'B' in request.GET['B']: query_1 = model_1.objects.filter(a=request.GET['A'], b=request.GET['B']) elif 'B' in request.GET['B'] and 'C' in request.GET['C']: query_1 = model_1.objects.filter(b=request.GET['B'], c=request.GET['C']) elif 'A' in request.GET['A'] and 'C' in request.GET['C']: query_1 = model_1.objects.filter(a=request.GET['A'], c=request.GET['C']) elif 'A' in request.GET['A']: query_1 = model_1.objects.filter(a=request.GET['A']) elif 'B' in request.GET['B']: query_1 = model_1.objects.filter(b=request.GET['B']) elif 'C' in request.GET['C']: query_1 = model_1.objects.filter(c=request.GET['C']) -
Django formset: {{form.instance.ide}} return record value in template but do not work in {% url 'ecrf:traitement_delete' form.instance.ide %}
I try to implement Django formset. I manage the basic (i.e. create and update records) but I would like to be able to delete a formset (and later add dynamically a new formset). But to do that, I need to get access to record id (PK field is named 'ide' in my model). But in my template, if I render {{form.instance.ide}} for each formset, it return the correct value but if I try to use it in url to set url to delete, it doesn't works as form.instance.ide return None inside url tag. Do not understand difference between using form.ide (that do not return the value in my case) and form.instance.ide? -
Access Powershell Output from $admins=Get-LocalGroupMember -Group "administrators"` in Django app
I´m trying to access the Powershell Output from $admins=Get-LocalGroupMember -Group "administrators" in my Django app. views.py def psAPI(request): if request.method == 'POST': admins=request.POST['admins'] print(admins) return HttpResponse(status=200) Ps Script $admins=Get-LocalGroupMember -Group "administrators" $Body =@{ "admins"=$admins } Invoke-WebRequest -Uri <url>/psAPI/ -Method Post -Body $Body wanted Ouptut in Python ObjectClass Name PrincipalSource ----------- ---- --------------- User DESKTOP-*******\Administrator Local the Output I got System.Object[] -
Authorization backend function called twice in Django
I've implemented apple sign-in following this article: https://github.com/truffls/sign-in-with-apple-using-django/blob/master/backend.md Code: import jwt import requests from datetime import timedelta from django.conf import settings from django.utils import timezone from social_core.utils import handle_http_errors from social_core.backends.oauth import BaseOAuth2 class AppleOAuth2(BaseOAuth2): name = 'apple' ACCESS_TOKEN_URL = 'https://appleid.apple.com/auth/token' SCOPE_SEPARATOR = ',' ID_KEY = 'uid' @handle_http_errors def do_auth(self, access_token, *args, **kwargs): response_data = {} client_id, client_secret = self.get_key_and_secret() headers = {'content-type': "application/x-www-form-urlencoded"} data = { 'client_id': client_id, 'client_secret': client_secret, 'code': access_token, 'grant_type': 'authorization_code', } res = requests.post(AppleOAuth2.ACCESS_TOKEN_URL, data=data, headers=headers) response_dict = res.json() id_token = response_dict.get('id_token', None) if id_token: decoded = jwt.decode(id_token, '', algorithms=["ES256"], options={"verify_signature": False}) response_data.update({'email': decoded['email']}) if 'email' in decoded else None response_data.update({'uid': decoded['sub']}) if 'sub' in decoded else None response = kwargs.get('response') or {} response.update(response_data) response.update({'access_token': access_token}) if 'access_token' not in response else None kwargs.update({'response': response, 'backend': self}) return self.strategy.authenticate(*args, **kwargs) def get_user_details(self, response): email = response.get('email', None) details = { 'email': email, } return details def get_key_and_secret(self): headers = { 'kid': settings.SOCIAL_AUTH_APPLE_ID_KEY }**strong text** payload = { 'iss': settings.SOCIAL_AUTH_APPLE_ID_TEAM, 'iat': timezone.now(), 'exp': timezone.now() + timedelta(days=180), 'aud': 'https://appleid.apple.com', 'sub': settings.SOCIAL_AUTH_APPLE_ID_CLIENT, } client_secret = jwt.encode( payload, settings.SOCIAL_AUTH_APPLE_ID_SECRET, algorithm='ES256', headers=headers ) return settings.SOCIAL_AUTH_APPLE_ID_CLIENT, client_secret Authorization succeeds, i receive access token from apple but after that function do_auth is …