Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Invalid input syntax for type inet
Im having trouble persisting ip_addresses from my users via Django into Postgres. Can I just convert the ip_address field from inet to string and store that in the VARCHAR postgres field? -
After setting up cookiecutter for Django, I get a ConnectionRefusedError for sign-up and sign-in
I'm working on a project using cookiecutter, but for whatever reason, I can't sign in or sign up. If I sign in as a superuser through the admin, I am then logged in when I refresh the homepage and have access to the site, but can't authenticate otherwise. This is the error: ConnectionRefusedError at /accounts/login/ [WinError 10061] No connection could be made because the target machine actively refused it Request Method: POST Request URL: http://127.0.0.1:8000/accounts/login/ Django Version: 3.0.5 Exception Type: ConnectionRefusedError Exception Value: [WinError 10061] No connection could be made because the target machine actively refused it Exception Location: C:\Users\Machine\miniconda3\envs\portfolio\lib\socket.py in create_connection, line 796 Python Executable: C:\Users\Machine\miniconda3\envs\portfolio\python.exe Python Version: 3.8.2 Python Path: ['C:\Users\Machine\Desktop\portfolio-project', 'C:\Users\Machine\miniconda3\envs\portfolio\python38.zip', 'C:\Users\Machine\miniconda3\envs\portfolio\DLLs', 'C:\Users\Machine\miniconda3\envs\portfolio\lib', 'C:\Users\Machine\miniconda3\envs\portfolio', 'C:\Users\Machine\AppData\Roaming\Python\Python38\site-packages', 'C:\Users\Machine\miniconda3\envs\portfolio\lib\site-packages', 'C:\Users\Machine\Desktop\portfolio-project\portfolio', 'C:\Users\Machine\Desktop\portfolio-project\portfolio'] Server time: Mon, 20 Apr 2020 15:19:25 -0500 When I search for this error, I get some references to setting up an e-mail back-end, but as far as I can tell, this is already set up for local development. I went through Daniel Feldroy's Django Crash Course which uses a modified version of cookiecutter, but don't remember having this issue then. -
ValueError at /books/results/
"Field 'id' expected a number but got 'results'." I'm getting this error while trying to use search filter over a list of books. It was working fine until I changed the Class-based view to Function based view. This was the Class based view earlier using the default DetailView class: class BookDetailView(LoginRequiredMixin,DetailView): model = models.Book template_name='book_detail.html' login_url='login' This is the new Function based detail view I changed to: @login_required def book_detail(request,book_id): model =models.Book book=model.objects.get(id=book_id) template ='book_detail.html' owner =CustomUser.objects.get(username=book.owner) return render(request,template,{'book':book,'owner':owner}) Independently when I'm trying to go to detail view, its working fine. But when I try to search using the 'book_search' view, its throwing this error. Previously search functionality was also working fine. @login_required def book_search(request): template ='book_list.html' model =models.Book query =request.GET.get('q') results =model.objects.exclude(owner =request.user).order_by('-available','-id') if query: results =results.filter(Q(title__icontains =query)) paginator = Paginator(results, 9) page =request.GET.get('page') try: books =paginator.page(page) except PageNotAnInteger: books =paginator.page(1) except EmptyPage: books= paginator.page(paginator.num_pages) return render(request,template,{'books':books,'query':query,'page':page}) It has something to do with the result set that the search view is returning a list of books while detail view only require just one id. -
Failing Docker install of Jupyter on Django
I'm following the recommended way to install jupyter on django by installing the following pip packages: jupyter ipython django-extensions As described here for example: https://medium.com/ayuth/how-to-use-django-in-jupyter-notebook-561ea2401852 it was working for a while but since some days is failing and I cannot figure out what the problem really is: The error I'm getting is the following: ERROR: Complete output from command /usr/local/bin/python /usr/local/lib/python3.6/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-2xou1hp2/overlay --no-warn-script-location --no-binary :none: --only-binary :none: --no-index -- setuptools wheel 'ipython>=5' 'jupyter_core>=4.2' jupyter_client: ERROR: Collecting setuptools ERROR: Could not find a version that satisfies the requirement setuptools (from versions: none) ERROR: No matching distribution found for setuptools something seems to have broken the install but I'm lost about what it is. -
Django : error with form_valid and get_full_path()
I am trying to acquire the current tenant's domain name through a form. I am trouble with writing the view that would achieve that. here is my form.py: class ETL(forms.Form): Historical = forms.FileField() Pre_processing = forms.FileField() Supplier = forms.FileField() parameters = forms.FileField() def process_data(self, *args, **kwargs): url = self.request.get_full_path() dbschema = remove_www(url.split(':')[0]).lower() engine = create_engine('postgresql://pierre:56-Pmtmpmtm@127.0.0.1:5432/dbexostock12', connect_args={'options': '-csearch_path={}'.format(dbschema)}) fh = io.TextIOWrapper(self.cleaned_data['Historical'].file) fpp = io.TextIOWrapper(self.cleaned_data['Pre_processing'].file) fs = io.TextIOWrapper(self.cleaned_data['Supplier'].file) fp = io.TextIOWrapper(self.cleaned_data['parameters'].file) .... view.py @method_decorator(login_required, name='dispatch') class Getfiles(LoginRequiredMixin,FormView): template_name = 'upload.html' form_class = ETL success_url = 'Home' def form_valid(request, form): url = request.get_full_path() form.process_data() return super().form_valid(form) and here is the error that I get: AttributeError at /upload.html 'Getfiles' object has no attribute 'get_full_path' I am beginner with django, I am not sure how to resolve this, and the documentation about it got me a bit confused, especially about the form_valid() method. Thank you! -
Required parameter name not set - Django + Amazon S3
I'm trying to setup Amazon S3 for my Django app and I keep getting told 'Required parameter name not set '. This error seems to happen when an image needs to be displayed. For example, it works fine on the homepage where there are no images. Really don't know where I have went wrong. I have following set up in my settings.py. INSTALLED_APPS = [ 'projects', 'users.apps.UsersConfig', 'crispy_forms', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'storages', ] #S3 BUCKET CONFIG AWS_ACCESS_KEY_ID = 'acccess key' AWS_SECRET_ACCESS_KEY = 'secret access key' AWS_BUCKET_NAME = 'bucket name' AWS_S3_FILE_OVERWRITE = False AWS_DEFAULT_ACL = None DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' Full traceback Environment: Request Method: GET Request URL: http://127.0.0.1:8000/projects/createListing Django Version: 2.2 Python Version: 3.7.3 Installed Applications: ['projects', 'users.apps.UsersConfig', 'crispy_forms', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'storages'] Installed 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'] Template error: In template C:\Users\Maksims\Desktop\CA4106-Cloud-Computing\test\src\personal_portfolio\templates\base.html, error at line 10 Required parameter name not set 1 : {% load static %} 2 : <!doctype html> 3 : <html lang="en"> 4 : <head> 5 : <!-- Required meta tags --> 6 : <meta charset="utf-8"> 7 : <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> 8 : 9 : <!-- Bootstrap CSS --> 10 : <link re l="stylesheet" href="https://stack … -
Django ValidationError EmailField
I've been struggling with this error below. I am trying to checkout a user as guest with email but I get a validation error: ValidationError at /register/guest['“NU1@company.com” value must be either True or False.'] next_ = request.GET.get('next') next_post = request.POST.get('next') redirect_path = next_ or next_post or None if form.is_valid(): email = form.cleaned_data.get('email') new_guest_email = GuestEmail.objects.create(email=email) request.sesssion['guest_email_id'] = new_guest_email.id if is_safe_url(redirect_path, request.get_host()): return redirect(redirect_path) else: return redirect('/register/') return redirect('/register/') -
Displaying User Data in Django Admin from multiple models
If I have user data stored in multiple models (Account, x, y, z), how can I have them all displayed on one admin page? For example, If I try something along the lines of: from account.models import Account, XModel, YModel, ZModel class AccountAdmin(UserAdmin): list_display = ('email', . . . , 'a', 'b', 'c') # . . . admin.site.register(Account, AccountAdmin) admin.site.register(XModel, AccountAdmin) admin.site.register(YModel, AccountAdmin) admin.site.register(ZModel, AccountAdmin) I'll get a ton of error messages, i.e. System check identified 30 issues (0 silenced). -
Making changes to Add page description in Django Admin
I'm working on django.And have created a custom user model for sign up.But in the add page there a description which I want to change,have a look at the red mark in the pic And my admin file look like this: from django.contrib import admin from django.contrib.auth.admin import UserAdmin from .models import CustomUser class CustomUserAdmin(UserAdmin): summary="hi" list_display = ('first_name','last_name','email','is_staff', 'is_active',) list_filter = ('first_name','email', 'is_staff', 'is_active',) search_fields = ('email','first_name','last_name','a1','a2','city','state','pincode') ordering = ('first_name',) add_fieldsets = ( ('Personal Information', { # To create a section with name 'Personal Information' with mentioned fields 'description': "", 'classes': ('wide',), # To make char fields and text fields of a specific size 'fields': (('first_name','last_name'),'email','a1','a2','city','state','pincode','check', 'password1', 'password2',)} ), ('Permissions',{ 'description': "", 'classes': ('wide', 'collapse'), 'fields':( 'is_staff', 'is_active','date_joined')}), ) fieldsets = ( ('Personal Information', { 'classes': ('wide',), 'fields': (('first_name','last_name'),'email','a1','a2','city','state','pincode','password')}), ('Permissions', {'fields': ('is_superuser','is_staff', 'is_active','date_joined')}), ) admin.site.register(CustomUser, CustomUserAdmin) What should I add to my admin file and where so that I change it?? Thanks in advance!! -
Django Rest Framework serialization.save() parameters
The below code perform saving new user inputs. In the serializer.save() code block why can't we pass data like serializer.save(ebook,review_author) instead serializer.save(ebook=ebook,review_author=review_author) ? class ReviewCreateView(CreateAPIView): queryset = Review.objects.all() serializer_class = ReviewSerializers def perform_create(self, serializer): pk = self.kwargs.get('e_pk') ebook = get_object_or_404(Ebook,pk=pk) review_author = self.request.user serializer.save(ebook=ebook,review_author=review_author) -
How to make Django Rest Apis Async
Following is my Django application configuration: django = 2.2.11 djangorestframework = 3.9.2 Python = 3.8.2 I am exposing a set of Rest apis for react js frontend, which connects to Postgres using a layered architecture views (controller) - services - data_layer. In data layer, I fetch the data using Connection.Cursor, then transform the data fetched using cursor.fetchall. By default the rest apis are synchronous apis, I am trying to find a way to make them Async, so that system scalability can be increased, otherwise every call will block the main thread. I have tried the following options: Using asyncio library, but I am unable to make the complete call chain Async. I generally get an error that expected return was Response / HttpResponse, but the method is returning Co-routine. I can find examples which contains running simple methods as async, but there's isn't an example of Django Rest API Tried the following link, which use the Threadpool executor to segregate every call on a thread in the controller itself, though the challenge is where to make the Asyncio call in the Main method as shown in the link, since these APIs are externally invoked. Can aiohttp help, not sure, but … -
Django dont get redirect when useing HttpResponseRedirect
i'm create a class views on django, and i want when user submit the form then redirect him to this url:http://127.0.0.1:8000/main/workhouses_list/ but when it redirect this url is printed in address bar: Request URL: http://127.0.0.1:8000/main/workhouse_reg/tsil_sesuohkrow:niam this is my code on the views: def workhouse_reg(request): if request.method== 'POST': workhouse_form=WorkhouseForm(request.POST) if workhouse_form.is_valid(): workhouse_form.save() return HttpResponseRedirect(reverse('main:workhouses_list')) else: return HttpResponse('not valid') this is my urls: app_name ='main' urlpatterns=[ path('workhouses_list/',views.workhouses_list,name='workhouses_list'),] i dont know why get this error..please some one idea..!! thanks..!! -
Give staff permissions to a particular group in Django
So I was making a Django app, and I differentiated users into various groups namely 'admin', 'customer', 'shopkeeper', etc. I can set if the user belongs to the 'admin' group only through the backend (through the Django admin panel). Now I want that whenever a user gets into the 'admin' group, he/she should automatically be given staff access or admin privileges automatically. PS: I know that we can go to the User tab and give him those permissions, but I want to automatically provide certain privileges to a corresponding group. How can that be done? -
Nginx up like orphan containers and not working (521 error)
I am using a container Nginx with docker-compose, but It have a bad configuration. When I link the domain to 8000 port I have a 521 error. It is my Dockerfile: FROM nginx COPY nginx.conf /etc/nginx/nginx.conf I used nginx-alpine, but it not working without alpine python, and I had to change it because Pandas not working with alpine. So, my nginx.conf is: user nginx; worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; ## Default: 1024, increase if you have lots of clients } http { include /etc/nginx/mime.types; # fallback in case we can't determine a type default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; keepalive_timeout 65; upstream app { server django:5000; } server { # use 'listen 80 deferred;' for Linux # use 'listen 80 accept_filter=httpready;' for FreeBSD listen 5000; charset utf-8; # Handle noisy favicon.ico messages in nginx location = /favicon.ico { return 204; access_log off; log_not_found off; } location / { # checks for static file, if not found proxy to app try_files $uri @proxy_to_app; } # django app location @proxy_to_app { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; … -
Can't implement sessions in Django
I had a global variable called list but to implement session, I inserted it in index function but where i previously used that variable in an add function now it is giving an error "Unresolved reference 'tasks'" i tried replacing it with a request.session["tasks"] but when i used it i couldn't add tasks to my to do list ap class NewTaskForm(forms.Form): task = forms.CharField(label="New Task") def index(request): if "tasks" not in request.session: request.session["tasks"] = [] return render(request,"tasks/index.html",{ "tasks": request.session["tasks"] }) def add(request): if request.method == "POST": form = NewTaskForm(request.POST) if form.is_valid(): task = form.cleaned_data["task"] tasks.append(task) return HttpResponseRedirect(reverse("tasks:index")) else: return render(request,"tasks/add.html",{ "form": form }) return render(request, "tasks/add.html",{ "form": NewTaskForm() })''' -
django_microsoft_auth reply URL issues and other questions
I am trying to use the django_microsoft_auth package. I have some questions and issues: When I try and login I get AADSTS50011: The reply URL specified in the request does not match the reply URLs configured for the application - how do I debug or fix this? The docs say If you want multiple Site objects and generate authorize URL when accessing your site from multiple domains, you must not set a SITE_ID But if I do not set the SITE_ID my app will not run at all - I get Site matching query does not exist. So I am running with SITE_ID = 1. Is that an issue? The login with microsoft link is only on the admin page - how would I get that on my app's main login page? -
integrating clean architecture with ORM
I'm trying to develop a monolithic Django application with uncle.bob's clean architecture. The problem is I don't want to miss the powerful abilities of Django ORM but this will make a confusion at the same time. The ORM will handle the repository and data layer of application but at the same time makes problem in DTO because I don't want to transfer objects of type Django model. Should I create a port to convert Django model objects into plain old Python objects? I think Django is not much suitable for integrating with clean architecture. I mean for a monolithic large scale application Django will have many down sides. -
Django form: ModelChoiceField(multiple-select) similar to ModelAdmin.filter_horizontal?
How can I create a field ModelChoiceField(multiple-select) in my own form, similar to that available on admin site (ModelAdmin.filter_horizontal)? Two boxes side by side Interface that allows searching Follow the image below: ChoiceField-MultipleSelect "Admin" -
How to see queries run by Django ORM?
I have DEBUD = True in settings.py file. I have MySQL database configured with django. I have a Course model in courses/models.py. In courses/views.py, I have: @api_view(['GET']) def courses_list(request): courses = Course.objects.all() serializer = CourseSerializer(courses, many=True) return Response(serializer.data) Now, If I make request from Postman to hit this view, I think some query like SELECT * FROM COURSES must be executed. How to see which queries has been executed when I make a request to some backend URL? I have also tried from django.db import connection as described here, but got empty array like this: >>> from django.db import connection >>> connection.queries [] Please, help me achieve what I want to. -
how to filter value with category on detail page template in django?
i have video category in categories, i want to filter video category value in detail page like if i click on video category value then i want this code {% video object.video as my_video %}{% video my_video 'medium' %}{% endvideo %} in detail page. if i click other categories values then i want {% else %} part how can i do that? model.py class Article(models.Model): title = models.CharField(max_length=100) author = models.ForeignKey( User, on_delete=models.CASCADE) thumbnail = models.ImageField(default='def.jpg', upload_to=article_path) video = EmbedVideoField(blank=True, null=True) timestamp = models.DateTimeField(auto_now_add=True) content = RichTextUploadingField(blank=True) category = models.ManyToManyField() def get_absolute_url(self): return reverse('news-detail', kwargs={'pk': self.pk}) views.py def NewsDetail(request, pk): obj = get_object_or_404(Article, pk=pk) context = { 'object': obj, } return render(request, 'news/detail.html', context) detail.html {% if cat in object.category > 'videos' %} {% video object.video as my_video %} {% video my_video 'medium' %} {% endvideo %} {% else %} <figure class="social-icon"> <img src="{{ object.thumbnail.url }}" /> </figure> <h2>{{ object.title }}</h2> <ul> {{ object.author.username }} {{ object.timestamp }} {% for cat in object.category.all %} {{ cat }} {% endfor %} </ul> {{ object.content|safe }} {% endif %} -
use json data in django template
I have a model that has one class that is made up of a number of others using OneToOneField. I would like to provide my template with nested data in json format and parse the json using template tags directly in my template. I have made some use of the Django rest framework. The following is a generic example of my codebase: models.py-------------------------------------- class Class1(models.Model): class_1_field_1 = models.CharField() class_1_field_2 = models.CharField() class Class2(models.Model): class_2_field_1 = models.CharField() class_2_field_2 = models.CharField() class MainClass(models.Model): field_1 = models.CharField() field_2 = models.IntegerField() field_3 = models.DateTimeField() class_1 = models.OneToOneField(Class1, on_delete=models.CASCADE,) class_2 = models.OneToOneField(Class2, on_delete=models.CASCADE,) class Class1Serializer(serializers.ModelSerializer): class Meta: model = Class1 fields = ('class_1_field_1', 'class_1_field_2') class Class2Serializer(serializers.ModelSerializer): class Meta: model = Class2 fields = ('class_2_field_1', 'class_2_field_2') class MainClassSerializer(serializers.ModelSerializer): class_1= Class1Serializer() class_2= Class2Serializer() class Meta: model = MainClass fields = ('field1', 'field2', 'field3', 'class_1', 'class_2') views.py------------------------------------- MainClassListView(ListView): context_object_name = 'mainclasses' model = MainClass serializer_class = MainClassSerializer def get_queryset(self): object_list = MainClass.objects.filter(user__in=[self.request.user]) return object_list def get_context_data(self, **kwargs): context = super().get_context_data(**kwargs) serializer = MainClassSerializer(MainClass.objects.filter(user__in=[self.request.user]), many=True) context['data'] = JSONRenderer().render(serializer.data) return context def dispatch(self, request, *args, **kwargs): return super(MainClassListView, self).dispatch(request, *args, **kwargs) index.html---------------------------------------------------- ... {{data}} ... This tag displays a string with the following format: b'[valid_json_is_displayed_here]', where the valid_json_is_displayed_here is a … -
Are Django STATIC_ROOT files fetched locally on the server or over an Http call?
I'm using the following line in my Django project to embed a logo image file on a PDF. It works fine, but I was just wondering, is the STATIC_ROOT file accessed from the server machine locally or are they fetched via an http call? (Just trying to speed up the pdf generation process as much as possible.) from proj.settings import STATIC_ROOT logo = Image.open(STATIC_ROOT + "img/" + "logo.png") -
How to create functional tests for Django view
In my Django app, I have a view which makes a request to an API server to retrieve data, then displays this data back in a template. I am completely new to testing, and am unsure about what functional tests I can create to test this view. I have created a test to assert that the popup loads and returns a HTTP response 200 (mocking out the API and using a pre-defined mock data set). How else can I test this view? How can I test whether the view is loading the correct data? -
Error when connecting Django project to mysql?
I'm using python 3 and I have tried to connect my Django project(django3) to MySQL but I keep getting this error even though I installed mysqlclient. I get this error when I'm trying to connect to MySQL 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 "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/core/management/__init__.py", line 377, in execute django.setup() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/apps/registry.py", line 114, in populate app_config.import_models() File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/apps/config.py", line 211, in import_models self.models_module = import_module(models_module_name) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 728, in exec_module File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/contrib/auth/models.py", line 2, in <module> from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/contrib/auth/base_user.py", line 47, in <module> class AbstractBaseUser(models.Model): File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/base.py", line 121, in __new__ new_class.add_to_class('_meta', Options(meta, app_label)) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/base.py", line 325, in add_to_class value.contribute_to_class(cls, name) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/models/options.py", line 208, in contribute_to_class self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/django/db/__init__.py", line 28, in __getattr__ return getattr(connections[DEFAULT_DB_ALIAS], item) … -
While executing a Celery Task 'AsyncResult' object is not iterable
I am Using Celery to perform a task in the background on form submission. As soon as form is submitted during POST request, I have created a task to execute in the back ground using delay method. This task processes some click operations on some other web using selenium web driver and return two python lists after task execution. Based on list content I want to display pop up message. When I execute the task using celery and run the Django web development server on form submit , I am getting error message: 'AsyncResult' object is not iterable”. Please suggest how to resolve this issue and proceed further. Here is my code snippet: sample List content which obtained through selenium operations on web page is as shown below: board_not_used_list = ['16123','14960'] board_mgr_permissions_not_present_list = [ '23456','45678'] views.py: -------- def conclude_key_issue_form(request, id=None): if id: action = 'edit' model = get_object_or_404(ConcludeKeyIssues, pk=id) else: action = 'submit' model = ConcludeKeyIssues() message = "" if request.method == 'POST': form = ConcludeKeyIssuesForm(request.POST, instance=model) selected_model_name = request.POST.get('registered_model') if form.is_valid(): new_key_issue_request = form.save(commit=False) new_key_issue_request.integrator_id = request.user.username integrator_username = new_key_issue_request.integrator_id integrator_password = form.cleaned_data['integrator_pwd'] new_key_issue_request.integrator_pwd = integrator_password new_key_issue_request.save() form.save_m2m() created_pk = new_key_issue_request.pk if id is None: board_not_used_list, board_mgr_permissions_not_present_list = task_check_board_availability_and_permissions.delay(created_pk) …