I am trying to create a custom model manager, but encountered an error. The code is as follows:
class LookupManager(models.Manager):
def get_options(self, *args, **kwargs):
return [(t.key, t.value) \
for t in Lookup.objects.filter(group=args[0].upper())]
class Lookup(models.Model):
group = models.CharField(max_length=1)
key = models.CharField(max_length=1)
value = models.CharField(max_length=128)
objects = LookupManager()
(I quite often played with get_options, using super()other methods of filtering the results)
When I run syncdb, I get the following error ( ops_lookup- the corresponding table):
django.db.utils.DatabaseError: no such table: ops_lookup
I noticed that if I change the manager to return []instead of a filter, it works syncdb. In addition, if I run syncdband all the tables exist, then change the code to above, it also works.
How can I make Django not expect this table to exist on startup syncdbfor the first time?
, , . , , . , , , , , , .
django ( ?)