there are two Models, User
And Friends
. I want to make two users make friends,but it did work.
the console just said,
django.core.management.base.CommandError: System check identified some issues:
ERRORS: : (admin.E202) 'api4android.Friends' has more than one ForeignKey to 'api4android.User'.
here is the code
class Friends(models.Model):
user = models.ForeignKey(User, null=True, related_name='user')
friend = models.ForeignKey(User, null=True, related_name='friend')
note_name = models.CharField(max_length=20)
def __str__(self):
return self.note_name
hope my poor english makes you understand what i mean.
In your admin.py you have to specify fk_name to each relation. Example:
class FriendshipInline(admin.TabularInline):
model = Friendship
fk_name = "user"
More info: Django Docs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With