Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Handle a file that can have suspicious macros when passed over HTTP request
Suppose a user is trying to upload a file that contains macros to the server (I am using the Django server). How can I handle or check whether the file contains macros inside it without opening or writing the file to the server. I am using oletools for detecting macros. The problem is, whenever a file is uploaded using the POST method, the URL is bound to a view "upload-doc". Inside the view I want to detect the macros. But as the file is still in HTTP request (not written to the server yet) the type of the file is "InMemoryUploadFile" which means I guess it is still in memory, not written to disk. Now, how can I detect the macros in this file which is not yet written to the disk? From this example on using olevba, I have to pass the file path for detecting macros, but as the file is in memory, I am getting "FileNotFound" error. Is there any way to detect macros in a file without accessing or writing to the server when it is uploaded using HTTP POST request? I am open to using any other package in achieving this. ANy suggestions can help … -
How to make Forgot password for user in Django [duplicate]
This question already has an answer here: Resetting Password in Django 4 answers The Django provides default forgot the password functionality for the admin site but what about the user?? How can I do that is there any way?? In that case, we just have to make changes in Settings.py and it starts work #setting.py EMAIL_HOST = 'smtp.mailtrap.io' EMAIL_HOST_USER = '729a166592447' EMAIL_HOST_PASSWORD = 'c23c7c2fff61' EMAIL_PORT = '2525' The above credentials for default admin site but I don't have any idea how to do the same thing for the user -
Django Multiple Authentication Database, MongoDB and SQLite
I'm trying to have two authentication backends in my project. Default DataBase for my app is MongoDB but I'm using another app built with SQLite where I need a copy of the users from MongoDB but I think that because MongoEngine I cannot find the way to access SQLite DB with something like: Users.objects.get(username='username') Code I Have In settings is: AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'mongoengine.django.auth.MongoEngineBackend', ) _MONGODB_USER = '****' _MONGODB_PASSWD = '****' _MONGODB_HOST = '127.0.0.1' _MONGODB_NAME = '****' _MONGODB_DATABASE_HOST = \ 'mongodb://%s:%s@%s/%s' \ % (_MONGODB_USER, _MONGODB_PASSWD, _MONGODB_HOST, _MONGODB_NAME) connect(_MONGODB_NAME, host=_MONGODB_DATABASE_HOST, max_pool_size=None) AUTH_USER_MODEL = 'mongo_auth.MongoUser' MONGOENGINE_USER_DOCUMENT = 'mongoengine.django.auth.User' I think that the problem is with AUTH_USER_MODEL and MONGOENGINE_USER_DOCUMENT that is overriding default Authentication that would be with SQLite but I tried to delete it and I get an error like: 'A server error ocurred, contact with administrator' How can I have the two authentication methods working ? I also tried writting my own backend.py but the problem is still the same, I cannot access Users.objects.get(username='username') from SQLite DB -
Test search function in django by id
i want to test my queryset which returns a single object by a given id in django rest framework class UniquePlaceAPI(generics.ListAPIView): queryset=Places.objects.all() serializer_class=ViewPlaceSerializer filter_backends= [SearchFilter] search_fields = ['id'] def get_queryset(self): queryset = Places.objects.all() id = self.request.query_params.get('search') if id is not None: queryset = queryset.filter(id__exact=id).distinct() return queryset i wrote this test for my code: def test_unique_search(self): url='http://127.0.0.1:8000/api/Places/UniquePlace/?search=1' response=self.client.get(url) self.assertEqual(response.status_code,200) queryset = Places.objects.all() id = self.request.query_params.get('search') print if id is not None: queryset = queryset.filter(id__exact=id).distinct() self.assetEqual(queryset,'اصفهان') but it give me an error which says that AttributeError: 'TestView' object has no attribute 'request' how can i fix this issue? -
Django ModelForm field choices filtered for a specific model
I tried this approached to allow project_id to be dynamic, but i get an error:"init() missing 1 required positional argument: 'project_id'". forms.py class CreateCostForm(forms.ModelForm): def __init__(self,project_id,*args, **kwargs): super(CreateCostForm, self).__init__(*args, **kwargs) self.fields['cost_name'].queryset = ProjectCost.objects.filter(project_name_id=project_id) class meta: model = ProjectCost When i hard-code the value of project_id like: self.fields['project_name'].queryset = ProjectCost.objects.filter(project_name_id=4) or ProjectCost.objects.filter(project_name_id= 8), i get the correct filtered options on the form.So how can i make project_id dynamic? i tried: def init(self, *args, **kwargs): project_id = kwargs.pop('project_id', None) super(CreateCostForm, self).init(*args, **kwargs) self.fields['cost_name'].queryset = ProjectCost.objects.filter(project_name_id=project_id) But this returns 'None' for the value of 'project_id'. Any idea on how to fix this? Thanks. -
ForeignKey don't show data
When I try to use foreignKey, html don't response Models.py class Home(models.Model): book = models.ForeignKey(Book, verbose_name=( "book"), on_delete=models.CASCADE, related_name="book") Views.py def main(request): posts = Home.objects.all() return render(request, 'home/home-page.html', {'posts': posts}) HTML {% for post in posts %} {% for book in post.book.all %} {{ book }} {% endfor %} {% endfor %} What going wrong? -
Django separate model class to two
I have one model class like this: class Teams(models.Model): Name = models.CharField(max_length=200) Games_n = models.IntegerField(default=0) Win_n = models.IntegerField(default=0) Los_n = models.IntegerField(default=0) Eve_n = models.IntegerField(default=0) Game_mean = models.IntegerField(default=0) Best_game = models.IntegerField(default=0) Event = models.ForeignKey(Events, on_delete=models.CASCADE) Team_year = models.IntegerField(default=0) and I have collected all the data to database, but now I think it is better to separate Team name to another class (because same team can be in different events). So my question is: is it possible to separate classes afterwards? That in the end I would have something like this: class Team_event(models.Model): Team = models.ForeignKey(Teams, on_delete=models.CASCADE) Games_n = models.IntegerField(default=0) Win_n = models.IntegerField(default=0) Los_n = models.IntegerField(default=0) Eve_n = models.IntegerField(default=0) Game_mean = models.IntegerField(default=0) Best_game = models.IntegerField(default=0) Event = models.ForeignKey(Events, on_delete=models.CASCADE) Team_year = models.IntegerField(default=0) class Teams(models.Model): Name = models.CharField(max_length=200) -
Generate apple client secret and token
Acoording to Apple Developer website https://developer.apple.com/documentation/signinwithapplerestapi/generate_and_validate_tokens I want to generate client_secret string with given Apple static variables and later use this client_secret to get an apple token. Unfortunately, in return of response I get 400 Error Response and my JSON response contains a dict only with error key. Also I generate a authorizationCode ("code" in functions) which is valid for only 5 minuts. Is there any possibility to check the correctness of generated client_secret string or a mistake is somewhere else? Function to generate client secret: def get_apple_client_secret() -> str: headers = {"alg": "ES256", "kid": settings.APPLE_KEY_ID} payload = { "iss": settings.APPLE_TEAM_ID, "iat": int(timezone.now().timestamp()), # epoch time "exp": int((timezone.now() + timedelta(days=180)).timestamp()), "aud": "https://appleid.apple.com", "sub": settings.APPLE_CLIENT_ID, } keyfile = open("accounts/apple_priv_key.p8", "r") private_key = keyfile.read() client_secret = jwt.encode( payload, private_key, algorithm="ES256", headers=headers ).decode("utf-8") return client_secret Function to achieve apple token: def get_apple_token(code: str, client_secret: str) -> dict: headers = {"content-type": "application/x-www-form-urlencoded"} data = { "client_id": settings.APPLE_CLIENT_ID, "client_secret": client_secret, "code": code, "grant_type": "authorization_code", "redirect_uri": settings.APPLE_REDIRECT_URI, } response = requests.post( "https://appleid.apple.com/auth/token", data=data, headers=headers ) print(response) print(response.json()) return response.json() Printed response and response.json(): <Response [400]> {'error': 'invalid_client'} -
How to get the absolute path of a uploaded file? - Python + Django
This is a snapshot of my web page. I am able to get the file name but not the root directory of the file. Is there any way to get it? And also, I want to pass this path to my python code to get some values from excel file. Any help will be appreciated. -
How to add condition on join in django ORM?
Actually, I need a self join with a condition. But no one answered me this question(my question), so I decided to use two identical models. I need to add a condition AND on join like this: LEFT OUTER JOIN "processing"."payer_payment_source" T7 ON ("processing"."payer_payment_source"."payer_id" = T7."payer_id" AND "T7."payment_type_id" = 'bank_card_details) views.py paymentsss = Transaction.objects.all().select_related('currency', 'payment_source__payment_type', 'deal__service__contractor', 'payment_source__payer') I want to add: "T7."payment_type_id" = 'bank_card_details models.py class PayerPaymentSource1(models.Model): payer_id = models.BigIntegerField(blank=True, null=False, primary_key=True) payment_type = models.ForeignKey(PaymentType, max_length=64, blank=True, null=True, on_delete=models.CASCADE) source_details = models.TextField(blank=True, null=True) # This field type is a guess. class Meta: managed = False db_table = '"processing"."payer_payment_source"' class PayerPaymentSource(models.Model): id = models.BigIntegerField(blank=True, null=False, primary_key=True) payer = models.ForeignKey(PayerPaymentSource1, blank=True, null=True, on_delete=models.CASCADE) payment_type = models.ForeignKey(PaymentType, max_length=64, blank=True, null=True, on_delete=models.CASCADE) source_details = models.TextField(blank=True, null=True) # This field type is a guess. class Meta: managed = False db_table = '"processing"."payer_payment_source"' class Transaction(models.Model): id = models.BigIntegerField(blank=True, null=False, primary_key=True) currency = models.ForeignKey(Currency, null=True, on_delete=models.CASCADE) deal = models.ForeignKey(Deal, null=True, on_delete=models.CASCADE) # service_instance = models.ForeignKey(ServiceInstance, null=True, on_delete=models.CASCADE) payment_source = models.ForeignKey(PayerPaymentSource, null=True, on_delete=models.CASCADE) payment_date = models.DateTimeField(blank=True, null=True) amount = models.IntegerField(blank=True, null=True) status = models.CharField(max_length=255, blank=True, null=True) context = models.TextField(blank=True, null=True) class Meta: managed = False db_table = '"processing"."transaction"' -
Problem with registering 2 profile models in Django Admin
I have made 2 User Profile models Professor and Student, both of them have a OneToOne relationship with The Django User Model. When I am trying to register it in the Admin Panel the following Problem occurs. django.contrib.admin.sites.AlreadyRegistered: The model User is already registered Here is my models.py file class Student(models.Model): user = models.OneToOneField(to=User, on_delete=models.CASCADE) profile_pic = models.ImageField(upload_to='StudentProfilePic', blank=True) institution = models.ForeignKey(to=Institution, blank=True, null=True, on_delete=models.CASCADE) course = models.CharField(max_length=50, blank=True) roll_no = models.IntegerField() def __str__(self): return self.name class Professor(models.Model): user = models.OneToOneField(to=User, on_delete=models.CASCADE) profile_pic = models.ImageField(upload_to='ProfessorProfilePic', blank=True) institution = models.ForeignKey(to=Institution, blank=True, null=True, on_delete=models.CASCADE) def __str__(self): return self.name admin.py file from django.contrib import admin from django.contrib.auth.admin import UserAdmin from django.contrib.auth.models import User from . models import Student, Professor admin.site.unregister(User) class StudentInline(admin.StackedInline): model = Student class StudentUserAdmin(UserAdmin): inlines = (StudentInline, ) class ProfessorInLine(admin.StackedInline): model = Professor class ProfessorUserAdmin(UserAdmin): inlines = (ProfessorInLine, ) admin.site.register(User, StudentUserAdmin) admin.site.register(User, ProfessorUserAdmin) The error occurs in the last line admin.site.register(User, ProfessorUserAdmin) -
Heroku: How to specify the path of JVM buildpack non-java projects?
I'm deploying a Django/Python project on heroku, and I need the java.exe path. In one of my django/python scripts I have: ... owlready2.JAVA_EXE = "C:\\Program Files\\Java\\jre1.8.0_221\\bin\\java.exe" ... This runs on my localhost, but since I want to deploy my project on heroku, I know I would need tohsave some version of java install. However, I don't know how to install java and then specify the java.exe path in my django/python script for deployment. -
Newly created Django project won't generate migrations
I'm trying to add a simple model and run migrations for it in a newly created Django app (2.2.7). As I'm completely new to Django, I seem to miss some important setting. I've listed the steps I've done below, including the error message at the bottom. django-admin startproject myproject cd myproject django-admin startapp myapp This is the current project structure ➜ myproject tree . ├── manage.py ├── myapp │ ├── __init__.py │ ├── admin.py │ ├── apps.py │ ├── migrations │ │ └── __init__.py │ ├── models.py │ ├── tests.py │ └── views.py └── myproject ├── __init__.py ├── settings.py ├── urls.py └── wsgi.py I add the app myapp to myproject/settings.py: INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'myproject.apps.MyappConfig' ] I add a model in myapp/models.py: from django.db import models class Post(models.Post): title = models.CharField(max_length=100) Now I want to create the migrations based on the model: python3 manage.py makemigrations What I get is this error: ➜ myproject python3 manage.py makemigrations Traceback (most recent call last): File "manage.py", line 21, in <module> main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line utility.execute() File "/usr/local/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv … -
django save all record in for loop
this is the code from the picture {% for schedule in sched %} <tr> <td></td> <td>{{schedule.Remark}}</td> <td>Php {{ schedule.Amount|floatformat:2}}</td> <td> </td> </tr> {% endfor %} this is the code from inserting record to database id = request.POST.get('ids') educlevel = request.POST.get('gradelevel') studentname = StudentProfile(id=id) educationlevel = EducationLevel(id=educlevel) id = request.POST.get('payments') payment = PaymentType(id=id) sc = request.POST.get('schoolyear') schoolyear = SchoolYear(id=sc) V_insert_data = StudentsEnrollmentRecord( Student_Users=studentname, Payment_Type=payment, Education_Levels=educationlevel,School_Year=schoolyear ) V_insert_data.save() for file in request.FILES.getlist('myfile'): StudentsSubmittedDocument.objects.create( Students_Enrollment_Records=V_insert_data, Document=file ) insert_StudentsPaymentSchedule = StudentsPaymentSchedule( Students_Enrollment_Records = V_insert_data, #Amount = ScheduleOfPayment.Amount, Remarks = ScheduleOfPayment.Remark ) insert_StudentsPaymentSchedule.save() this the models.py class ScheduleOfPayment(models.Model): Pending_Request = [ ('Active', 'Active'), ('Inactive', 'Inactive'), ] Education_Levels = models.ForeignKey(EducationLevel, related_name='+', on_delete=models.CASCADE, blank=True, null=True) Courses = models.ForeignKey(Course, related_name='+', on_delete=models.CASCADE,blank=True, null=True) Payment_Type = models.ForeignKey(PaymentType, related_name='+', on_delete=models.CASCADE, blank=True, null=True) Display_Sequence = models.IntegerField(blank=True, null=True) Date = models.DateField(null=True,blank=True) Amount = models.FloatField(null=True, blank=True) Remark = models.CharField(max_length=500,blank=True, null=True) this is where I want to save all the record shown class StudentsPaymentSchedule(models.Model): Students_Enrollment_Records=models.ForeignKey(StudentsEnrollmentRecord, related_name='+', on_delete=models.CASCADE,null=True) Payment_Schedule = models.DateField(null=True,blank=True) Amount = models.FloatField(null=True,blank=True) Remarks=models.TextField(max_length=500,null=True,blank=True) this is the problem, only 1 record save in database StudentsPaymentSchedule, I just want to save all the Payment schedule and amount from database ScheduleOfPayment and automatic post it in StudentsPaymentSchedule and I don't know what this mean django.db.models.query_utils.DeferredAttribute object at … -
How to get the model from the content type object
When I refer Django Docs I can see that Django ContentType model having three fields . 1)app_label 2)model 3)name Now I get the ContentType object using the filter query. I would like to get the model name from this ContentType object a=Module.objects.filter(slug="sales") for x in a: logger.info(x.content_type) -
Django channels using secured WebSocket connection - WSS://
When I tried to run server using sslserver as shown below, python manage.py runsslserver Errors: Traceback: Validating models... System check identified no issues (0 silenced). November 08, 2019 - 11:17:26 Django version 2.0.7, using settings 'dashboard_channels.settings' Starting development server at https://127.0.0.1:8000/ Using SSL certificate: \lib\site-packages\sslserver\certs\development.crt Using SSL key: \lib\site-packages\sslserver\certs\development.key Quit the server with CTRL-BREAK. [08/Nov/2019 11:18:33] "GET / HTTP/1.1" 200 1299 [08/Nov/2019 11:18:34] "GET / HTTP/1.1" 200 1299 [08/Nov/2019 11:18:35] "GET /static/js/jquery.js HTTP/1.1" 200 270575 Not Found: /ws/home [08/Nov/2019 11:18:36] "GET /ws/home HTTP/1.1" 404 2134 Browser Console: (index):31 WebSocket connection to 'wss://127.0.0.1:8000/ws/home' failed: Error during WebSocket handshake: Unexpected response code: 404 (index):41 error Event (index):44 close CloseEvent Code: Javascript: var loc = window.location; var wsStart = 'ws://'; if (loc.protocol == 'https:') { wsStart = 'wss://' } var endpoint = wsStart + loc.host + '/ws/home'; var socket = new WebSocket(endpoint); It's working fine with normal python manage.py runserver command. Anyhow this for testing purposes, finally I need to deploy it on Apache2.4 in the windows server machine. Where I have already setup for https but not for web sockets. -
what is 'code' parameter in django-rest-social-auth?
I am new in Django and working on django-rest-social-auth. I want to implement social login in my app.(frontend- angular, Backend- Django) but I am not getting what is the code parameter below request. POST /api/login/social/token/ input: { "provider": "facebook", "code": "AQBPBBTjbdnehj51" } output: { "token": "68ded41d89f6a28da050f882998b2ea1decebbe0" } POST /api/login/social/token_user/ input: { "provider": "facebook", "code": "AQBPBBTjbdnehj51" } output: { "username": "Alex", "email": "user@email.com", // other user data "token": "68ded41d89f6a28da050f882998b2ea1decebbe0" } -
ForeignKeys and historical data
I have a Quote table that generates a price based on lots of parameters. Price is generated based on data from multiple other tables like: Charges, Coupon, Promotions etc. The best way to deal with it is using ForeignKeys. Here's the table (all _id fields are foreign keys): Quote #user input fields charge_id promotion_id coupon_id tariff_id Everything looks good. Each quote record has very detailed data that tells you where the price comes from. The problem is the data in the tables that it depends on isn't guaranteed to stay the same. It might get deleted or get changed. Let's say a Quote has a foreign key to a tariff and then it gets changed. The records associated with it no longer tell the same story. How do you deal with something like this? Would really appreciate if you recommend some theory related to this. -
value() function showing two time output
from hellogymapp.models import CommCenter def ajaxAgent(request): data = CommCenter.objects.values('inbound_mtd') return HttpResponse(data) -
Django query show length in a template'
I am trying output the length of my query in a template. What is the right method to do that? I have tried len(),.count(),count() but nothing worked. here is my views.py code for that part: @login_required def view_contacts(request): print("Current User") current_user = request.user.get_username() user = User.objects.filter(username=current_user).first() output = UserContacts.objects.filter(current_user_id=user.id).first() my_dict = {'output':output,'number': output.count} return render(request,'basic_app/view_contacts.html',my_dict) and this is my view.contacts.html {%extends 'basic_app/base.html' %} {% block body_block %} <div class = "jumbotron"> <p> you have {{ number }} of contacts in your address book</p> <p> {{ output }} </p> </div> {% endblock %} Any help would be greatly appreaciated Error I get: 'UserContacts' object has no attribute 'count' -
Is there a way to connect my google home mini to python so that I can send the speech to text to my python interpreter to parse
I want to do a side project and just wanted to know how to connect my google home mini to python code? using some api if i can send the speech the user sends to my python editor to parse through, it would do exactly what i need -
Cannot connect postgres db and PGadmin using docker-compose file (running locally on mac)
I've been having issues trying to connect pgadmin and postgres database running in docker containers locally on my machine. All containers are up and running. Database is running, Django is running, Django is running and I can create data and save to django models. I can access PGadmin at local host and log in. When I go create server and add, host localhost also tried, 0.0.0.0 also tried, 127.0.0.1 port 5432 name postgres username postgres password postgres I receive this error, Unable to connect to server: could not connect to server: Connection refused Is the server running on host "0.0.0.0" and accepting TCP/IP connections on port 5432? If my django app is running do I need to be on another port to access the database for PGadmin to work? I can't find any documentation for django postgres and pgadmin running with docker-compose. Here's my docker-compose file version: '3.4' services: db: restart: always image: postgres volumes: - pgdata:/var/lib/postgresql/data environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres ports: - "5432:5432" expose: - 5432 redis: restart: always image: redis volumes: - redisdata:/data pgadmin: image: dpage/pgadmin4 depends_on: - db ports: - "5555:80" environment: PGADMIN_DEFAULT_EMAIL: pgadmin4@pgadmin.org PGADMIN_DEFAULT_PASSWORD: admin restart: unless-stopped django: build: context: ./backend environment: - DATABASE_URL=postgres://postgres:postgres@db:5432/postgres command: … -
Is there a way to use a model field in an if conditional via a Django Template?
I am creating a template that displays a button but only if a particular user has a 'path' field in the Model. How can I use the model attribute inside the if conditional? This is my current code: models.py: from django.db import models from django.contrib.auth.models import User class Path(models.Model): user = models.OneToOneField(User, on_delete = models.CASCADE) path = models.CharField(max_length = 255, blank=False, null=False) #Will not accept empty string or None created_date = models.DateTimeField(auto_now = True) def __str__(self): return f"{self.user.username}" template.html: {% if path.path %} <button class="btn btn-outline-info" onclick="function()" id='button'> Initiate Index </button> {% endif %} Currently, {% if path.path %} does not work. How can I access the path attribute inside my if conditional. If the path exists, a button will be seen. If not, vice versa. Thank you in advance. -
Django Autocomplete Light is not working with Django Filters
I am trying to use Django autocomplete light with Django filters. I've written the following codes. And also tried different solutions, but nothing is working for me. An empty list is shown in the dropdown. settings.py INSTALLED_APPS = [ 'dal', 'dal_select2', 'django.contrib.admin', # ............ ] filters.py class OrderFilter(django_filters.FilterSet): user = django_filters.ModelChoiceFilter( label='Username', queryset=User.objects.all(), empty_label="All", # lookup_expr='icontains', widget=autocomplete.ModelSelect2(url='user:search') ) urls.py from django.urls import path from .views import ( UserList, UserSearchAutocomplete, ) app_name = 'user' urlpatterns = [ path('list/', UserList.as_view(), name='list'), path('search/', UserSearchAutocomplete.as_view(), name='search'), ] views.py from dal import autocomplete class UserSearchAutocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): qs = User.objects.all() if self.q: qs = qs.filter(first_name__istartswith=self.q) return qs templates/list.html {{ filter.form.user }} Help me to solve the problem. Thanks in advance. -
Django - Celery - SQS - S3 - Receiving Messages
I have a Django application and I'm using Celery,SQS and S3. When I run the following function using Django, Celery and SQS the function works and it prints 'hello' every minute as it should. from celery.task import periodic_task from celery.schedules import crontab @periodic_task(run_every=crontab(hour='*', minute='*', day_of_week="*")) def print_hello(): print('hello world') But the app is also linked to an S3 Bucket. Whenever a new file is saved to S3 a notification is sent to the SQS queue. The problem happens when a notification message is sent to the SQS queue. When a notification reaches the queue the worker fails. It stops the periodic task print_hello(), gives this error message: [2019-11-07 22:10:57,173: CRITICAL/MainProcess] Unrecoverable error: Error('Incorrect padding') ...parserinvoker/lib64/python3.7/base64.py", line 87, in b64decode return binascii.a2b_base64(s) binascii.Error: Incorrect padding and then quits. I've been looking at the documentation and have been trying to troubleshoot all week and haven't found a solution. I'm including my settings.py in case it's a configuration issue Settings.py BROKER_URL = "sqs://" CELERY_ACCEPT_CONTENT = ['application/json'] CELERY_RESULT_SERIALIZER = 'json' CELERY_TASK_SERIALIZER = 'json' CELERY_DEFAULT_QUEUE = env('CELERY_DEFAULT_QUEUE') CELERY_RESULT_BACKEND = None BROKER_TRANSPORT_OPTIONS = { 'region': 'us-east-1', 'polling_interval':20, 'visibility_timeout': 3600, 'task_default_queue': env('CELERY_DEFAULT_QUEUE'), }