Closed magelan closed 13 years ago
Did you put register function in moderator.py module inside of your app ?
You should create moderator.py module inside of your app, please there registration code:
from moderation import moderation
from yourapp.models import YourModel
moderation.register(YourModel)
Next place following code in your main urls.py file:
from moderation.helpers import auto_discover
auto_discover()
Hope that this will solve your problem.
Thanks for you instant reply :-)
I get a new Error: ImportError at /admin cannot import name auto_discover
Caused by these lines in url.py:
from moderation.helpers import auto_discover auto_discover()
Could you paste your urls.py file ?
from django.conf.urls.defaults import * from django.contrib import databrowse from kurse.models import kurs
from django.contrib import admin admin.autodiscover()
from moderation.helpers import auto_discover auto_discover()
urlpatterns = patterns('',
# (r'^bildungswerk/', include('bildungswerk.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
#(r'^admin/gatekeeper/', include('gatekeeper.urls')),
(r'^admin/', include(admin.site.urls)),
(r'^site_media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': 'D:/django/bildungswerk/bilder'}),
(r'^photologue/', include('photologue.urls')),
(r'^filter/', 'kurse.views.chr_filter'),
(r'^alex/', 'kurse.views.kurs_list'),
(r'^form/', 'kurse.views.kurs_form'),
#(r'^databrowse/(.*)', databrowse.site.root),
(r'^new/$', 'django.views.generic.create_update.create_object', { 'model': kurs } ),
)
What version of django-moderation are you using ? are you using version from pypi ? If you can please use version from github.
oh, sorry. Formating gets changed by github
I tried "from moderation.helpers import auto_discover" and there seems to be not auto_discover in moderation.helpers
This is because you are using older version of django-moderation, please update to version from github.
I used easy_install django-moderation before, and now downloaded 0.3.1 but I'm still not quite shure what version I have installed. But the "from moderation.helpers import auto_discover" error is gone now.
RegistrationError at /admin/kurse/kurs/add/
Have you removed "moderation.register(kurs)" from your models.py file ?
yes, I did.
when I change the admin.py back to: "class kursAdmin(admin.ModelAdmin)" instead of "class kursAdmin(ModerationAdmin):" I get no errors, but kurs objects are not moderated either ;-)
I removed south and did syncdb and now get a different error. AttributeError at /admin/kurse/kurs/1/ 'kurs' object has no attribute 'moderated_object'
It seems I have version 0.2, even so I downloaded and install 0.3.1: c:\python26\lib\site-packages\django_moderation-0.2-py2.6.egg\moderation\forms.py in init, line 14
How can I get the latest version?
You have wrong version on your PYTHONPATH. You need remove directory c:python26libsite-packagesdjango_moderation-0.2-py2.6.egg
Download https://github.com/dominno/django-moderation/tarball/v0.3.2
extract it and run:
python setup.py install
Thanks for not giving up. I have done that before many times with different versions and also removed the Line in easy-install.pth, but when ever I do an install it end with this message: Using c:\python26\lib\site-packages Finished processing dependencies for django-moderation==0.2 Even with the version 0.3.2 direktly from your Link. Maybe the Messages are not up to date.
You can also clone a repo and add moderation module to PYTHONPATH
git clone git://github.com/dominno/django-moderation.git
Ok tried that as well, and should have to newest Version avaliable. Error still: AttributeError at /admin/kurse/kurs/2/ 'kurs' object has no attribute 'moderated_object'
Could you paste full tracebug for this ?
File "C:\Python26\lib\site-packages\django\contrib\admin\options.py" in wrapper
Exception Type: AttributeError at /admin/kurse/kurs/2/ Exception Value: 'kurs' object has no attribute 'moderated_object'
I wonder how the moderator.py file gets executed? Is that done but
from moderation.helpers import auto_discover auto_discover()
Or do I have to import that file somewhere?
it is done by this auto_discover
function
magelan, have you resolved your issue yet?
moderation.register
may only be run once for each model. This is why it's typically put in moderator.py
, a file which is never imported anywhere else to avoid collisions (auto_discover
will import it automatically). Search all of your project's files and make sure that moderation.register
is not called anywhere except in your moderator.py
file. Additionally, make sure that moderator.py
is not being imported anywhere in your application (just like admin.py
should never be imported anywhere).
Also make sure that auto_discover
is not being called anywhere else and urls.py
is not being imported anywhere. Because register
can only be called once, the file it is called in and all files that reference that one (indirectly through auto_discover
in this case) can only be called once as well. Since urls.py
is called by Django once and moderator.py
, it can't be imported anywhere else.
If the 'kurs' object has no attribute 'moderated_object'
error you were receiving was from the command line you would need to import moderator.py
or your urls file manually. For example:
from kurse import moderator
If it was not, please make sure your application is in INSTALLED_APPS
in settings.py
and you have a proper moderator.py
file in your application that calls moderation.register
for your model.
Hi,
no unfortuneatly not. I checked everything in your post, and everything was correct. I'm not aware that I changed anything, but now I get a new error. It only appears if I try to add or change an object that is supposed to be moderated.
error at /admin/kurse/kurs/1/
(10061, 'Es konnte keine Verbindung hergestellt werden, da der Zielcomputer die Verbindung verweigerte')
for some reason it is in German, and says "Connection could not established, because the host Computer refused the connection"
Any other idea or something else I could try?
Full error: http://dpaste.com/539124/
That looks like an issue with your email configurations.
Bingo! Everything works now. Thanks a lot for you work and support.
Hi,
I installed and configured moderation according to the readme and get this Error:
RegistrationError at /admin/kurse/kurs/add/
<class 'kurse.models.kurs'> has been registered with Moderation.
I found the same error in Issues here, but could not solve it. I even complety fail to understand why this is an problem, since I am indeed registering this class with Moderation. Maybe you have an idea. Thanks for your Time.