Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
new-forms admin shouldn't throw error when a model is registered twice #6776
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Simon Willison  
View profile  
 More options Apr 11 2008, 5:56 am
From: Simon Willison <si...@simonwillison.net>
Date: Fri, 11 Apr 2008 02:56:04 -0700 (PDT)
Local: Fri, Apr 11 2008 5:56 am
Subject: new-forms admin shouldn't throw error when a model is registered twice #6776
http://code.djangoproject.com/ticket/6776

newforms-admin raises an AlreadyRegistered exception if you attempt to
register a model with admin.site twice. Unfortunately, due to the
different places and ways in which a models.py file can be imported
it's extremely easy to trigger this accidentally, and difficult to
debug when you do.

The code in question is here:

http://code.djangoproject.com/browser/django/branches/newforms-admin/...

if model in self._registry:
    raise AlreadyRegistered(
        'The model %s is already registered' % model.__name__
    )
self._registry[model] = admin_class(model, self)

Is there any reason we can't just ignore attempts at repeat
registrations here?

Cheers,

Simon


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
mrts  
View profile  
 More options Apr 11 2008, 6:47 am
From: mrts <m...@mrts.pri.ee>
Date: Fri, 11 Apr 2008 03:47:54 -0700 (PDT)
Local: Fri, Apr 11 2008 6:47 am
Subject: Re: new-forms admin shouldn't throw error when a model is registered twice #6776
As double imports should be considered harmful, I'd rather see a
better warning there, in the lines of ""The model Foo is already
registered. This can be caused by a double import, see docs/bar.txt
for ways to avoid it." (Double imports are triggered by mixing
relative and absolute imports, e.g. in "import models" in foo/views.py
and "from project.foo import models" in bar/views.py.)

There should perhaps be a section "How to organize your project and
applications" in main documentation or in the FAQ that would give
clear guidelines for creating reusable applications yet avoiding
double imports.

On Apr 11, 12:56 pm, Simon Willison <si...@simonwillison.net> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
NickFitz  
View profile  
 More options Apr 11 2008, 7:24 am
From: NickFitz <n...@nickfitz.co.uk>
Date: Fri, 11 Apr 2008 04:24:19 -0700 (PDT)
Local: Fri, Apr 11 2008 7:24 am
Subject: Re: new-forms admin shouldn't throw error when a model is registered twice #6776
On Apr 11, 11:47 am, mrts <m...@mrts.pri.ee> wrote:

> As double imports should be considered harmful, I'd rather see a
> better warning there, in the lines of ""The model Foo is already
> registered. This can be caused by a double import, see docs/bar.txt
> for ways to avoid it."

Just wondering: why exactly should double imports be "considered
harmful"? If the framework detects them and silently ensures that Bad
Things Don't Happen, then they aren't harmful, and it's one less
finicky little detail to bog one down hunting all over for the source
of the problem.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Russell Keith-Magee  
View profile  
 More options Apr 11 2008, 7:36 am
From: "Russell Keith-Magee" <freakboy3...@gmail.com>
Date: Fri, 11 Apr 2008 19:36:47 +0800
Local: Fri, Apr 11 2008 7:36 am
Subject: Re: new-forms admin shouldn't throw error when a model is registered twice #6776

On Fri, Apr 11, 2008 at 5:56 PM, Simon Willison <si...@simonwillison.net> wrote:

>  http://code.djangoproject.com/ticket/6776

>  newforms-admin raises an AlreadyRegistered exception if you attempt to
>  register a model with admin.site twice. Unfortunately, due to the
>  different places and ways in which a models.py file can be imported
>  it's extremely easy to trigger this accidentally, and difficult to
>  debug when you do.

Brian raised this issue about a month ago, albeit from a slightly
larger perspective:

http://groups.google.com/group/django-developers/browse_thread/thread...

The discussion there may be slightly more illuminating regarding the
reasoning and options.

Russ %-)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »