Code

Opened 5 years ago

Closed 4 years ago

Last modified 3 years ago

#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


Attachments (0)

Change History (2)

comment:1 Changed 4 years ago by thejaswi_puthraya

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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)
In [1]: from com.models import *

In [2]:

comment:2 Changed 3 years ago by smoke@…

  • Easy pickings unset
  • Severity set to Normal
  • Type set to Uncategorized
  • UI/UX unset

Observed the same behavior in Django 1.3, for the record!

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.