Search code examples
djangodjango-modelsdjango-errors

Models not getting created outside of models.py


My project hierarchy -

MyProject -> myapp -> MyPackage -> models.py .

In this models.py there is a class -

class Tagline(models.Model):  
        name = models.CharField(max_length=20)  
        tagline = models.CharField(max_length = 40)  
    class Meta:  
        app_label = 'myapp'  

But when i try and access this table ( either through the admin or a normal view ) django throws me an error stating -
Table "myapp_tagline" doesn't exist .
What else besides the app_label do I have to specify in order to get django to detect this model.

P.S. Also how do I indent my code here?


Solution

  • It has to be in <app>.models. Import it there.

    Meta is a class attribute, so it has to be at the same indentation as the other class attributes.