Quantcast

Meta class completely missing.

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Meta class completely missing.

Brandon-2
print Foo.Meta throws AttributeError: type object 'Foo' has no attribute 'Meta' for *some* classes.

Reproduce it by:

from django.db import models
class Foo(models.Model):
    value
= models.CharField(max_length=256,blank=True)

   
class Meta(object):
       
pass

Then makemigrations and migrate
Then print Foo.Meta

Of the 61 models currently defined in one models.py my project 25 of them do not throw an error and have a reference to a Meta class. The other 36 throw the error above.

Is this right? What is going on? Why would some models have a Meta class and others not? Actually defining a Meta class (with or without attributes) in the model seems to make zero difference.

Any help understanding this is greatly appreciated.
--Brandon

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/4e1e9636-31e0-4ba2-819b-f3d37cb5c5d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Meta class completely missing.

chris rose
hi brandon

try removing (object) from your meta class declaration

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/30d054d7-8150-4eeb-bc3b-cf8a762078ae%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...