evildmp / Arkestra

Arkestra extends Django CMS to provide an intelligent semantic web publishing system for organisations and institutions.
http://arkestra-project.org
BSD 2-Clause "Simplified" License
139 stars 27 forks source link

TemplateSyntaxError at /news/<id> (newsarticle.get_template) #40

Closed konr4d closed 11 years ago

konr4d commented 12 years ago

I get:

TemplateSyntaxError at /news/long-title/ Invalid template name in 'extends' tag: ''. Got this from the 'newsarticle.get_template' variable.

while trying to access news from the list.

Whole trace:

Request Method: GET Request URL: http://localhost:8000/news/long-title/

Django Version: 1.4 Python Version: 2.7.3 Installed Applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.humanize', 'django.contrib.messages', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.sitemaps', 'django.contrib.flatpages', 'south', 'cms', 'mptt', 'menus', 'sekizai', 'cms.plugins.file', 'cms.plugins.picture', 'cms.plugins.teaser', 'cms.plugins.text', 'cms.plugins.video', 'cms.plugins.twitter', 'arkestra_utilities', 'contacts_and_people', 'vacancies_and_studentships', 'news_and_events', 'links', 'arkestra_utilities.widgets.combobox', 'arkestra_image_plugin', 'video', 'housekeeping', 'polymorphic', 'semanticeditor', 'easy_thumbnails', 'typogrify', 'filer', 'widgetry', 'sieci_cms.news', 'sieci_cms.people', 'sieci_cms.projects') Installed Middleware: ('django.middleware.gzip.GZipMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware', 'cms.middleware.multilingual.MultilingualURLMiddleware', 'cms.middleware.page.CurrentPageMiddleware', 'cms.middleware.user.CurrentUserMiddleware', 'cms.middleware.toolbar.ToolbarMiddleware')

Template error: In template /home/konrad/work/pjwstk/sieci_cms/libs/news_and_events/templates/news_and_events/newsarticle.html, error at line 1 Invalid template name in 'extends' tag: ''. Got this from the 'newsarticle.get_template' variable. 1 : {% extends newsarticle.get_template %} 2 : {% load arkestra_date_tags typogrify_tags humanize thumbnail placeholder_tags %} 3 : 4 : {% block title %} 5 : {{ newsarticle }} 6 : {% endblock %} 7 : 8 : {% block nav_local %} 9 : {% endblock nav_local %} 10 : 11 : {% block pagetitle %}

Traceback: File "/home/konrad/work/pjwstk/sieci_cms/libs/django/core/handlers/base.py" in get_response

  1. response = callback(request, _callback_args, *_callback_kwargs) File "/home/konrad/work/pjwstk/sieci_cms/libs/news_and_events/views.py" in newsarticle
  2. RequestContext(request), File "/home/konrad/work/pjwstk/sieci_cms/libs/django/shortcuts/init.py" in render_to_response
  3. return HttpResponse(loader.render_to_string(_args, *_kwargs), **httpresponse_kwargs) File "/home/konrad/work/pjwstk/sieci_cms/libs/django/template/loader.py" in render_to_string
  4. return t.render(context_instance) File "/home/konrad/work/pjwstk/sieci_cms/libs/django/template/base.py" in render
  5. return self._render(context) File "/home/konrad/work/pjwstk/sieci_cms/libs/django/template/base.py" in _render
  6. return self.nodelist.render(context) File "/home/konrad/work/pjwstk/sieci_cms/libs/django/template/base.py" in render
  7. bit = self.render_node(node, context) File "/home/konrad/work/pjwstk/sieci_cms/libs/django/template/debug.py" in render_node
  8. return node.render(context) File "/home/konrad/work/pjwstk/sieci_cms/libs/django/template/loader_tags.py" in render
  9. compiled_parent = self.get_parent(context) File "/home/konrad/work/pjwstk/sieci_cms/libs/django/template/loader_tags.py" in get_parent
  10. raise TemplateSyntaxError(error_msg)

Exception Type: TemplateSyntaxError at /news/long-title/ Exception Value: Invalid template name in 'extends' tag: ''. Got this from the 'newsarticle.get_template' variable.

evildmp commented 12 years ago

On Tue, Jul 10, 2012, Konrad Adamczyk reply+i-5531608-e1d65f88ae78b9b4c8eb460f372057c580fd3034-86222@reply.github.co wrote:

I get:

Invalid template name in 'extends' tag: ''. Got this from the 'newsarticle.get_template' variable. 1 : {% extends newsarticle.get_template %}

What's happening here is that the newsarticle needs to know which base template to use, and though get_template() should always be able to work one out it obviously hasn't, somehow.

If you can get on to #arkestra on irc.freenode.net, I am sure we can pin this down quickly - it is almost certainly a minor configuration matter.

Otherwise, do try the newer pip branch, and the instructions at

https://github.com/evildmp/Arkestra/blob/pip/docs/getting_started/installation.rst

They make it much easier to get started.

Still:

https://github.com/evildmp/Arkestra/blob/pip/arkestra_utilities/generic_models.py#L67

This is get_template():

@property
def get_template(self):
    return self.get_hosted_by.get_template()    

Which calls:

@property
def get_hosted_by(self):
    return self.hosted_by or default_entity

So it finds the Entity hosting this item, which is either the explicitly set hosted_by field for the NewsArticle, or failing that the default_entity (defined in settings).

Once it has worked out the Entity, it wants Entity.get_template().

https://github.com/evildmp/Arkestra/blob/pip/contacts_and_people/models.py#L392

def get_template(self):
    """
    Returns a template for any pages that need to render based on this entity
    """
    if self.get_website:
        return self.get_website.get_template()
    else:
        return default_entity.get_website.get_template()

If the Entity has a cms.Page as its website field, then do cms.Page.get_template(); if not, return the website template of your site's default_entity.

This means that every Akrestra site must have a default_entity; in the example project it's defined here:

https://github.com/evildmp/Arkestra/blob/pip/example_14/example_14/arkestra_settings.py#L14

evildmp commented 11 years ago

Can't replicate.