I have 2 model classes in my django app: 1: House (name, location, id...) 2: Photo (description, id, house -foreign key-).
In the admin interface, the photo is displayed as inline for the house form, but now, I want the user to be able to choose ONE picture as highlighted for that house. My question is: there's someway to add a radiobutton so the user is only able to choose one picture? Could you help me to achieve this, please? Thanks!
Add
OneToOneField
forPhoto
inHouse
model (you will need to reference it as"YOUR_APP.Photo"
to avoid circular references), provideModelAdmin
with custom form, and in that form's constructor filter queryset for that field to display only photos for current house.Different approach is to add
highlighted
flag inPhoto
model and ensure onsave
that only one photo is highlighted for one house.