Heres the scenario :
class Account(model.Model):
acc_name = models.CharField(max_length=50)
class Person(model.Model):
accounts = models.ManyToManyField(Account)
class Message(model.Model):
person = models.ForeignKey(Person)
msg = models.CharField(max_length=500)
Now I am using InineModelAdmin in my admin.py
. So it looks like this :
class Account(admin.ModelAdmin):
...
some code
...
admin.site.register(Account, AccountAdmin)
class MessageInLine(admin.StackedInline):
model = Message
class PersonAdmin(admin.Modeladmin):
inlines = [MessageInLine]
admin.site.register(Person, PersonAdmin)
So it stands that Message
has a ForeignKey
on Person
and Person
has a Many-To-Many
with Account
.
Now in the Django-admin
, where I add Person it obviously gives the components of Person
and Message
. Now here the accounts are in a list, where they need to be selected by holding CTRL
. I want to use a radio_button
to allow selecting multiple buttons for faster selection. How can I do this?
Edit :
I tried using radio_field like this inside PersonAdmin
:
radio_fields = {"accounts":admin.VERTICAL}
But it gives me an error that says that it is nether a ForeignKey
nor does it have a Choices Set
So obviously this isnt working. Is there a way around this?