Thanks a lot Russ Magee, now it works.
Ciao
Vittorio
Il giorno 04/apr/2013, alle ore 14:24, Russell Keith-Magee ha scritto:

> 
> 
> On Thu, Apr 4, 2013 at 6:48 PM, Tom Evans <tevans...@googlemail.com> wrote:
> On Thu, Apr 4, 2013 at 11:35 AM, Russell Keith-Magee
> <russ...@keith-magee.com> wrote:
> >
> >
> > On Thu, Apr 4, 2013 at 5:28 PM, Vittorio <ml-...@de-martino.it> wrote:
> >>
> >> Under Django 1.5.1 I'm having a go at using ManyToManyField (see below 
> >> models.py and admin.py files) referring to an Sqlite3 legacy db.
> >>
> >> I'm receiving the following fatal error message in admin
> >>
> >> Exception Value:
> >>
> >> 'LibroOption.fields' can't include the ManyToManyField field
> >>
> >> 'autore' because 'autore' manually specifies a 'through' model
> >
> >
> > The error is telling you exactly what the problem is. You can't put autore 
> > in the list of admin-displayed fields (or, for that matter, the list of 
> > filter_horizontal) because it uses a through model.
> >
> > There's a very simple reason for this - a through model exists to allow you 
> > to specify additional data on a relation. The basic m2m widget (in any of 
> > it's forms, including raw_id_field and filter_horizontal/vertical) only 
> > allow you to define the "other" object that you want a relation with. You 
> > can't set up a 'through' relation without specifying the extra data as 
> > well, so you're prohibited from using the basic m2m widgets on m2m 
> > relations with a through model.
> >
> > If you want to have an admin representation for an m2m relation with a 
> > through model, you need to add an inline to represent the through model. 
> > See [1] for more details.
> >
> > That said, if I'm reading your models correctly, it looks like the 
> > "through" model isn't actually required, it's just been introspected that 
> > way -- it's easier for the introspector to create a model for *every* 
> > table, rather than try to work out which tables are actually m2m tables.
> >
> > It should be possible to remove the explicit definition of the LibriAutori 
> > model, and replace the autori m2m relation with:
> >
> >    autori = models.ForeignKey(Autore,db_column='autori', 
> > db_table='LibriAutori')
> >
> 
> This should be a ManyToMany field with the same options, no?
> 
> /facepalm
> 
> You are completely correct. I lose my keyboard privileges for the evening :-)
> 
> Yours
> Russ Magee %-)
> 
> -- 
> 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 http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
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 http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to