Putting two functions in one view/page

Hi all,

so i have an URL called:

path('overzichtzaken/', views.zaken, name='overzicht'),

The HTML is overzichtzaken.html:

{% extends 'base.html' %}
{% load static %}

<!DOCTYPE html>
{% block content %}

        <h1>Dit is het Dashboard</h1>
            <div class="zaakoverzicht">
                {%for zaak in zaakoverzicht%}
                    <div class="zaak">
                    <h2><a href="{% url 'detailzaak' zaak.id %}">{{ zaak.Registratienummer }}</a></h2>
                    <p>{{ zaak.Onderzoeksnaam }}</p>

                {% endfor %}

{% endblock %}

The view is:

def zaken(request):
   zaakoverzicht = get_list_or_404(Zaak)
   #zaakoverzicht = Zaak.objects.all().order_by('Created')
   return render(request, 'overzichtzaken.html', {'zaakoverzicht':zaakoverzicht})

At this point the ‘page’ only shows the cases (zaken) But in this ‘page’ i also want to build in the function to create a new case.
I have made a form in forms.py:

from django import forms
from . import models

class MaakZaak(forms.ModelForm):
    class Meta:
        model = models.Zaak
        fields = ['Registratienummer','Onderzoeksnaam']``` 

The models.py attached to this is: 
``` class Zaak(models.Model):
    Registratienummer = models.CharField(unique=True, max_length=10, help_text = ' Verplicht uniek 10 cijferig nummer invoeren', validators=[RegexValidator(r'^[0-9]{10}$')])
    Onderzoeksnaam = models.CharField(max_length=255, blank=False)
    Created = models.DateTimeField(auto_now_add=True)
    Aangemaakt_door = models.ForeignKey(User, on_delete=models.CASCADE, db_column='FK_Gebruiker')

    def __str__(self):
        return self.Onderzoeksnaam```

I have created another view for this 'creating function in views.py: 
```def testen(request):
   if request.method =='POST':
      form = forms.MaakZaak(request.POST)
      if form.is_valid():
         tijdelijk = form.save(commit=False)
         tijdelijk.Aangemaakt_door = request.user

         return redirect('overzicht')

      form = forms.MaakZaak()
   return render(request,"testen.html",{ 'form':form })```

(and of course another html, called testen.html)

With kind regards, 

Ah oke i figured it out. I added the function in my view overzicht :slight_smile: seems to work. Sorry for the spam.