Hello!
I have a profile model which have a OneToOne relation to a Member model, which is the main model used for custom authentication.
The Member model have a field called profile_type, which can be Man, Woman, Couple etc.
Are there any ways to, in the admin page, display the Profile fields depending on what the profile_type field is set to?
For example, if profile_type is Man, in the admin page I want to render something like this:
member = request.user
if member.profile_type == "Man":
field_1 = models.CharField(max_length=128)
field_2 = models.CharField(max_length=128)
field_3 = models.CharField(max_length=128)
if member.profile_type == "Woman":
field_4 = models.CharField(max_length=128)
field_5 = models.CharField(max_length=128)
field_6 = models.CharField(max_length=128)
where the fields are fields in the Profile model.
Currently, my admin page for the Profile Model is described by this code in the admin.py file:
@admin.register(Profile)
class ProfileAdmin(admin.ModelAdmin):
exclude = ["member"]
list_display = ["member", ]