Skip to content Skip to sidebar Skip to footer

Django Filter Query - Doesn't Work

I have problems with my Django, I want to write a very simple query but it doesn't work. Model: class Games(models.Model): name = models.CharField(max_length=128) path_to_f

Solution 1:

In Django 1.7 and later you can't use models without explicitly initialising Django first. Run the following commands:

import django
django.setup()

And after that your queries will work.

Relevant Django doc: https://docs.djangoproject.com/en/dev/ref/applications/#initialization-process


Post a Comment for "Django Filter Query - Doesn't Work"