Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Django Rest Framework viewsets.ModelViewSet
I have created a view in my DRF api that takes in a couple of parameters and saves them in the database.Am using a serializer derived from a model to do this.Below is the serializer and model code: class CreditPaymentSerializer(serializers.ModelSerializer): session = serializers.PrimaryKeyRelatedField( queryset=ShoppingSession.objects.all, many=False) class Meta: model = CreditPayment exclude = ['last_update'] and the model is class CreditPayment(models.Model): session = models.ForeignKey('shops.ShoppingSession', on_delete=models.PROTECT) name = models.CharField(max_length=50, default = 'none') number = models.CharField(max_length=15, blank=False) email = models.CharField(max_length=40, blank=True) amount_payed = models.IntegerField(blank=False) total_shopping = models.IntegerField(blank=False) amount_remaining = models.IntegerField(blank=False) date_payment_expected = models.DateField(blank=False) last_update = models.DateField(auto_now=True) def __str__(self): return self.name The viewset that is used to perform the creation of an instance of the model is: class CreditPaymentView(viewsets.ModelViewSet): permission_classes = [IsAuthenticated] queryset = CreditPayment.objects.all() serializer_class = CreditPaymentSerializer def create(self, request, *args, **kwargs): serializer = self.get_serializer(data=request.data) serializer.is_valid(raise_exception=True) self.perform_create(serializer) headers = self.get_success_headers(serializer.data) res = { "message": "Details Successfully created" } return Response(res, status=status.HTTP_201_CREATED, headers=headers) I cannot tell what is the wrong with the view,once i try to make a post request i get an error. With the error stack looking as follows Traceback (most recent call last): File "/home/sean/anaconda3/envs/skakey/lib/python3.8/site-packages/django/core/handlers/exception.py", line 47, in inner response = get_response(request) File "/home/sean/anaconda3/envs/skakey/lib/python3.8/site-packages/django/core/handlers/base.py", line 181, in _get_response response = wrapped_callback(request, *callback_args, … -
Wildcard url in Django using re_path
As per Django documentation ,below url pattern will work for http://127.0.0.1:8000/index . But I want also to make it work for http://127.0.0.1:8000/api/index/ http://127.0.0.1:8000/api/json/index/ from django.urls import include, re_path urlpatterns = [ re_path(r'^index/$', views.index, name='index'), ... ] How we can achieve it using re_path -
How to get HTML from Jquery form builder and store it in database
Iam bulding a survey website,where the user can create their own forms.My project contains 2 side , create-form where the surveyer can create the form and user side where they can fill the form , and i am using django on both sides. For starters iam using jquery form builder: <div id="fb-editor"></div> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"> </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"> </script> <script src="https://formbuilder.online/assets/js/form-builder.min.js"></script> <script> jQuery(function($) { $(document.getElementById('fb-editor')).formBuilder(); }); </script> My plan is to take the HTML code of the generated form and store it in a database, like firebase and then re-generate the form on user-side.So i need help on how to extract the HTML of the generated form and Is it the right way to do this thing or Is there any alternative "Django" way on doing this thing. -
An error occurred during deploying code to amazon-elastic-beanstalk.error is execution of command [app-deploy] - [PreBuildEbExtension]
option_settings: aws:elasticbeanstalk:application:environment: DJANGO_SETTINGS_MODULE: eagle_eye.settings aws:elasticbeanstalk:container:python: WSGIPath: eagle_eye/wsgi.py -
How to pass two arguments in a url with (?P<pk>\d+)$'
In the code below referring to django's urls.py file, I'm passing the pk as an argument in the url: url(r'^data/edit_item/(?P<pk>\d+)$', edit_data, name="edit_data") I want to know if there is a way to pass two arguments in this kind of regular expression. I've tried several ways like: url(r'^data/edit_item/(?P<pk>\d+)$&header', edit_data, name="edit_data") but I'm having a lot of trouble getting the right format. The url is being called directly in the html: {% if header|lower == "specie" %} <a href="{% url 'edit_data' item.pk %}" role="button" aria-pressed="true" > Edit</a> {% endif %} So I need to pass the argument header in the html as well: {% if header|lower == "specie" %} <a href="{% url 'edit_data' item.pk header %}" role="button" aria-pressed="true" > Edit</a> {% endif %} -
Site with different authentication for site students and staff in Django?
I am trying to create a Django web app with two types of users, Students and Staff. The problem is Students must login with their full name and id number (where name is non-unique, and id number operates as password), but I do not believe there is a way for Django to allow name to be non-unique (USERNAME_FIELD constant must be unique). Staff have a different login, they can login with regular username and password (username must be unique). Also, because there are two types of users, I do not know what to put for the AUTH_USER_MODEL constant in settings.py, since there can only be one model for this. What is the best way to set up the app without running into these problems? -
How to speed up BeautifulSoup for loop
I have a for loop that parses through 6 urls to get the text of the first class with "GARawf". The loop works however I've noticed that it now takes the page about 9 seconds to load compared to 1 second before. As I am new to Django and BeautifulSoup I was wondering if there was a way I could refactor the code so it loads the view faster. views.py # create list of cities city_list = ["Toronto", "Montreal", "Calgary", "Edmonton", "Vancouver", "Quebec"] # create price list prices_list = [] # set origin for flight origin = "Madrid" #origin_urllib = urllib.parse.quote_plus(origin) # set headers headers = { "User-Agent": "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36" } for i in city_list: # set destination for flight destination = i # set search query url = "https://google.com/search?q=" + origin + " to " + destination + " Google Flights" response = requests.get(url, headers=headers) soup = BeautifulSoup(response.text, 'lxml') # get price element prices = soup.find("span", attrs={"class": "GARawf"}) if prices != None: prices_list.append(prices.text.strip()) else: prices_list.append("Not Available") -
Issue with Auth0/Nginx/Django redirect after login with Nginx Proxy
I am using nginx as a proxy to pass to my django app container. I can successfully access the main url but when it passes control back to the django app and logins in the django app container gives it the local url and it doesn't route back to the correct page. The redirect uri comes in as http://app site-enabled upstream app{ server 0.0.0.0:8888; } server { listen 8080; server_name app-dev.company.net; location / { # django running in uWSGI proxy_pass http://app; include uwsgi_params; uwsgi_read_timeout 300s; client_max_body_size 320m; sendfile on; proxy_read_timeout 1800; proxy_connect_timeout 1800; proxy_send_timeout 1800; send_timeout 1800; } } docker-compose.yml version: "3.9" services: app: image: ecr/app container_name: django_app ports: - 8888 env_file: - dev.env volumes: - staticfiles:/opt/app/static/ nginx: build: ./nginx container_name: django_app volumes: - staticfiles:/opt/app/static/ ports: - 8080:8080 depends_on: - app volumes: staticfiles: -
ModuleNotFoundError: No module named 'dj_rest_auth'
I don't get why I am getting this problem I followed most the steps to the guide in installing: https://dj-rest-auth.readthedocs.io/en/latest/installation.html Except that I used pipenv install. However, python manage.py migrate gave me this error: main() File "/home/ryan/Documents/is4103/is4103-capstone-id01/Backend/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/ryan/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line utility.execute() File "/home/ryan/.local/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute django.setup() File "/home/ryan/.local/lib/python3.9/site-packages/django/__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/ryan/.local/lib/python3.9/site-packages/django/apps/registry.py", line 91, in populate app_config = AppConfig.create(entry) File "/home/ryan/.local/lib/python3.9/site-packages/django/apps/config.py", line 223, in create import_module(entry) File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1030, in _gcd_import File "<frozen importlib._bootstrap>", line 1007, in _find_and_load File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked ModuleNotFoundError: No module named 'dj_rest_auth' settings.py 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'BackendApp', 'rest_framework', 'rest_framework.authtoken', 'dj_rest_auth', ] Pipfile [[source]] url = "https://pypi.org/simple" verify_ssl = true name = "pypi" [packages] requests = "*" django = "*" psycopg2-binary = "*" django-polymorphic = "*" pillow = "*" djangorestframework = "*" markdown = "*" django-filter = "*" dj-rest-auth = "*" [dev-packages] [requires] python_version = "3.9" -
Serving Django static and media files using Docker and Nginx
I have a system which I am trying to Dockerize and set up a CI/CD pipeline for but it is not serving static or media files in production (does on local). The production docker-compose file looks as such: version: "3.8" services: backend: build: context: ./backend dockerfile: Dockerfile.prod image: "${BACKEND_IMAGE}" volumes: - static_volume:/backend/assets - media_volume:/backend/media expose: - 8000 env_file: .env depends_on: - db nginx: build: context: ./nginx dockerfile: Dockerfile.prod image: "${NGINX_IMAGE}" restart: unless-stopped ports: - 80:80 - 443:443 volumes: - ./nginx/certbot/conf:/etc/letsencrypt - ./nginx/certbot/www:/var/www/certbot - static_volume:/backend/assets - media_volume:/backend/media depends_on: - backend - db volumes: static_volume: media_volume: nginx.prod.conf: upstream backend { server backend:8000; } server { listen 80; listen [::]:80; location / { proxy_pass http://backend; proxy_set_header Host $http_host; } location /api/ { proxy_pass http://backend; proxy_set_header Host $http_host; } location /admin/ { proxy_pass http://backend; proxy_set_header Host $http_host; } location /static/ { alias /backend/assets/; } location /media/ { alias /backend/media/; } } Django settings.py: STATIC_DIR = os.path.join(BASE_DIR, 'static') STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'assets/') STATICFILES_DIRS = [STATIC_DIR, ] MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') MEDIA_URL = '/media/' I am getting a 404 Not Found for both static and media files. Help on identifying what I am doing wrong would be appreciated... -
ZoneInfoNotFoundError: 'No time zone found with key utc'
While trying to load my webpage on the browser, I got the message. A server error occurred. Please contact the administrator and when I go back to check my termimal, I see the message zoneinfo._common.ZoneInfoNotFoundError: 'No time zone found with key UTC' I have checked but don't know what's wrong. I even tried changing the UTC to my original timezone, but it still didn't work. P.S: I started getting this error after I tried working on templates inheritance Here's what my settings.py file looks like INSTALLED_APPS = [ 'newapp.apps.NewappConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', ] 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', ] ROOT_URLCONF = 'new.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', ], }, }, ] WSGI_APPLICATION = 'new.wsgi.application' # Database # https://docs.djangoproject.com/en/4.0/ref/settings/#databases DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': BASE_DIR / 'db.sqlite3', } } # Password validation # https://docs.djangoproject.com/en/4.0/ref/settings/#auth-password-validators AUTH_PASSWORD_VALIDATORS = [ { 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', }, { 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator', }, { 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator', }, { 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator', }, ] # Internationalization # https://docs.djangoproject.com/en/4.0/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # … -
Trying to run a django project and getting errors
So I am about to start working on a project with Python Django (never worked with these before). However, before starting I want to run the application. My manager gave me the files on which I should be working and there is the manage.py file already created. Now I have installed Python, pip and django and am trying to run this with the command python manage.py runserver And I get this long error which I am not sure what is all about considering that this whole project is already working on the computer of my manager and is even uploaded to a host. Watching for file changes with StatReloader Exception in thread django-main-thread: Traceback (most recent call last): File "C:\Program Files\Python310\lib\threading.py", line 1009, in _bootstrap_inner self.run() File "C:\Program Files\Python310\lib\threading.py", line 946, in run self._target(*self._args, **self._kwargs) File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\core\management\commands\runserver.py", line 115, in inner_run autoreload.raise_last_exception() File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception raise _exception[1] File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\core\management\__init__.py", line 381, in execute autoreload.check_errors(django.setup)() File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\utils\autoreload.py", line 64, in wrapper fn(*args, **kwargs) File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\__init__.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\apps\registry.py", line 91, in populate app_config = AppConfig.create(entry) File "C:\Users\Admin\AppData\Roaming\Python\Python310\site-packages\django\apps\config.py", line 223, in create import_module(entry) File "C:\Program Files\Python310\lib\importlib\__init__.py", line … -
Unkown string showing up on rendered HTML page
A random string "b b b b b" gets inserted between two HTML components which doesn't exist in my code to begin with. I currently have a js script to find this garbage string and just remove it manually. Was wondering if anyone knew why this was happening so I could actually fix it instead of this workaround This is how the relevant part of the code looks on my local machine (look at the start of the table tag) - <div class="row"> <div class="col-1"></div> <div class="col-10"> <div class="row answers"> <table class="part2"> <thead> <tr> <th></th> </tr> </thead> <tbody> <tr> <td>1. {{form.question_1.label_tag}}</td> {% for choice in form.question_1 %} <td><span class="radio">{{ choice.tag }}</span></td> {% endfor %} </tr> </tbody> </table> </div> </div> <div class="col-1"></div> </div> This is how the rendered HTML Code looks. I copied this from the browser inspect element (Notice how the random b \n b \n b\n is inserted right before the table tag without it being in the code)- <div class="row answers"> b b b b b b <table class="part2"> <thead> <tr> <th></th> </tr> </thead> <tbody> <tr> <td>1. <label>When this student is feeling happy, they can control their happiness.</label></td> </tr> </tbody> </table> </div> This is a Python-Django project being … -
Django raw SQL as Models
I'm working on a project where some database queries are complex enough to need raw SQL. How to organise these queries? Most advice seems to be to put them in a view but I would like them implemented as Models to support reuse. I want to be able to call them: Model.objects.all() in any view that needs them. I have seen some stuff where a custom Manager is added to an existing model but some of the queries don't touch any database tables that are implemented as Models so it is not obvious which model to add the custom Manager to. What I would like is to set up a library of these queries and pull them into views as needed. Is there a Django approach that I should employ for this? TIA -
Have only hours and minutes in durationfield Django
I would like to have a duration field expressed just as hours and minutes. I post you my code: views.py log_entry = LogEntry.objects.filter(Q(date__range=[start_date, end_date]) & Q( student_id__id__icontains=student) & Q(instructor_id__id__icontains=instructor) & Q(aircraft_id__id__icontains=aircraft)) total_flight_hours = log_entry_dual.aggregate(eet=Sum(ExpressionWrapper( F('ata') - F('etd'), output_field=IntegerField()), output_field=DurationField()))['eet'] Now, total_flight_hours is printed in my template as (for example) 03:00:00 which states for 3 hours. Since I just need hours and minutes and I don't care about seconds, is there a way to get rid of the seconds? Thank you very much in advance -
Django: How i can make space or makethe things go to the next line if needed in the view.py
I have did some calculation on 2 fields and then i want to display the result recursively Here is the Django code View: @login_required def calcul_resultat(request): resultat = Decimal(0) charge_per = request.POST.get('charge_per', False) charge_exp = request.POST.get('charge_exp', False) calcul="" if not (charge_per): return HttpResponse({"result" :resultat}) else: float_charge_per = float(charge_per) resultat = 1.5 * float_charge_per calcul += "calculation of deadweight" calcul += " " calcul += str(resultat) float_charge_exp = float(charge_exp) resultat = 1.35 * float_charge_exp calcul += " " calcul += "calculation of operating load" calcul += " " calcul += str(resultat) return render(request,'pages/result.html',{'calcul':calcul}) when i press the button calculate , here is the result in the picture , it seems that the(br tag) ""it doesn't work enter image description here How i can resolve that is there any example can help me.Thanks to make space in django if needed -
Get Spotify access token with spotipy on Django and Python
I'm new to Django and I'm trying to link Spotify to my webapp. I'm using Spotify to do it and it correctly access to Spotify. To do it I have a button that opens the view below views.py @authenticated_user def spotify_login(request): sp_auth = SpotifyOAuth(client_id=str(os.getenv('SPOTIPY_CLIENT_ID')), client_secret=str(os.getenv('SPOTIPY_CLIENT_SECRET')), redirect_uri="http://127.0.0.1:8000/", scope="user-library-read") redirect_url = sp_auth.get_authorize_url() auth_token = sp_auth.get_access_token() print(auth_token) print("----- this is the AUTH_TOKEN url -------", auth_token) return HttpResponseRedirect(redirect_url) If I don't use auth_token = sp_auth.get_access_token() everything works fine and I got redirected to the correct. Unfortunately, if I add that line of code to access the access token, instead of staying on the same page, it opens another tab on the browser with the Spotify auth_code and lets the original page load forever. Is there a way to retrieve the access token in the background without making my view reload or open another tab in the browser? -
How to get only selected items from admin CheckboxSelectMultiple Django
I am trying to display only selected participants from admin panel but ending up getting all of them. My admin panel looks like this: These are the team captains so when they are joining the tournament the template shows their team my template looks like this: {% for team in teams %} {% for player in tournament.participants.all %} {% for member in team.members.all %} {{ member.username }} {% endfor %} {% endfor %} {% endfor %} And admin.py class TournamentAdminForm(ModelForm): class Meta: model = Tournament fields = '__all__' widgets = { "participants": CheckboxSelectMultiple(), "broadcast_talents": CheckboxSelectMultiple(), } -
Maintain Two Types Of User
So I have a requirement where I have to maintain two types of users. A company and all of its users, to manage day-to-day work. And also create public data like showing a few items and related images and set availability for meetings and more. Public user who can see the items, images. and can book the meetings. Now for the first case, every user is created by official email and password as registeruser endpoint from rest-framework. there is user profile and other company data. For the second type of user (public), I have to give access for social login as well as login by email/mobile (maybe). I am confused as how to configure this in the best possible way. the company datas' are important. Should I create both user types in the same database (differentiating by user types)? or should I use a seprerate database then how to fetch data from two databases (never done this)? Also to keep my datas safe from unauthorized access. Or is there a better way to manage all of my requirements which I'm totally unaware of? Like a better approach. Looking for an explanation from an experienced person. Thanks -
Access Json data key name
I want to get data with request.data.columns in frontend.I can do it with ViewSet with list method but how to do it with generics.APIVIEW. Below is my viewsets and generics code: class TestList(viewsets.ViewSet): queryset = Test.objects.all() def list(self,request): serializer = TestSerializer(self.queryset, many = True) return Response({'columns': serializer.data}) class TestList(generics.RetriveAPIView): queryset = Test.objects.all() serializer_class = TestSerializer -
django and react, simplest way to integrate
I have a react app created using "create-react-app" that I would like to connect to a backend, now due to the fact I already use django and like how it simplifies many of the redundant tasks, I chose it as my backend. In many articles the recommended way of using it is using django_rest_framework and making api calls from the react app, I neglected a very important point here as I thought I could have django serve the simple static pages and use react only for the js heavy tasks (which in my case is only one page and the main point of the website). my questions are, can I keep user logged in if he navigates from the simple html pages to the app (in case they live on separate servers) ? If not possible how can I integrate a create-react-app project with django ? -
Is it possible to have flexible decimal_places for a model in django?
I am working in a model that i would like to use for diferent kinds of investmensts. So i am wondering if is it possíble to have flexible decimals. For example: This is the class class Asset(models.Model): portfolio = models.ForeignKey(Portfolio, on_delete=models.CASCADE, default=1) category = models.ForeignKey(Category, on_delete=models.CASCADE) shares_amount = models.DecimalField(max_digits=18, decimal_places=0, default=0) If i leave it blank i get the error: "DecimalFields must define a 'decimal_places' attribute." Maybe what i am trying is not possíble, probably i need to find another solution. I would like to know if is possíble to have this decimal places fleixible. Something like: shares_amount = models.DecimalField(max_digits=18, decimal_places=x) if category == cryptocurrency x=18 else x=0 -
Need help running an existing django project on a new machine
Im just starting to do some work with an already existing python django project. I just installed python in my machine and Im trying to figure out how to install django and as I see I am supposed to use pip for this. However, in all tutorials people are firstly creating a virtual environment for it. Now my question is since the project already exists do I need to create a virtual environment from scratch? I can see that there is already a env folder which includes bin and lib folders. Can I somehow use this environment? And if so are there some specific commands for that? I am on windows by the way. -
Django - Pass a dropdown Item value from the template to the view
I have a Django template that looks like this <td>{{ row.column1 }}</td> <td>{{ row.column2 }}</td> <td>{{ row.column3 }}</td> <td> <select name="dropdown_menu_option" id="dropdown_menu_option"> <option selected="selected" disabled>--SELECT--</option> <option value="10">10</option> <option value="50">50</option> <option value="100">100</option> <option value="256">256</option> <option value="512">512</option> <option value="1">1</option> </select> </td> <td><a href="{% url 'exampleurl' row.column1 row.column2 row.column3 dropdown_menu_option %}" class="action-button-small shadow animate grey">Take Action</a></td> I have my URLs set up like this - url(r'exampleurl/(?P<column1>.+)/(?P<column2>.+)/(?P<column3>.+)/(?P<dropdownvalue>)$', viewName, name='exampleurl'), My view is set up like this - def viewName(request, directory, column1, column2, column3, dropdownvalue): print(column1) print(column2) print(column3) print(dropdownvalue) The problem I am having is, dropdownvalue is NULL. This is one of the reasons I have removed the regex from the URL.py file for dropdownvalue. How do I pass this value from my template to the view? -
Formtools does not display my formsets, only the forms
hi i am using formtools to submit a multistep form. The problem is that I haven't found many tutorials about it. And it is that I was able to create the form but the formset does not appear. What am I doing wrong or what am I missing? if I stopped using formtools if the formset is seen but not with formtools, I think that I am not generating the view correctly so that it displays the formset and saves the data throughout the multi step form views.py class PresupuestoWizardView(SessionWizardView): file_storage = FileSystemStorage(location=os.path.join(settings.MEDIA_ROOT, 'files')) form_list = [PresupuestosClientesForm, PresupuestosVehiculosForm,PresupuestosParteForm,PresupuestosManoObraForm,PresupuestosPagosForm,PresupuestosFotosForm] template_name = "Presupuestos/new-customer.html" def done(self, form_list, **kwargs): return render(self.request, "Presupuestos/new-customer.html", { 'form_data': [form.cleaned_data for form in form_list], }) forms.py ParteFormSet = formset_factory(PresupuestosParteForm, extra=extra_forms, max_num=20) ManoObraFormSet = formset_factory(PresupuestosManoObraForm, extra=extra_forms, max_num=20) PagosFormSet = formset_factory(PresupuestosPagosForm, extra=extra_forms, max_num=20) extra_forms = 1 DESCUENTO = ( ('Quantity', 'Quantity'), ('Percentage', 'Percentage'), ) DISCOUNT= ( ('Quantity', 'Quantity'), ('Percentage', 'Percentage'), ) class PresupuestosClientesForm(forms.ModelForm): class Meta: model = Clientes fields = '__all__' widgets = { 'titulo': forms.Select( attrs={ 'class': 'form-select' } ), 'nombre': forms.TextInput( attrs={ 'class': 'form-control' } ), 'apellido': forms.TextInput( attrs={ 'class': 'form-control' } ), 'correo': forms.EmailInput( attrs={ 'class': 'form-control' } ), 'telefono': forms.TextInput( attrs={ 'class': 'form-control' } ), 'tel': forms.TextInput( …