Caught AssertionError while rendering: latest() #126

Closed
justinm715 opened this Issue Jan 31, 2012 · 15 comments

Projects

None yet

4 participants

@justinm715

I am getting the following message. "TemplateSyntaxError at /admin/zinnia/ - Caught AssertionError while rendering: latest() requires either a field_name parameter or 'get_latest_by' in the model" Here is the Traceback: http://pastebin.com/2EqzPb84 I have installed Zinnia using "pip install -e git:/...", which means I have version 0.10. I get this error when I visit /en/admin/zinnia/. I tried executing "Entry.published.latest()" in the django shell and I get the same message.

Owner

Hi,

I have tried to reproduce the bug, but I cannot.
Even if I do a Entry.published.latest() in the django shell.

The traceback seems to say that the get_latest_by attribute is not defined, but the Entry's Meta class define the get_latest_by attribute to creation_date.

Have you done a extension of the Entry model ?

I am not sure what is wrong with my installation. I have not extended the Entry model. I deleted all my posts and disabled my own cms plugins to make sure my stuff wasn't inadvertently causing some kind of mysterious interference. I then made some entries, saved them as drafts, visited /admin/zinnia/ and did not get any errors. When I changed one of these entries to published and visited /admin/zinnia/ I got the error.

I think I managed to fix it, though. I added the following function to class EntryPublishedManager in zinnia/managers.py and the error is gone.

def latest(self):
    return self.get_query_set().order_by('-creation_date')[0]
Owner

What is your version of Django ?

I have Django 1.3.1

Owner

I don't understand why the manager cannot find this standard method...

Any possibility to provide me an ssh access to take a look with my own eyes on this really strange issue?
I'm asking this because I can't reproduce locally the problem.

I can't really give SSH access (or I am too lazy to figure it out). It's inside a server inside a virtual box instance on my local machine. I don't know why it's doing that either. I re-installed zinnia (using the same django module) and it's doing it again. Perhaps it is just me and I screwed something up, but it is only a minor inconvenience as I don't really go to that page anyway. Please don't trouble yourself with it. Thank you for the help, though.

Owner

Ok I understand that you cannot give an ssh access, no problems.
So I will close the issue until further information.

@Fantomas42 Fantomas42 closed this Feb 9, 2012
thanos commented Mar 20, 2012

I' just got the same issue. This is vanilla & django-cms installation.

^Croot@li394-186:/opt/infinigon/lambdafx# pip freeze
Warning: cannot find svn location for distribute==0.6.16dev-r0
BeautifulSoup==3.2.1
Django==1.3.1
GnuPGInterface==0.3.2
PAM==0.4.2
PIL==1.1.7
South==0.7.3
Twisted-Core==11.0.0
apt-xapian-index==0.44
chardet==2.0.1

FIXME: could not find svn URL in dependency_links for this package:

distribute==0.6.16dev-r0
-e git://github.com/Fantomas42/django-blog-zinnia.git@f9621d6#egg=django_blog_zinnia-dev
django-classy-tags==0.3.4.1
django-cms==2.2
django-cms-themes==1.0.8
django-mptt==0.5.1
django-sekizai==0.5
django-tagging==0.3.1
django-tinymce==1.5.1b2
django-xmlrpc==0.1.3
html5lib==0.95
httplib2==0.7.2
iotop==0.4.3
keyring==0.6.2
launchpadlib==1.9.8
lazr.restfulclient==0.11.2
lazr.uri==1.0.2
oauth==1.0.1
pexpect==2.3
psycopg2==2.4.1
pyOpenSSL==0.12
pycrypto==2.3
pycurl==7.19.0
pyparsing==1.5.6
pyserial==2.5
python-apt==0.8.0ubuntu9
python-debian==0.1.20ubuntu2
simplejson==2.1.6
smart==1.4
ufw==0.30.1-2ubuntu1
wadllib==1.2.0
wsgiref==0.1.2
zope.interface==3.6.1

wmsmith commented Apr 5, 2012

This issue is affecting me as well; I do not know what it is about our setups that are causing it, but I do know that, in the zinnia_statistics() tag in zinnia/templatetags/zinnia_tags.py, the 'first_entry' and 'last_entry' variables seem to be Entry instances, their Meta attributes are objects of type cmsplugin_zinnia.placeholder.Meta, which does not inherit from Entry.

Is there any reason for EntryPlaceholder.Meta to not inherit EntryAbstractClass.Meta? Currently it does not, and adding it made everything work for me.

Owner

Hi,
thank you wmsmith for your explanation, everything seems logic now.
It's a known bug of the EntryPlaceholderModel since Zinnia extends the Meta class of the Entry model.

The good news is that the bug is already fixed in django-blog-zinnia/cmsplugin-zinnia@63a3fc5 but you have to use cmsplugin_zinnia instead of zinnia.plugins because the module has been removed in the latest versions of Zinnia.

Regards

wmsmith commented Apr 6, 2012

Ahh...didn't know it was a known bug...sorry.

I am using cmsplugin_zinnia, but I had not updated to the latest master of cmsplugin_zinnia...any chance of a new release on pypi? It currently has 0.1, but that version does not have the patch.

Thanks for your prompt reply!

Owner

@wmsmith you are right the 0.1 version does not have the patch...

But the release 0.2 for cmsplugin_zinnia is planned in few days.

wmsmith commented Apr 6, 2012

Sounds great; thanks!

Owner

The version 0.2 is now released on Pypi.
It takes me less time than I expected.

wmsmith commented Apr 6, 2012

Nice! Editing my pip requirements file now....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment