Hi,

this is a tough question, i've posted it to stackoverflow here:
http://stackoverflow.com/questions/39076392/django-m2m-through-model-with-classic-admin-widget

I include the text of the question here to make it easier to respond:

I need to customise a through model of a many-to-many relationship, the 
customisation is subtle, because the user won't need do act manually, I try 
to explain myself better by explaining my use case with the following 
pseudo code:


RouterConfiguration- vpn (many-to-many through VpnClient)# other fields
VpnClient- router: ForeignKey to RouterConfiguration- vpn: ForeignKey to Vpn- 
cert: ForeignKey to Cert
Vpn# other fields
Cert# (stores x509 certificates)# other fields


The through model VpnClient has only one additional field, a ForeignKey to 
Cert, but I want VpnClient to automatically create a Cert instance without 
user interaction and until here there is no problem.

The problem comes in the Django Admin, because as far as I understood, it 
is not possible to use the classic many2many widget when using a through 
model:

When you specify an intermediary model using the through argument to a 
ManyToManyField, the admin will not display a widget by default. This is 
because each instance of that intermediary model requires more information 
than could be displayed in a single widget, and the layout required for 
multiple widgets will vary depending on the intermediate model.

Reference: 
https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#working-with-many-to-many-intermediary-models

But I don't want the user to insert any extra information. I just want to 
be able to control the model so it can perform a series of actions 
automatically.

So my question is: is it possible to have the classic admin widget with a 
custom through model? If there's no easy solution maybe I could try with a 
custom widget? Or maybe there is an alternative way to accomplish what I 
need?


Thanks to anyone who can give me any useful suggestion.

Federico

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4488bb17-dabd-4bef-9fa4-7707a4b76c9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to