feincms / feincms-elephantblog

A blog for FeinCMS
feinheit.ch/labs/
BSD 3-Clause "New" or "Revised" License
42 stars 38 forks source link

Urls not working on initial setup when using as Application Content with FeinCMS #19

Closed colinkahn closed 11 years ago

colinkahn commented 12 years ago

This is a problem me and a coworker of mine both faced on separate projects using ElephantBlog as Application Content with FeinCMS. It seems that neither method of registering elephantblog works correctly. The two methods i've tried are:

Page.create_content_type(ApplicationContent, APPLICATIONS=(
    ('elephantblog', _('Blog'), {'urls': 'elephantblog.urls'}),
))

and,

Page.create_content_type(ApplicationContent, APPLICATIONS=(
    ('elephantblog.urls', _('Blog')),
))

When using the first example the absolute urls for entries are not generated (this is with the recommended absolute url overrides in the settings file fyi). In the second case nothing will show up on my blog page and previewing entries from the admin will give a 404.

The only way I've gotten it to work is by using one of these then switching it to the other. But from a fresh install neither work as expected.

sbaechler commented 12 years ago

Could you give me more informations? I use the second case and it's working well. Which version of FeinCMS and Elephantblog are you using?

colinkahn commented 12 years ago

Here's the pip freeze from my project. I've basically forked https://github.com/rdegges/django-skel and am trying to add FeinCMS and ElephantBlog as well. Everything works fine except ElephantBlog. I can also send you a zipped version of the template i'm actually using if you feel that will help. Thanks :)

Django==1.4.1
Fabric==1.4.2
FeinCMS==1.6.1
Jinja2==2.6
PIL==1.1.7
PyJWT==0.1.2
Pygments==1.5
South==0.7.6
Sphinx==1.1.3
distribute==0.6.28
django-appconf==0.5
django-classy-tags==0.3.4.1
django-compressor==1.2
django-debug-toolbar==0.9.4
django-jsonfield==0.8.11
django-mptt==0.5.1
django-rawinclude==0.1
django-reversion==1.6.1
django-sekizai==0.6.1
django-taggit==0.9.3
django-tastypie==0.9.11
django-watson==1.1.1
docutils==0.9.1
feincms-elephantblog==0.1.0
httplib2==0.7.6
ipython==0.13
mimeparse==0.1.3
oauth2==1.5.211
pycrypto==2.6
python-dateutil==1.5
python-twitter==0.8.2
readline==6.2.2
redis==2.6.0
simplejson==2.6.1
ssh==1.7.14
wsgiref==0.1.2
simonkern commented 12 years ago

same here btw the documentation is inconsistent. In the urls.py itself it says: " Page.create_contenttype(ApplicationContent, APPLICATIONS=( ('elephantblog', ('Blog'), {'urls': 'elephantblog.urls'}), ))

"

In the documentation it says: " from feincms.content.application.models import ApplicationContent

init your Page object here

Page.create_content_type(ApplicationContent, APPLICATIONS=( ('elephantblog.urls', 'Blog'), ))"

sbaechler commented 12 years ago

Can you try the newest version (0.3) from github? There has been a big change from 0.1 to 0.2. Maybe that is the problem. If it works I'll update the pypi version.

pip install -e git://github.com/feincms/feincms-elephantblog.git#egg=elephantblog

simonkern commented 12 years ago

Done. It's the sam error as before:

Everything up to www.example.com/blog/2012/09/25/ and www.example.com/blog/category/allgemein/ is working.

The only thing broken is: www.example.com/blog/2012/09/25/testeintrag/

In addition the navigation extension shows no more categories now :-p

simonkern commented 12 years ago

forget about the navigation extension ;-) i had to add "treeinfo" to the import thats all ;)

but the detailview still does not work :(

simonkern commented 12 years ago

    {% feincms_render_region object "main" request %}

this is what causes the error: 'str' object has no attribute 'feincms_render_level'

//EDIT

adding the following to my settings.py fixed it


TEMPLATE_CONTEXT_PROCESSORS = (
    'django.contrib.auth.context_processors.auth',
    'django.core.context_processors.request',
)

matthiask commented 12 years ago

Exactly -- the request context processor is required for the feincms_render_... tags.

colinkahn commented 12 years ago

This doesn't seem to be the case for my original issue. I do have the context processors added, and also have tried it using the 0.3 github version with no luck.

matthiask commented 12 years ago

@colinkahn Can you post the ABSOLUTE_URL_OVERRIDES and the Page.create_content_type(ApplicationContent, ...) code somewhere? I'd like to take a look at it, maybe I can see something wrong with your or our code.

colinkahn commented 12 years ago

Of course, here's a gist: https://gist.github.com/3801247

matthiask commented 12 years ago

Alright, I cannot see anything wrong with that.

What's the output of running the following commands in the ./manage.py shell (assuming you have at least one entry and one category defined)?

from elephantblog.models import *
Entry.objects.all()[0].get_absolute_url()
Category.objects.all()[0].get_absolute_url()
colinkahn commented 12 years ago

Here's the output. On the frontend nothing shows up on my Blog FeinCMS page (IE, that page is there, just nothing on it), and I get a 404 if i try to manually enter the path to the ElephantBlog post or category.

In [1]: from elephantblog.models import *

In [2]: Entry.objects.all()[0].get_absolute_url()
/Users/colinkahn/code/project/lib/python2.7/site-packages/elephantblog/feeds.py:11: UserWarning: BLOG_TITLE and/or BLOG_DESCRIPTION not defined in settings.py. Standard values used for the Feed
  warnings.warn('BLOG_TITLE and/or BLOG_DESCRIPTION not defined in settings.py. Standard values used for the Feed')
Out[2]: '/blog/2012/09/19/hello-world/'

In [3]: Category.objects.all()[0].get_absolute_url()
Out[3]: '/blog/category/default/'
sbaechler commented 12 years ago

Have you changed the URLs since adding the blog Application content to the page? Try removing, saving and re-adding the Application content to the blog page. The languages of the page and the blog entry have to match as well. Usually we put the blog page within the base language tree. As in /en/blog/.

colinkahn commented 12 years ago

@sbaechler I'm trying all of this from fresh installs using a django project template.

I think I found the issue though. It seems part of it is that I didn't have USE_TZ = True in my settings file. After updating my template with that and installing it I was still getting the same issue though. So, I created a page.json fixture from my working test install for the Blog FeinCMS page that had the ApplicationContent already set. I also included pytz in my req's file. Doing a clean install and then loading my fixture all seems to be working.

I'm not sure if any of that constitutes a bug on ElephantBlogs part, I haven't tried digging in deep enough to attempt to figure out why changing USE_TZ to True and loading the blog in a fixture solved the problem

sbaechler commented 12 years ago

I just added tests for USE_TZ=False and they passed as well. I still think the problem was that the entry for page_applicationcontent in the database was somehow corrupt. The value stored there is the path to the URL conf.