Newforms admin Auth

0 views
Skip to first unread message

Michael Newman

unread,
Feb 18, 2008, 1:28:41 PM2/18/08
to Django developers
I am still hacking around trying to figure out what exactly is still
having issues in newforms-admin auth. After I updated the patch at
http://code.djangoproject.com/ticket/6083 , I still got a strange and
inconsistant error despite restart after restarts of apache about how
my registration couldn't import name UserCreationForm. Five more hours
this morning and I finally narrowed it down to a line of code that
registered the admin portion of the Auth system.

Right now this line from "django.contrib.auth import admin" is located
in models, which works fine if what you want is just to register the
auth system for the admin, but you get these strange anbigous errors
when you need to the tie into auth.models with any other code (I
assume an AlreadyRegistered exception is the real exception being
raised).

I thought that, typical to my personal conventions, I would then just
place that line of code into auth.__init__, but then I realized that
django.contrib.auth is imported several times and that wouldn't work
either. So now I have this one line of code that needs to be run once
and only once without a home. Any ideas, suggestions, thoughts that
the AlreadyRegistered error should fail quietly?

P.S. I changed auth.models.User.add_view to newforms as well and want
to update that ticket again but would prefer to do it after I fix this
error.

Michael Newman

unread,
Feb 19, 2008, 8:32:03 AM2/19/08
to Django developers
Maybe I should clear up my problem and question. My problem is
newforms admin specific in that I am importing the admin.py and
therefore registering the module multiple times. The problem is where
should I import this admin file. This problem right now is specific to
Auth, but I could see where it may be an issue in the future. If you
put the import in models, you can't import models, and if you put it
in __init__ as seems to be the popular convention you can't import the
app model by itself. Right now I am solving the auth issue by putting
the import into another model's __init__, but that won't work for
contrib.auth. So my question is where should this import be put so tht
it doesn't get called more than once, specifically for Auth now, but
more abstract for the future?


On Feb 18, 1:28 pm, Michael Newman <newmani...@gmail.com> wrote:
> I am still hacking around trying to figure out what exactly is still
> having issues in newforms-admin auth. After I updated the patch athttp://code.djangoproject.com/ticket/6083, I still got a strange and

Florian Apolloner

unread,
Feb 29, 2008, 4:55:15 AM2/29/08
to Django developers
An ugly hack would be (I also did it for one project and it worked
fine) to put the code into a try statement and catch the
AlreadyRegistered Exception.
Reply all
Reply to author
Forward
0 new messages