Sub classing a self referring class with natural keys from a Base class 
generates an error on dumpdata.

c:\dev\chris\bugdemo>manage.py syncdb
Creating tables ...
Creating table auth_permission
Creating table auth_group_permissions
Creating table auth_group
Creating table auth_user_user_permissions
Creating table auth_user_groups
Creating table auth_user
Creating table django_content_type
Creating table django_session
Creating table django_site
Creating table bug_template_extends
Creating table bug_template_includes
Creating table bug_template

You just installed Django's auth system, which means you don't have any 
superusers defined.
Would you like to create one now? (yes/no): no
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

c:\dev\chris\bugdemo>manage.py dumpdata
Error: Can't resolve dependencies for bug.Template in serialized app list.

Here's the model.

from django.db import models

class BaseManager(models.Manager):
    def get_by_natural_key(self, name, date_created):
        return self.get( name=name, date_created=date_created,)

class Base(models.Model):
    objects = BaseManager()
    
    date_created   = models.DateTimeField(auto_now_add = True )
    date_modified  = models.DateTimeField(auto_now = True )    
    name           = models.CharField(max_length = 100, default = '.')
    description    = models.TextField(default = '.')
    
    class Meta:
        abstract = True
        unique_together = (('name','date_created'),)
        ordering = ['name','date_created']
        
    def natural_key(self):
        return (self.name, self.date_created)
        
    def __unicode__(self):
        return self.name


TEMPLATE_TYPES = (
    ('HTML', 'HTML Text Template'),
    ('XML', 'XML Template'),
    ('TXT',  'Text Template'),
    )
    
class Template(Base):
    extends   = models.ManyToManyField('self', blank = True, null =True, 
related_name = 'extends_template', symmetrical = False)
    includes   = models.ManyToManyField('self', blank = True, null =True, 
related_name = 'includes_template', symmetrical = False)
    type       = models.CharField(max_length = 6, choices=TEMPLATE_TYPES)

Chris

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Yck43Fc-zpoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to