inheritance - Django: app_label problem when declaring base models outside models.py -
i have abstract container class allows derived models hold content blocks such images, text, etc., separate models. db tidiness, want tables models labeled content_block_image, content_block_text, etc.
but when specify app_label = 'content_block'
in meta class of content model, getting error during syncdb:
content.event: 'content' has m2m relation model content, has either not been installed or abstract.
i declaring following base classes follows:
# base.py class content(models.model): tags = models.textfield(_('tags'), blank=true) user = models.foreignkey(user) content_type = models.foreignkey(contenttype, related_name='%(class)s_content_set') container_type = models.foreignkey(contenttype) container_id = models.positiveintegerfield() container = generic.genericforeignkey('container_type', 'container_id') class meta: app_label = 'content_block' class container(models.model): content_type = models.foreignkey(contenttype, related_name='%(class)s_container_set') content = generic.genericrelation('content', content_type_field='container_type', object_id_field='container_id') class meta: abstract = true
then, in models declaring models call container such as:
# models.py class event(container): title = models.charfield(max_length=100) start = models.datetimefield() end = models.datetimefield()
if remove app_label
syncdb runs without problem. seems app_label not label.
any ideas on how going app_label content base class set?
from the doc
if model exists outside of standard models.py (for instance, if app’s models in submodules of myapp.models), model must define app part of:
app_label = 'myapp'
content_block
application exists ? if not, i'm not shure work.
it seems want forcing table names. it's possible property
the name of database table use model:
db_table = 'music_album'
Comments
Post a Comment