2đź‘Ť
âś…
To get Django to know that the primary first name should be a “pointer” to a first name instance, you should modify your model a bit:
class Person(models.Model):
primary_first_name = models.ForeignKey('FirstName')
The second part of your question is a bit tricky. So you want the Django Rest Framework to generate an “admin interface” to create some first names and then allow you to tick the certain as the primary? I guess you’d better stick with the django.contrib.admin
, which has inlines. DRF certainly doesn’t have such a complex interface, after all, it’s just for the objects (de)serialization.
👤Alex Morozov
Source:stackexchange.com