1.<class 'xxxxxx'> has more than 1 ForeignKey to <class 'yyyyyyy'>
There is no problem actually, you only need to define the fkey that admin
app should use for the relation. If you have model like this (your
testcase):
class Person(models.Model):
name = models.CharField(max_length=
friends = models.ManyToManyField('self', through='Friendship',
related_name='friend_of', symmetrical=False)
def __unicode__(self):
return self.name
class Friendship(models.Model):
first = models.ForeignKey(Person, related_name='rel_from_set')
second = models.ForeignKey(Person, related_name='rel_to_set')
date_friended = models.DateTimeField(auto_now_
def __unicode__(self):
return u'%s :: %s' % (self.first.name, self.second.name)
You need to specify fk_name attr on inline object:
class FriendshipInline(admin.
model = Friendship
fk_name = 'first'
Similarly could could edit the second side of the relation like this on a
single page:
class SecondFriendshipInline(admin.
model = Friendship
fk_name = 'second'
Your PersonAdmin would be then like this:
class PersonAdmin(admin.ModelAdmin):
inlines = [FriendshipInline, SecondFriendshipInline]
admin.site.register(Person, PersonAdmin)
This subtle config addon is however not mentioned currently in the docs,
you need to go to the source.
http://stackoverflow.com/questions/17872441/django-createview-gives-an-error-needs-to-have-a-value-for-field-before-t