m2m table names

61 views
Skip to first unread message

HenrikV

unread,
Sep 19, 2008, 2:47:06 PM9/19/08
to Django developers
If you imagine changing the table name of the auth.User table to
'account_user'. Should the groups relationship create a table called
'account_user_groups' or 'auth_user_groups' ?

Russell Keith-Magee

unread,
Sep 20, 2008, 12:19:39 AM9/20/08
to django-d...@googlegroups.com

I'm unclear if this is a user 'how to' question, or a badly phrased
suggestion for an improvement to Django.

If it's a user question, it should be asked on django-users.
django-developers is for discussing the development of django itself.
That said - unless overridden with the db_table setting or the use of
a through model, the m2m table name will be "model.db_table +
field_name" - in your case, that means account_user_groups.

If this is a suggestion for an improvement to Django, can you clarify
what exactly you are proposing? The current m2m table naming scheme
has been in place since the very beginning, and with the exception of
a few customizations, it hasn't changed in all that time. Why do you
think it is necessary to change the naming scheme?

Yours,
Russ Magee %-)

HenrikV

unread,
Sep 20, 2008, 6:13:22 AM9/20/08
to Django developers
I am working on #3011, making the User model overridable. I have a
working patch, but
if I set the db_table on the User model, the queryset and syncdb
doesn't seem to agree
on what the m2m table should be called.

As a sidenote there seems to a problem with certain combinations
db_table and app_name
for models with an abstract base class. I haven't isolated the problem
yet though.

Henrik

On Sep 20, 5:19 am, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:

Russell Keith-Magee

unread,
Sep 21, 2008, 2:36:23 AM9/21/08
to django-d...@googlegroups.com
On Sat, Sep 20, 2008 at 6:13 PM, HenrikV <hvende...@googlemail.com> wrote:
>
> I am working on #3011, making the User model overridable.

Ok - do you think this might have been useful information to include
on your original query?

> I have a
> working patch, but
> if I set the db_table on the User model, the queryset and syncdb
> doesn't seem to agree
> on what the m2m table should be called.
>
> As a sidenote there seems to a problem with certain combinations
> db_table and app_name
> for models with an abstract base class. I haven't isolated the problem
> yet though.

Well... lets think this through. Django has had m2m since day 1.
Django has a large collection of unit tests that exercise m2m
relations. They test all sorts of combinations of m2m and db_table
combinations.

You have been messing around with modifying the internals of Django.

So, either:
1) Django has a fundamental problem with m2m tables that has gone
unnoticed for 3 years
2) There is something wrong with your code

Which do you think is more likely?

Please note that I'm not saying that Django is flawless. However, I
have a lot more confindence in Django that I have in a random
"something seems to be wrong" comment that isn't backed up with a
concrete example. Until you present a concrete example where vanilla
Django fails, you're going to find that anyone with the ability to
help you isn't going to be particularly helpful.

Yours,
Russ Magee %-)

HenrikV

unread,
Sep 22, 2008, 11:39:12 AM9/22/08
to Django developers
I hope your reply was helpful to others. I asked a question because I
am not as knowledgeable about Django internals as you obviously are,
and this is this is to my knowledge the place to ask.
I make no assumptions about where there is a bug, or if there is one,
as I haven't figured out how things are supposed to work, hence my
original question.
I have the source code so I can figure out the answers myself given
enough time. I will try not to slam the door too hard behind me.


On Sep 21, 7:36 am, "Russell Keith-Magee" <freakboy3...@gmail.com>
wrote:

Karen Tracey

unread,
Sep 22, 2008, 12:45:08 PM9/22/08
to django-d...@googlegroups.com
On Mon, Sep 22, 2008 at 11:39 AM, HenrikV <hvende...@googlemail.com> wrote:

I hope your reply was helpful to others. I asked a question because I
am not as knowledgeable about Django internals as you obviously are,
and this is this is to my knowledge the place to ask.
I make no assumptions about where there is a bug, or if there is one,
as I haven't figured out how things are supposed to work, hence my
original question.
I have the source code so I can figure out the answers myself given
enough time. I will try not to slam the door too hard behind me.

Henrik,

Clearly Russell's reply rubbed you the wrong way.  Before leaving, though, perhaps try re-reading the notes you posted, imagining you know the m2m implementation very well but know nothing at all of the code you are presently trying to get working.  Is there enough information in what you posted for someone who knows m2m (but not what you are working on) to give any real guidance on what might be going wrong?  I don't think there is (though I confess to also not knowing m2m very well, so I could be wrong). 

I sense in Russell's reply a frustration that you are positing general m2m problems without providing any specifics to go on.  As he says, there is an extensive test suite that exercises m2m, and it does not show any problems. As he also states, that it not to say none exist, but without more specifics on what problems you are running into it is impossible to say one way or the other.  He did take the time to reply twice on the conversation, so clearly is interested enough to attempt to help, but having a hard time doing so given the lack of information on what you are doing, exactly, and what problems you are seeing.

Karen
Reply all
Reply to author
Forward
0 new messages