1👍
✅
You just need to call the correct related field.
If you are inside the Question Admin Interface you need to add the user_text
to your form:
@admin.register(Question)
class QuestionAdmin(admin.ModelAdmin):
...
fields = ('user_text', ...)
If you are inside the UserText Admin Interface you can use inlines:
class QuestionInline(admin.TabularInline):
model = Question
@admin.register(UserText)
class UserTextAdmin(admin.ModelAdmin):
...
inlines = [QuestionInline, ]
Btw, a OneToOneField
is similar a ForeignKey
with unique=True
, in other words, each user can only have one question. If the user can have more than one question you should switch to a ForeignKey
.
Source:stackexchange.com