DJango Generic date views filtering

Hello I really need help with date views. I need a prediction based view on date. I have users and staff, users have their views while staff can see everything what a user did in their view

right now I have a Dashboard for staff where they can choose the view of a user

class Dashboard (AdminStaffRequiredMixin, LoginRequiredMixin, ListView):
    model = SchulverzeichnisTabelle
    template_name = 'SCHUK/Dashboard.html'
    context_object_name = 'Dashboard'

the view

    {% for Ansicht in Dashboard %}
        <th scope="row"></th>
        <td><a href="{% url 'Ansicht' %}">{{Ansicht.Konto}}</a></td>
        <td><a href="{% url 'Ansicht' %}">{{Ansicht.Schulname}}</a></td>
        <td><a href="{% url 'Ansicht' %}">{{Ansicht.SAB}}</a></td>
        <td><a href="{% url 'Ansicht' %}">{{Ansicht.GL}}</a></td>
        <td><a href="{% url 'Ansicht' %}">{{Ansicht.Teilstandort}}</a></td>
    {% endfor %}

Now when they view one view all the data that is show is a _set from user model (that is also why I just cant use simple django filter bc it is a set and I dont know how to filter only the set but thats just a side note)

class Ansicht(AdminStaffRequiredMixin, LoginRequiredMixin, DetailView):
    model = User
    template_name = 'SCHUK/Ansicht.html'
    context_object_name = 'Ansicht'

the view in short
  {% for Ansicht in Ansicht.schulverzeichnistabelle_set.all %}


basically the same, but not all entries in models instead only those from a user.

So, the user have one school but multiple teachers on his school. The staff adds teacher to a user and the user can edit some things

class LehrerAktualisierenSchulleitung(LoginRequiredMixin, UpdateView):
    model = LehrerTabelle
    fields = '__all__'
    template_name = 'SCHUK/LehrerAktualisierenSchulleitung.html'
    context_object_name = 'LehrerAktualisierenSchulleitung'
    def get_success_url(self):
        return reverse('Schulverzeichnis', args=[])

Every teacher gets a user so that _set can show staff only teacher corresponding to the user / school.

The staff can now do a prediction like that

class PrognoseTabelle(models.Model):
    Benutzer = models.ForeignKey(User, on_delete=models.SET_NULL, null=True) 
    Lehrer_FK = models.ForeignKey('LehrerTabelle', on_delete=models.SET_NULL, related_name='LehrerNName', null=True, blank=True)
    #######Status 1######
    von_Datum = models.DateField(null=True, blank=True)
    Status = models.CharField(max_length=20, null=True, blank=True)
    Stunden = models.CharField(max_length=20, null=True, blank=True)
    bis_Datum = models.DateField(null=True, blank=True)
    #######Status 2######
    von_Datum_2 = models.DateField(null=True, blank=True)
    Status_2 = models.CharField(max_length=20, null=True, blank=True)
    Stunden_2 = models.CharField(max_length=20, null=True, blank=True)
    bis_Datum_2 = models.DateField(null=True, blank=True)
    #######Status 3######
    von_Datum_3 = models.DateField(null=True, blank=True)
    Status_3 = models.CharField(max_length=20, null=True, blank=True)
    Stunden_3 = models.CharField(max_length=20, null=True, blank=True)
    bis_Datum_3 = models.DateField(null=True, blank=True)
    Erstellt_Datum_3 = models.DateField(null=True, blank=True)
    #######Status 4######

it is from date , a status, working hours and to date. on top it is bound to a teacher and a user for the _set thing, to show staff only needed data

I need to have a filter or in that case a date view which can filter based on date the status and working hours to view for the staff.

a bonus would be if there is also a method to filter for the work hours for a calculation table but that would be another topic

How can I now filter it, Im completely lost and scared that I choose the wrong language for this task and need to swtich to something more frontend like. but django allows javascript so even a new language is not needed it must be somehow possible with javascript but how can I fetch that many items or convert them from the model to json, I mean if there is a way to convert it all to json from the CBV I would also take that as solution bc then the frontend can just take over

pls halp

Back to Top