'dict' object has no attribute 'model' Issue

When I select a date range, I want it to show the number of hard drives saved in the database and the total size of these hard drives in the selected date range.

would be glad if you help.


class MateryalFiltrele(django_filters.FilterSet):
    baslangicTarihi = DateFilter(field_name="eklenmeTarihi", lookup_expr="gte", label='')
    bitisTarihi = DateFilter(field_name="eklenmeTarihi", lookup_expr="lte", label='')
    class Meta:
        model = MateryalEkle
        fields = ('cinsi','materyalBoyut')


class MateryalEkle(models.Model):
    ('USB', 'USB'),
    ('HDD', 'HDD'),
    cinsi = models.CharField(max_length=50, choices=MATERYALCINSI)
    materyalBoyut = models.IntegerField(max_length=5)
    eklenmeTarihi = DateField(auto_now_add=True)
    def __str__(self):
        return self.cinsi


def istatistik(request):

    topla = MateryalEkle.objects.filter(cinsi='HDD').aggregate(tumhddtopla=Sum('materyalBoyut'))
    toplafiltre = MateryalFiltrele(request.GET, queryset=topla)

        return render(request, 'delil/istatistikler.html', {'toplafiltre':toplafiltre})



{{ toplafiltre.form.baslangicTarihi | as_crispy_field }}
{{ toplafiltre.form.bitisTarihi | as_crispy_field }}

<button type="submit" ></button>


<table class="table mt-5">
            {% for tekil in hddToplaFiltre.qs %}
            <th class="ubold text-info ufo60" scope="col">{{tekil.tumhddtopla}}</th>
            {% endfor %}


When asking for help with an error message, it’s helpful if you post the complete traceback message and not just the summary line. (You should also enclose it between the lines of three backticks as well, just like you do with code.)

I am sorry fır this. I got it. Will you answer my question?

That’s not the traceback.

We’re looking for the information that would be presented in your console where you’re running runserver.

1 Like

Thank you for your interest. I solved the problem.