Skip to content

Commit

Permalink
Make the app work without django.core.context_processors.request too
Browse files Browse the repository at this point in the history
Fixes: #8
  • Loading branch information
vdboor committed Dec 6, 2012
1 parent da56456 commit e212b22
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
8 changes: 0 additions & 8 deletions example/settings.py
Expand Up @@ -59,14 +59,6 @@
'django.contrib.messages.middleware.MessageMiddleware',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.request',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)

ROOT_URLCONF = 'urls'

Expand Down
16 changes: 13 additions & 3 deletions fluent_comments/templatetags/fluent_comments_tags.py
@@ -1,3 +1,4 @@
from django.conf import settings
from django.template import Library
from django.core import context_processors
from fluent_comments.models import get_comments_for_model
Expand All @@ -10,10 +11,19 @@ def ajax_comment_tags(context):
"""
Display the required ``<div>`` elements to let the Ajax comment functionality work with your form.
"""
request = context['request']
new_context = {
'STATIC_URL': context.get('STATIC_URL', None)
}

# Be configuration independent:
if new_context['STATIC_URL'] is None:
try:
request = context['request']
except KeyError:
new_context.update({'STATIC_URL': settings.STATIC_URL})
else:
new_context.update(context_processors.static(request))

new_context = {}
new_context.update(context_processors.static(request))
return new_context


Expand Down

0 comments on commit e212b22

Please sign in to comment.