Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Can we use post_save signals in apps.py?
There. I'm using django python. I've custom user model. I've created a separate django signals file. there is my method. I'm importing them in my apps.py and wanting to use there. cause, post_migrate signals are working that way. but post_save is different cause that takes model. whereas postmigrate are working with app name. You better understand with following code. signals.py import secrets from django.core.mail import send_mail def create_first_account(sender, **kwargs): if sender.name == 'accounts': user = User.objects.get_user_by_username("meidan") if user: return None password = secrets.token_hex(4) user = User.objects.create( username="meidan", email="meidanpk@gmail.com", password=password ) user.is_active= True User.objects.save_me(user) subject = 'Meidan Account' message = password from_email = settings.EMAIL_HOST_USER recipient_list = ['ahmedyasin1947@gmail.com'] send_mail(subject, message, from_email, recipient_list, fail_silently=False) def create_first_account(sender,created, **kwargs): if sender.name == 'accounts': print(created) apps.py from django.apps import AppConfig from django.db.models.signals import post_migrate,post_save from django.contrib.auth import get_user_model User = get_user_model() class AccountsConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' name = 'accounts' def ready(self): from accounts.signals import generate_banks,create_first_account,create_first_account post_migrate.connect(generate_banks, sender=self) post_migrate.connect(create_first_account, sender=self) post_save.connect(create_first_account,sender=User) right now getting error. File "/home/aa/playapp-backend/envMy/lib/python3.10/site-packages/django/apps/registry.py", line 201, in get_model self.check_apps_ready() File "/home/aa/playapp-backend/envMy/lib/python3.10/site-packages/django/apps/registry.py", line 136, in check_apps_ready raise AppRegistryNotReady("Apps aren't loaded yet.") django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet. -
How to show request body using django rest framework and drf_spectacular in function based views
I have the following problem, which has been difficult for me to find documentation on function-based views to document them with drf_spectacular since all this is found for class-based views I have tried different ways to document the requestBody in swagger using serializers_class, manual objects, inline_serializers but all this without any success, here I leave a fragment of my code and a screenshot of how it should be and where should I be @extend_schema( summary="Fetch order information", description="This endpoint filter orders based on the provided parameters.", tags=["orders"], request=OrderInfoParamsSerializer, # HERE IS MY PROBLEM responses={ 200: OrderInfoSerializer(many=True), }, ) @extend_schema(request=None) @api_view(["GET"]) @token_required def order_info(request: Request) -> Response: params = OrderInfoParamsSerializer(data=request.data) if not params.is_valid(): return Response({"error": params.errors}, status=status.HTTP_400_BAD_REQUEST) params = params.validated_data ... class OrderInfoParamsSerializer(serializers.Serializer): order_id = serializers.IntegerField( required=False, allow_null=True, help_text="Filter by order ID" ) class OrderInfoSerializer(serializers.ModelSerializer): class Meta: model = Orders fields = "__all__" I tried to migrate the views to those based on classes where it only worked with one in the POST method not with the GET (I could migrate all my views if this worked) I didn't want to have to refactor the entire project and would like to be able to find some solution that works for function-based … -
Generate SQL joins from list of Django models
Given a list of arbitrary Django models, how can you use the Django ORM to generate the JOIN statements for an SQL query? This of course will only work if the relationships are defined in the model and there is a way to get from one model to another. The supplied list would not necessary contain models that are directly related to each other. I am trying to manually generate an SQL query given a list of models and I would like to leverage the already defined model relationships and the ORM to do this. It must be possible, the ORM already does this when using filters, select_related etc. -
use ajax with django
I already created an animation in dom for the login and registration but the only thing I need is to validate the registration and I already have the registration with django but I need it to show me the error if something happens with ajax and not restart the page or anything for that matter but in real time, this is the django code in views.py: def registrar_usuario(request): if request.method != "POST": return render(request, "./login.html") else: if "cancelar" in request.POST: #no hace nada de momento return print("aca se pondra la animacion para que vuelva a login") try: #datos requeridos, haciendolos obligatorios required_fields= ["email_usuario", "nombre_usuario", "fecha_nacimiento", "password"] #despues de esto hay que generar un mensaje de error en caso de que falten campos, pero se debe hacer con javascript for field in required_fields: if not request.POST.get(field): print("todos los campos son necesarios") return redirect("./login.html") #cuando se configure javascript este mensaje puede ser borrado ya que javascript debe hacer el mensaje, sin embargo debe ir de la mano con este fragmento de codigo django #verifica que el usuario no este creado email_usuario= request.POST["email_usuario"] if Registro.objects.filter(email_usuario=email_usuario).exists(): #aca tambien debe ir un codigo javascript de la mano con django print(f"El email {email_usuario} ya existe!") return … -
Django local server doesn't update web site with the new data from the database
CRUD operations are working just fine when I check the admins site. All of the new created items, updated or deleted are shown in the admins site, but in order to make the data appear in the website I have to restart my local server what's the problem I'm working with python 3.11.9 -
Sending email Django with mailtrap
Hi I finished making my contact form but it doesn't let me send email, I'm using mailtrap as a test server but I get an error. I'm using Django 5.0 and Python 3.10 Settings.py # Email config EMAIL_HOST = 'sandbox.smtp.mailtrap.io' EMAIL_HOST_USER = '811387a3996524' EMAIL_HOST_PASSWORD = '********6d43' EMAIL_PORT = '2525' Error message SMTPServerDisconnected at /contact/ Connection unexpectedly closed Request Method: POST Request URL: http://127.0.0.1:8000/contact/ Django Version: 5.0.4 Exception Type: SMTPServerDisconnected Exception Value: Connection unexpectedly closed Exception Location: /usr/lib/python3.10/smtplib.py, line 405, in getreply Raised during: contact.views.contact Python Executable: /home/andres/.local/share/virtualenvs/CursoDjango-IwbI9JP5/bin/python Python Version: 3.10.12 Python Path: ['/home/andres/Escritorio/CursoDjango/webempresa', '/usr/lib/python310.zip', '/usr/lib/python3.10', '/usr/lib/python3.10/lib-dynload', '/home/andres/.local/share/virtualenvs/CursoDjango-IwbI9JP5/lib/python3.10/site-packages'] Server time: Fri, 17 May 2024 22:26:46 +0000 -
Is there a way to insert a default field to each user's 'wincon' model or lock the form field to a value based on another form field?
I am building a game tracker. I would like to have it where if the user selects anything other than 'Win' then the wincon field of the form is unchangeable or set to a default field. This is to make it easier to understand that when they don't win they shouldn't add a wincon. It would also be nice if the user had a blank field that if they didn't want to input a wincon then it would default to '------' Ideally if it is a win then the wincon field would be able to be changed. But if a loss is selected then the form defaults to null or a prepopulated field like '------' models.py class Profile(models.Model): user = models.ForeignKey(User, max_length=10, on_delete=models.CASCADE, null=True) def __str__(self): return str(self.user) class Wincon(models.Model): wincon = models.CharField(max_length=100,) user = models.ForeignKey(User, max_length=10, on_delete=models.CASCADE, null=True) def __str__(self): return self.wincon class Game(models.Model): # ForeignKeys user = models.ForeignKey(User, max_length=10, on_delete=models.CASCADE, null=True) wincon = models.ForeignKey(Wincon, on_delete=models.CASCADE, null=True, blank=True,) views.py @login_required(login_url='my-login') def wincon(request): wincon_list = Wincon.objects.filter(user=request.user) user = User.objects.get(username=request.user) if request.method == "POST": wincon_form = WinconForm(request.POST) if wincon_form.is_valid(): obj = wincon_form.save(commit=False) obj.user = request.user obj.save() return HttpResponseRedirect('/wincon') else: wincon_form = WinconForm() context = {'wincon_form': wincon_form, 'wincon_list': wincon_list, 'user': user} return … -
Django and IIS (wfastcgi.py, httpPlatform or ...)
I need to run next some years Django on IIS (don't ask why :-). I found two ways https://learn.microsoft.com/en-us/visualstudio/python/configure-web-apps-for-iis-windows?view=vs-2022 1. httpPlatform + runserver wsgi.multithread:True wsgi.multiprocess:False The solution is multithreaded, working almost well, low resources, good performance. 2*5 processes can solve something like 1500req/second. But: IIS server returns "HTTP Error 502: Bad Gateway" sometimes during app poll recycle. Not so often, but... Django runserver documentation says in big letters: "DO NOT USE THIS SERVER IN A PRODUCTION SETTING" some sites said "HttpPlatformHandler has been replaced by ASP.NET Core Module" And HttpPlatformHandler is not a part of IIS. 2. fastCGI + wfastcgi wsgi.multithread:False wsgi.multiprocess:True This solution is a single threaded, working well, with no error, even if recycle or hi load occurs. But consume high resources: 1500req = 1500 running processes, 100GB of memory for almost none. Big amount of running processes means big system heap consumptions, load global variables, resources, imports ... again and again. Some sites say, of course: "wfastcgi is essentially deprecated ..." So - is there an effective and reliable way to run Django under IIS, which will last over some Windows versions from 2019, 2022 and next few at least 5-10 years? Is there some port from … -
Is it possible customize drf api root and grappeli in a Django Project?
I am using Django Rest Framework and Grappelli in my Django project. I need to add a cookie consent notice. Is it possible to customize both to show the notice? Do I need to create a new template? -
Django form submission not redirecting to success page and the post request is not being done
I'm encountering an issue with Django where form submission is not redirecting to the success page as expected and the data input its not happening . Here's a breakdown of the problem: I have a Django application where users can book rooms using a form. Upon successful submission of the form, the user should be redirected to a "booking success" page. However, after submitting the form, the page remains unchanged, and there's no redirection happening.Yes need authentication for book it . **this is my views.py ** `def book_room(request): if request.method == 'POST': form = BookingForm(request.POST) if form.is_valid(): form.save_booking() return redirect('booking_success') else: form = BookingForm() return render(request, 'bookings/appbooking.html', {'form': form})` my urls `from . import views from django.urls import path urlpatterns = [ path('', views.index, name='bookings'), path('booking_success/', views.booking_success, name='booking_success'), path('book_room/', views.book_room, name='book_room'), ` -
Docker compose enter debug mode upon breakpoint while dropping stdout from web server
Have a question on using docker-compose when entering into debug mode by manually setting breakpoint(). This is my service and it has a /health which calls almost every 5s, and it prints out 200 status code to stdout. However, when using docker attach <container_id> to enter into the container, as it hits a breakpoint, it is interlaced with the (pdb) debugger. Is there a way to redirect these stdout from /health temporarily to not "bother" the debugger session? -
Displaying an image doesn't work Django python
So this is my views.py when I use atrakcjatest my images work, but when I try to use the filtered atrakcja(atrakcje_list) it doesnt work and only images dont work, the rest of variables are ok def map_view(request, trasa_id): trasa = get_object_or_404(Trasa, id_trasy=trasa_id) trasa_atrakcje = Trasa_a_atrakcja.objects.filter(id_trasy=trasa_id) atrakcje = Atrakcja.objects.filter(id_atrakcji__in=[ta.id_atrakcji for ta in trasa_atrakcje]) atrakcje_list = list(atrakcje.values('id_atrakcji', 'nazwa', 'kategoria_id', 'latitude', 'longitude', 'czas_zwiedzania', 'opis', 'miasto_id', 'cena', 'zdjecie_jpeg')) atrakcje_json = json.dumps(atrakcje_list) atrakcjatest = Atrakcja.objects.all() return render(request, 'map.html', {'atrakcje': atrakcje_json, 'trasa': trasa, 'atrakcje_list': atrakcje_list, 'atrakcjatest': atrakcjatest}) I dont understand this bug because when I use objects.all() everything works and also It's kinda strange that the only thing which doesnt work is Image, I tested the url in a tag and there is an empty string -
I want to deploy my django project on render but it show not build wheels for dlib
I want to deploy my django project which is face recognition for online transaction on render but it show ERROR: Could not build wheels for dlib, which is required to install pyproject.toml-based projects how could i resolve this ? i try install dilib in local server according to latest python version but notable to deploy please give me insights to reslove this problem -
Django Graphene GraphQL customize Error messages
In my Django app with Graphene for GraphQL, how do I intercept the Graphene GraphQL messages so I can sanitize the content? I tried creating a custom graphql view and a custom_execute function and using that in the urlpatterns endpoint definition: class CustomGraphQLView(GraphQLView): def execute_graphql_request(self, request, data, query, variables, operation_name, show_graphiql=False): document = parse(query) result = custom_execute(self.schema, document, root_value=request, variable_values=variables, operation_name=operation_name) return result def custom_execute(schema, document, root_value=None, variable_values=None, operation_name=None, context_value=None): # Execute the query try: result = execute( schema=schema, document=document, root_value=root_value, context_value=context_value, variable_values=variable_values, operation_name=operation_name ) if isinstance(result, ExecutionResult): if result.errors: modified_errors = [GraphQLError("Custom error handling message") for error in result.errors] result.errors = modified_errors return result except Exception as e: return ExecutionResult(data=None, errors=[GraphQLError('test'), GraphQLError(str(e))]) urlpatterns = [ path('graphql', CustomGraphQLView.as_view(graphiql=not IS_PROD)), ] Inside the execute function in my custom_execute function, I get the error: "Expected <Schema instance> to be a GraphQL schema." I have verified that the schema object is of type <class 'graphene.types.schema.Schema'>. How do I fix this error. Is this even the recommended way to customize the error messages generated by graphql? -
Django View Not Returning 404 as Expected When Form is Submitted
I'm facing a strange issue with Django. I have set up a simple form in a template that submits to a view, but I'm not getting the expected 404 response. Instead, I'm being redirected to the URL http://localhost:8000/clear/ without seeing the 404 error. Here is my setup: Template: <form method="post" action="{% url 'clear_chat' %}"> {% csrf_token %} <button type="submit" class="btn btn-danger clear-button me-2"> Clear Chat </button> </form> View: from django.http import HttpResponse from django.contrib.auth.decorators import login_required @login_required def clear_chat(request): return HttpResponse("Invalid request method.", status=404) Urls: from django.urls import path from .views import clear_chat urlpatterns = [ path('clear/', clear_chat, name='clear_chat'), ] Instead of seeing the 404 response, I'm redirected to the URL http://localhost:8000/clear/ without any error message. I have no clue what is wrong with that code. -
Deploying Django AI on Heroku
I'm having trouble uploading my Django web app to Heroku due to the Slug Size limit. My web app includes an AI API that requires a torch dependency. This is the error: Compressing... remote: ! Compiled slug size: 700M is too large (max is 500M). remote: ! See: http://devcenter.heroku.com/articles/slug-size remote: remote: ! Push failed In the requirements.txt I have already forced to install only torch+cpu, but I can't reduce the Slug Size by 200M. How can I solve it? -
django bulk update with batch in multiple transactions
I've a certain code that updates bulk rows: from simple_history.utils import bulk_update_with_history from simple_history.tests.models import Poll from django.utils.timezone import now objs = Poll.objects.all() for obj in objs: obj.question = 'Duplicate Questions' bulk_update_with_history(objs, Poll, ['question'], batch_size=5000) Now data here can be very huge and sometimes thousands of rows to update. This caused the database in lock:relation state for about 2-3 minutes. On dissecting the bulk_update_with_history method which belonged to a simple-history package, the doc string states that: def bulk_update_with_history( objs, model, fields, batch_size=None, default_user=None, default_change_reason=None, default_date=None, manager=None, ): """ Bulk update the objects specified by objs while also bulk creating their history (all in one transaction). :param objs: List of objs of type model to be updated :param model: Model class that should be updated :param fields: The fields that are updated :param batch_size: Number of objects that should be updated in each batch So the theory is that this particular function wraps all batch updates in a single transaction which is what caused the db to lock state. I want to know how batch_size works in bulk_update. Django doc states that: The batch_size parameter controls how many objects are saved in a single query. The default is to update all … -
How to pass on the chopped details from URL in Django?
I have a project with the following urls.py. urlpatterns = [ path('category*/', include('student.urls')) // * could be replaced by a number ] In that project I then have an application student whose urls.py looks like this: urlpatterns = [ path('all/', views.all, name='all') ] So lets say when I type in the URL category1/all/ I get the list of all Category 1 students, but when I do category2/all/ I should be able to get the list of all Category 2 students. So by the time I reach all/ I have lost for which category I want to retrieve the list of all students. How can I still know in my students application which category students data should be retrieved? -
How to take data from HTML Inputs and use them in a form?
I am trying to get the user's login and password from the HTML template (from ) and use these inputs for processing. I want to use the inputs from the HTML template and not the usual Django forms, like: <label class="form-label">Username</label> {{ form.username }} <span>{{ form.errors.username }}</span> This is a part of HTML tamplate: <form method="post"> {% csrf_token %} <div class="mb-[22px]"> <input type="username" placeholder="Username" class="w-full px-5 py-3 text-base transition bg-transparent border rounded-md outline-none border-stroke dark:border-dark-3 text-body-color dark:text-dark-6 placeholder:text-dark-6 focus:border-primary dark:focus:border-primary focus-visible:shadow-none" /> </div> <div class="mb-[22px]"> <input type="password" placeholder="Password" class="w-full px-5 py-3 text-base transition bg-transparent border rounded-md outline-none border-stroke dark:border-dark-3 text-body-color dark:text-dark-6 placeholder:text-dark-6 focus:border-primary dark:focus:border-primary focus-visible:shadow-none" /> </div> This is the class from forms.py: class LoginForm(AuthenticationForm): username = CharField( max_length=50, min_length=3, required=True, widget=TextInput(attrs={"class": "form-control"}), ) password = CharField( required=True, widget=PasswordInput(attrs={"class": "form-control"}), ) class Meta: model = User fields = ("username", "password") How can I properly pair these code elements? -
Deleting resource of a django model with foreign key
I have following django models : class ModelA(models.Model) : # fld1, fld2 class ModelB(models.Model) : fld_a1 = models.ForeignKey(ModelA, related_name='modela_1') fld_a2 = models.ForeignKey(ModelA, related_name='modela_2') # other fields Now when I delete resource from ModelB, how to make sure that the corresponding foreignkey objects from ModelA are also deleted -
Celery executes tasks sequentially, one after another
I have a Django application that has large I/O-bound tasks. I use Celery to run these tasks in threads and manage the progress in the UI with a progress bar. Here's my configuration : Django version : 5.0.2 Celery version : 5.3.6 Redis version : Redis for Windows 5.0.14.1 (https://github.com/tporadowski/redis/releases) SERVER Windows Server 2016 (can't change that; I have data stored in an Access Database) Hosting app in IIS default AppPool Processor : 4 core RAM : 4 GB web.config configuration : <?xml version="1.0" encoding="utf-8"?> <configuration> <system.webServer> <handlers> <add name="Python FastCGI" path="*" verb="*" modules="FastCgiModule" scriptProcessor="C:\Python311\python.exe|C:\Python311\Lib\site-packages\wfastcgi.py" resourceType="Unspecified" requireAccess="Script" /> </handlers> <directoryBrowse enabled="true" /> </system.webServer> <appSettings> <add key="PYTHONPATH" value="C:\inetpub\Django-LIAL\WEBAPPLIAL" /> <add key="WSGI_HANDLER" value="WEBAPPLIAL.wsgi.application" /> <add key="DJANGO_SETTINGS_MODULE" value="WEBAPPLIAL.settings" /> </appSettings> </configuration> Django wsgi configuration : from gevent import monkey monkey.patch_all() import os from django.core.wsgi import get_wsgi_application os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'WEBAPPLIAL.settings') application = get_wsgi_application() Django celery configuration : #Celery setting CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0' CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_BACKEND = 'django-db' CELERY_CACHE_BACKEND = 'django-cache' CELERY_TASK_ALWAYS_EAGER = False CELERY_TASK_TRACK_STARTED = True celery command line launched in git : $ celery -A WEBAPPLIAL worker -l info -P gevent *** what the celery command line do : *** -------------- celery@WIN-RHK2AHPNGJ1 v5.3.6 (emerald-rush) --- ***** ----- -- ******* ---- … -
How to fix CSRF TOKEN being overwritten with form data after submission failed in django?
I building a multitenants project using django-tenant and django-tenant-user but I am facing a weird issue where the CSRF TOKEN and email fields of my login form are being overwritten with the password data after a failed login attempt. Please view my relevate code snippets below: View def login_user(request): if request.user.is_authenticated: return redirect('core:index') if request.method != 'POST': form = LoginForm() return render(request, 'core/login.html', {'form': form}) form = LoginForm(request.POST) if not form.is_valid(): context = {"form": form} if not form.errors: messages.error(request, 'Invalid username or password') return render(request, 'core/login.html', context) user = authenticate(request, username=form.cleaned_data['username'], password=form.cleaned_data['password']) if user is None: messages.error(request, 'Invalid username or password.') return render(request, 'core/login.html', {'form': form}) messages.success(request, 'Login successful') login(request, user) return redirect('core:index') Form class LoginForm(forms.Form): username = forms.CharField(min_length=4, max_length=150) password = forms.CharField(min_length=4, max_length=128, widget=forms.PasswordInput) Template {% extends "_base.html" %} {% block title %} <title>TalwaPro HR Admin - Login </title> {% endblock title %} {% block content %} {% load tailwind_filters %} <div class="flex h-screen items-center justify-center"> <div class="card w-[90%] bg-base-200 shadow-xl justify-center md:w-[65%] lg:w-[40%]"> {% if messages %} <div class="toast toast-top toast-start"> <div class="alert alert-error"> {% for message in messages %} {{ message }} {% endfor %} </div> </div> {% endif %} <div class="card-body"> <h2 class="card-title text-accent justify-center">Sign In</h2> … -
Get User Information in Django
I have made a REST API using Django, and I have issues with retrieving a user's information by inserting a token. I am using the User model. So here is the view: `class getUserInfoView(APIView): #generics.RetrieveAPIView #authentication_classes = [authentication.TokenAuthentication] #authentication_classes = [jwt] #permission_classes = [permissions.IsAdminUser] #permission_classes = (AllowAny,) #queryset = User.objects.all() #serializer_class = UsersListSerializer#UserSerializer serializer_class = UserSerializer permission_classes = [IsAuthenticated] authentication_classes = [TokenAuthentication] def get(self, request): serializer = UserSerializer(data=request.user) user = request.user #return Response(UserSerializer(user).data) if serializer.is_valid(): user = jwt.get_user(token=serializer.validated_data['access_token']) if user: return Response({ 'id': user.id, 'username': user.username, 'email': user.email, }) return Response({'detail': 'Invalid credentials'}, status=status.HTTP_401_UNAUTHORIZED) return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)` Here's the serializer: `class UserSerializer(serializers.Serializer): #username = serializers.CharField(required=True) acess_token = serializers.UUIDField() class Meta: model = User fields = ["id", "username", "email"]` Here's the url: path('api/me/', getUserInfoView.as_view(), name='Personal-Information') The problem here is that when I run the server, I get the following: enter image description here I understand that the issue is in the view, can anyone explain what I am doing wrong? Thank you. I tried various View objects as argument for the class, did not work. -
Custom view on admin main page
I want to show some information on the admin index.html, but I do not want to use context processors for this, but have my own view. So I tried like described in the docs and discussed here. My app is called virtual, so I did: in virtual/admin.py: class VirtualAdminSite(admin.AdminSite): index_template = "virtual/admin_index.html" def index(self, request, extra_context=None): extra_context = extra_context or {} return super().index(request, extra_context) admin_site = VirtualAdminSite(name="virtualAdminSite") in virtual/apps.py: class VirtualAdminConfig(AdminConfig): default_site = "virtual.admin.VirtualAdminSite" in project/settings.py INSTALLED_APPS = ["virtual.apps.VirtualConfig", "virtual.apps.VirtualAdminConfig", ...] I then run in to the error: ImportError: Module "virtual.admin" does not define a "VirtualAdminSite" attribute/class If I use "django.contrib.admin" instead of virtual.apps.VirtualAdminConfig everything works just fine. so two questions: why does this error happen, I feel I copied that straight from the docs? I assumed I could add some variables in the VirtualAdminSite extra_context and show them in the index template by using {{ variable_name }} - is this correct? -
Django View called by View won't render
I have 2 views: def matching(request: HttpRequest) -> HttpResponse: context = Transaction.objects.order_by("-transaction_date").all() if request.method == 'POST': evidence_data = to_json(request.body) return render(request, "evidence/matching.html", {"transactions": context, "evidence_data": evidence_data }) return render(request, "evidence/matching.html", {"transactions": context}) def evidence(request: HttpRequest) -> HttpResponse: if request.method == 'POST': data = to_json(request.body) if data: return matching(request) context = TransactionEvidence.objects.order_by("-uploaded_at").all() return render(request, "evidence/evidence.html", {"evidence": context}) After the first view gets a post request, I want the other view to render with the transaction data and the data from the evidence view. The view is called, and the data is there and what I would expect, but in the browser, nothing is happening. What am I missing?