Hi Tom,

On Tue, Dec 23, 2014 at 8:23 AM, Tom Christie <christie....@gmail.com>
wrote:
>
> One thing I'm unclear on: Does the new API contain any (public API) way of
> determining if a relationship has an associated through table?
>
> Entirely possible that I'm being stupid and that's outside the scope of
> the API, but it's the one thing I see in Django REST framework's
> ModelSerializer '_meta' inspection code that's not obviously handled here.
>
> Is it something that needs to be covered? (Of course if we're talking
> about 1.8 blockers I've no particular problem if the answer needs to be
> 'maybe but could come later')
>

Well, it's covered (in that the capability exists), but that's a historical
capability - it hasn't been through the formal documentation process.

The API we've documented has focussed on being able to discover the fields
on a model. The fields themselves are (mostly) unchanged, and unless
changes were necessary to support the cleanup of the discovery API, we
haven't touched them.

So, something like:

[f for f in MyModel._meta.get_fields() if f.has_relation and f.many_to_many
and not f.rel.through._meta.auto_created]

would give you all the m2m fields on this MyModel that have a m2m relation
with a through model. The f.has_relation and f.many_to_many are new pieces
of the API; f.rel.through._meta.auto_created is an old approach, but isn't
formally documented.

I completely agree that in the longer term, these extra flags *should* be
documented. There might even be an argument for them to be documented for
1.8 (if we're not changing anything - just formalising something that is
already in use).

My only hesitation is the overlap with the RelatedObject patch that Carl
referred to. If that lands, some of these flags and mechanisms might change
as a result of removing the RelatedObject model. I'd need to take a closer
look at that patch to be able to work out if there's potential to box
ourselves into a corner.

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAJxq849STxqbrgJ1szV%2BMKsAak5o6TcXtmKs_ZbQKPHt6_PFHg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to