flebel / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

tagging.register does not work with the management shell #128

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
error: already.registered exception

reproduce:
1. create simple model in project with the django-tagging installed
2. add tagging.register(TheModel) to the model
3. run the shell ./manage.py  shell
4. from application.models import *
result:
<class 'tagging.AlreadyRegistered'>: The model Item has already been registered.

Original issue reported on code.google.com by till%bac...@gtempaccount.com on 29 May 2008 at 11:22

GoogleCodeExporter commented 9 years ago
Ditto. I've been doing this in my models.py:

try:
    tagging.register(MyModel)
except tagging.AlreadyRegistered:
    # Dev Note: Not sure the right way to register a model for tagging b/c it
    # raises this error if registered more than once. We end up registering
    # the first time during "manage.py syncdb" and then a second time when
    # actually attempting to run the site.
    pass

Original comment by tre...@gmail.com on 25 Jun 2008 at 10:36

GoogleCodeExporter commented 9 years ago
Same here.  The workaround that trentm posted works fine for me.

Original comment by jonathan...@gmail.com on 31 Jul 2008 at 6:12

GoogleCodeExporter commented 9 years ago
Same again. Seems models.py is being run more than once. I don't understand why 
the
developer would intentionally raise an Exception though. Why not just return 
silently
if the model is already registered?

Original comment by litchfie...@gmail.com on 29 Jan 2009 at 11:27

GoogleCodeExporter commented 9 years ago
I having same problem in my application. I just checked code and as litchfield4 
I
don't understand why raise a error too ... so I changed tagging code and I 
propose a
simple patch here, to ignore if Model already in register instead raise a error.

Original comment by philipe.rp@gmail.com on 28 Jul 2009 at 6:45

Attachments:

GoogleCodeExporter commented 9 years ago
Also have this problem, would be nice to see a resolution or clarification in 
the doc's.

Original comment by Stephen....@gmail.com on 4 Oct 2010 at 1:57

GoogleCodeExporter commented 9 years ago
Ditto, a silent passing would be nice if the model is already registered... 
It's a pain to write try/except clauses for each registered model.

Original comment by janne.la...@silverbucket.fi on 15 Feb 2011 at 7:36

GoogleCodeExporter commented 9 years ago
This has bitten our company as well. It's a shame this issue was reported back 
in 2008 and nothing has really been mentioned by the developers/maintainers.

cheers
James

Original comment by prolo...@shortcircuit.net.au on 13 Jan 2015 at 3:17