I use Generic Foreign keys to relate different profiles with my Users
model which is inherited from auth.User
. I'm not able to do dumpdata
though with the --natural
option passed. It says,
Error: Can't resolve dependencies for myproject.AdminProfile, myproject.TeacherProfile, myproject.Users in serialized app list.
According to documentation, it's said that we need to implement natural_key methods to take and flash fixtures which involves generic relations. How could I do that with my models presented here?
class Users(User):
location = models.TextField('Location', blank=True)
created_by = models.ForeignKey('self', null=True, blank=True, related_name='created_by_user')
# Generic foreign key setup to hold the extra attributes
profile_contenttype = models.ForeignKey(ContentType, null=True, blank=True)
profile_object_id = models.PositiveIntegerField('Extra ID', null=True, blank=True)
profile_object = generic.GenericForeignKey('profile_contenttype', 'profile_object_id')
class AdminProfile(models.Model):
organization = models.CharField('Organization', max_length=100)
# profile reverse relation to get the user
users_link = generic.GenericRelation('Users', content_type_field='profile_contenttype',
object_id_field='profile_object_id')
class TeacherProfile(models.Model):
designation = models.CharField('Designation', max_length=100)
# profile reverse to get the user
users_link = generic.GenericRelation('Users', content_type_field='profile_contenttype',
object_id_field='profile_object_id')
Using Django 1.4.3 and Postrgres.