#11917 closed Uncategorized (worksforme)
Generic comment moderation fails on ./manage.py shell with AlreadyModerated
| Reported by: | fractal | Owned by: | nobody |
|---|---|---|---|
| Component: | contrib.comments | Version: | 1.1 |
| Severity: | Normal | Keywords: | AlreadyModerated |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
when you register a model to be moderated you are unable o import that models.py on the shell
how to reproduce
create a project and a app inside it
set a model and a Comment moderator as per
http://docs.djangoproject.com/en/dev/ref/contrib/comments/moderation/ instructions
#foo/bar/models.py
from django.db import models
class Entry(models.Model):
pass
from django.contrib.comments.moderation import CommentModerator, moderator
class EntryModerator(CommentModerator):
pass
moderator.register(Entry, EntryModerator)
save and open the shell
./manage shell
In [1]: from bar.models import *
---------------------------------------------------------------------------
AlreadyModerated Traceback (most recent call last)
/tmp/foo/<ipython console> in <module>()
/tmp/foo/bar/models.py in <module>()
9
10 class EntryModerator(CommentModerator):
11 pass
12
---> 13 moderator.register(Entry, EntryModerator)
/usr/local/lib/python2.6/dist-packages/django/contrib/comments/moderation.pyc in register(self, model_or_iterable, moderation_class)
301 for model in model_or_iterable:
302 if model in self._registry:
--> 303 raise AlreadyModerated("The model '%s' is already being moderated" % model._meta.module_name)
304 self._registry[model] = moderation_class(model)
305
AlreadyModerated: The model 'entry' is already being moderated
Change History (2)
comment:1 by , 16 years ago
| Resolution: | → worksforme |
|---|---|
| Status: | new → closed |
comment:2 by , 14 years ago
| Easy pickings: | unset |
|---|---|
| Severity: | → Normal |
| Type: | → Uncategorized |
| UI/UX: | unset |
Observed the same behavior in Django 1.3, for the record!
Note:
See TracTickets
for help on using tickets.
I used similar code and it worked on SVN...
# com/models.py from django.db import models from django.contrib.comments.moderation import CommentModerator, moderator # Create your models here. class Entry(models.Model): pass class EntryModerator(CommentModerator): pass moderator.register(Entry, EntryModerator)