Comments (8)
Could you tell me more information how this bug occurred ? Could you paste a trace bug ?
from django-moderation.
On first starting the server (with "manage.py runserver"), I get:
AlreadyRegistered at /
The model ModeratedObject is already registered
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/adm
Django Version: 1.2 beta 1 SVN-12776
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.flatpages',
'django.contrib.sitemaps',
'reversion',
'django_extensions',
'annoying',
'mptt',
'sorl',
'tinymce',
'djapian',
'moderation',
'mg_core',
'mg_productos',
'mg_noticias',
'mg_sitio',
'mg_contacto',
'mg_archivos']
Installed Middleware:
('annoying.middlewares.StaticServe',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
80. response = middleware_method(request)
File "C:\Python26\lib\site-packages\django\middleware\common.py" in process_request
57. if (not _is_valid_path(request.path_info, urlconf) and
File "C:\Python26\lib\site-packages\django\middleware\common.py" in _is_valid_path
143. urlresolvers.resolve(path, urlconf)
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in resolve
307. return get_resolver(urlconf).resolve(path)
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in resolve
220. for pattern in self.url_patterns:
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns
249. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module
244. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python26\lib\site-packages\django\utils\importlib.py" in import_module
35. __import__(name)
File "C:\areaweb\022 microgeo\001 sitio web\dev\v1\microgeo\..\microgeo\urls.py" in <module>
6. admin.autodiscover()
File "C:\Python26\lib\site-packages\django\contrib\admin\__init__.py" in autodiscover
57. import_module("%s.admin" % app)
File "C:\Python26\lib\site-packages\django\utils\importlib.py" in import_module
35. __import__(name)
File "C:\areaweb\022 microgeo\001 sitio web\dev\v1\microgeo\mg_productos\admin.py" in <module>
8. from microgeo.moderation.admin import ModerationAdmin
File "C:\areaweb\022 microgeo\001 sitio web\dev\v1\microgeo\..\microgeo\moderation\admin.py" in <module>
137. admin.site.register(ModeratedObject, ModeratedObjectAdmin)
File "C:\Python26\lib\site-packages\django\contrib\admin\sites.py" in register
82. raise AlreadyRegistered('The model %s is already registered' % model.__name__)
Exception Type: AlreadyRegistered at /adm
Exception Value: The model ModeratedObject is already registered
If I reload the page, I get:
RegistrationError at /
<class 'mg_productos.models.Producto'> has been registered with Moderation.
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/adm
Django Version: 1.2 beta 1 SVN-12776
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.flatpages',
'django.contrib.sitemaps',
'reversion',
'django_extensions',
'annoying',
'mptt',
'sorl',
'tinymce',
'djapian',
'moderation',
'mg_core',
'mg_productos',
'mg_noticias',
'mg_sitio',
'mg_contacto',
'mg_archivos']
Installed Middleware:
('annoying.middlewares.StaticServe',
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware')
Traceback:
File "C:\Python26\lib\site-packages\django\core\handlers\base.py" in get_response
80. response = middleware_method(request)
File "C:\Python26\lib\site-packages\django\middleware\common.py" in process_request
57. if (not _is_valid_path(request.path_info, urlconf) and
File "C:\Python26\lib\site-packages\django\middleware\common.py" in _is_valid_path
143. urlresolvers.resolve(path, urlconf)
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in resolve
307. return get_resolver(urlconf).resolve(path)
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in resolve
220. for pattern in self.url_patterns:
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in _get_url_patterns
249. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python26\lib\site-packages\django\core\urlresolvers.py" in _get_urlconf_module
244. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python26\lib\site-packages\django\utils\importlib.py" in import_module
35. __import__(name)
File "C:\areaweb\022 microgeo\001 sitio web\dev\v1\microgeo\..\microgeo\urls.py" in <module>
10. from mg_productos import models
File "C:\areaweb\022 microgeo\001 sitio web\dev\v1\microgeo\..\microgeo\mg_productos\models.py" in <module>
454. moderation.register(Producto)
File "C:\areaweb\022 microgeo\001 sitio web\dev\v1\microgeo\moderation\__init__.py" in register
51. raise RegistrationError(msg)
Exception Type: RegistrationError at /adm
Exception Value: <class 'mg_productos.models.Producto'> has been registered with Moderation.
from django-moderation.
One other thing, I tried commenting out all the other external apps (reversion, etc) from my settings.py and I get the same errors.
from django-moderation.
I cannot reproduce this error. You will need to show your models and model admins, along with the register
lines in question.
from django-moderation.
Here's the model + register line:
class Producto(BaseModel):
"""(Producto description)"""
categoria = models.ForeignKey(Categoria,
blank=True, null=True,
related_name="productos",
help_text=u"Categoría bajo la que está el\
producto")
grupo = models.ForeignKey(Grupo, related_name='productos', blank=True, null=True)
nombre = models.CharField(max_length=200)
tipo = models.CharField(max_length=2,
choices=(('PR', 'Producto',),
('CP', 'Curso')),
default='PR')
slug = models.SlugField("Nombre para URL", unique=True)
marca = models.ForeignKey("Marca", blank=True, null=True)
descripcion = HTMLField()
imagen_principal = fields.ImageWithThumbnailsField(upload_to="productos/imagenes",
blank = True, null = True,
thumbnail = dict(
size=(270, 231)
),
extra_thumbnails = extra_thumbs,
help_text=\
"Esta será la imagen aparecerá a un\
costado de la descripción",
)
imagen = fields.ImageWithThumbnailsField(upload_to="productos/imagenes",
blank = True, null = True,
thumbnail = dict(
size=(270, 231)
),
extra_thumbnails = extra_thumbs,
help_text=\
"Esta será la imagen aparecerá a un\
costado de la descripción",
)
ficha_tecnica = FilteredFileField(upload_to="productos/fichas",
allowed={'pdf': 'application/pdf'},
max_length=100, blank=True, null=True,
help_text=u"Se permiten sólo archivos PDF")
#archivos = generic.GenericRelation('ArchivoConTipo')
#imagenes = generic.GenericRelation(Imagen)
videos = generic.GenericRelation(Video)
relacionados = models.ManyToManyField('self',
related_name='relacionado_con',
blank=True, null=True)
complementos = models.ManyToManyField(Categoria,
related_name='complemento_de',
null=True, blank=True,
limit_choices_to={
'padre__isnull': False,
'padre__padre__isnull': True,
})
orden = models.PositiveIntegerField(default=1)
#galeria = models.OneToOneField('photologue.Gallery', related_name='producto')
def rowlevelpermission(self, user):
return self.categoria.rowlevelpermission(user)
class Meta:
ordering = ('categoria', 'grupo', 'orden', 'nombre')
verbose_name = "Producto o Servicio"
verbose_name_plural = "Productos y Servicios"
def __unicode__(self):
return u"%s" % (self.nombre)
@models.permalink
def get_absolute_url(self):
return ('productos.producto', (self.slug,))
def get_grupo_name(self):
"""Obtiene el nombre del grupo y nada si es None"""
if self.grupo is None:
return u''
return u'%s' % (self.grupo)
def get_categoria_name(self):
"""Obtiene el nombre de la categoria, o none"""
if self.categoria:
return u"%s" % self.categoria.nombre
return u""
def area(self):
if self.categoria:
return u"%s" % self.categoria.get_root()
moderation.register(Producto)
from django-moderation.
And the admin:
class ProductoAdmin(ModerationAdmin):
inlines = (InformacionInline, ImagenProductoInline, ArchivoInline, VideoInline)
list_display = ('nombre', 'get_categoria_name', 'marca', 'grupo', 'orden', 'visible','modified')
date_hierarchy = 'modified'
list_filter = ('grupo', 'categoria', )
list_editable = ('grupo', 'visible', 'marca', 'orden')
search_fields = ('nombre', 'grupo__nombre' ,'categoria__nombre',)
prepopulated_fields = {"slug": ("nombre",)}
save_on_top = True
form = FileUploadForm
fieldsets = (
(None, {
'fields': (('visible', 'tipo'),
('categoria', 'grupo'),
('nombre', 'slug'),
'marca',
'descripcion',
'imagen_principal',
'imagen',
'ficha_tecnica',
'complementos',
'orden',
),
}),
)
filter_horizontal = ('complementos',)
#row level perms
def queryset(self, request):
qs = super(ProductoAdmin, self).queryset(request)
user = request.user
if user.is_superuser:
return qs
else:
return qs.filter(
Q(categoria__editores=user) |
Q(categoria__padre__editores=user) |
Q(categoria__padre__padre__editores=user) |
Q(categoria__padre__padre__padre__editores=user) |
Q(categoria__padre__padre__padre__padre__editores=user) |
Q(categoria__padre__padre__padre__padre__padre__editores=user) |
Q(categoria__padre__padre__padre__padre__padre__padre__editores=user)
)
def has_change_permission(self, request, obj=None):
if not obj:
return True # So they can see the change list page
return obj.rowlevelpermission(request.user)
has_delete_permission = has_change_permission
#row level perms
from django-moderation.
Could you show how your microgeo\urls.py
look like ? Error you are receiving probably occurs because of circular imports. Have you tried to move moderation.register(Producto)
somewhere else ? ex. create file moderation.py
in side of your app and add it there ?
from django-moderation.
That did the trick (moving moderation.register(Producto)).
Thanks!
from django-moderation.
Related Issues (20)
- django.core.exceptions.ImproperlyConfigured: AUTH_USER_MODEL refers to model 'auth.User' that has not been installed HOT 11
- Get rid of `django-model-utils` library HOT 2
- Moderated objects unavailable even with visible_until_rejected = True HOT 1
- Object-specific template and moderator?
- Notifying users | `changed_by` HOT 2
- Django 3.0.6 HOT 1
- Django 3.0
- [Model] matching query does not exist
- UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9735: ordinal not in range(128)
- Can't choose form for ModerationAdmin
- overtaking `_default_manager`
- New release to PyPi HOT 3
- Drop support for unsupported Django versions HOT 3
- New Release HOT 15
- Support for Django 3.2+ HOT 4
- Sites framework is required for using this package HOT 2
- Drop Django 2.2
- Does not work well with proxy classes HOT 1
- Default manager includes rejected objects HOT 2
- Auto Save New
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-moderation.