views:

47

answers:

1

I'm using

{% url facebook_xd_receiver %} 

in one of my HTML files. This works just fine when I run my project using the command

python manage.py runserver

But the same project stops running and gives me a "TemplateSyntaxError" at the line {% url facebook_xd_receiver %}

Can anyone please tell me what could be the difference between the dev server run through the command line and the apache server.

Is there anything I'm missing out on while configuring the Apache server? Or is it a Django problem?

EDIT: Actual report -

Environment:

Request Method: GET
Request URL: http://helvetica/djangonyc/exampleapp/
Django Version: 1.1.1
Python Version: 2.6.4
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'djangonyc.exampleapp',
 'djangonyc.facebookconnect']
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
 'facebook.djangofb.FacebookMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'facebookconnect.middleware.FacebookConnectMiddleware')


Template error:
In template /home/swat/website-apps/djangonyc/facebookconnect/templates/facebook/js.html, error at line 2
   Caught an exception while rendering: No module named app.models
   1 : <script type="text/javascript">

   2 :     FB_RequireFeatures(["XFBML"], function() {FB.Facebook.init("{{ facebook_api_key }}", " {% url facebook_xd_receiver %} ")});

   3 : 

   4 :     function facebookConnect(loginForm) {

   5 :         FB.Connect.requireSession();

   6 :         FB.Facebook.get_sessionState().waitUntilReady(function(){loginForm.submit();});

   7 :     }

   8 :     function pushToFacebookFeed(data){

   9 :         if(data['success']){

   10 :             var template_data = data['template_data'];

   11 :             var template_bundle_id = data['template_bundle_id'];

   12 :             feedTheFacebook(template_data,template_bundle_id,function(){});

Traceback:
File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response
  92.                 response = callback(request, *callback_args, **callback_kwargs)
File "/home/swat/website-apps/djangonyc/exampleapp/views.py" in index
  19.         context_instance=RequestContext(request)
File "/usr/lib/pymodules/python2.6/django/shortcuts/__init__.py" in render_to_response
  20.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "/usr/lib/pymodules/python2.6/django/template/loader.py" in render_to_string
  108.     return t.render(context_instance)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
  178.         return self.nodelist.render(context)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
  779.                 bits.append(self.render_node(node, context))
File "/usr/lib/pymodules/python2.6/django/template/debug.py" in render_node
  71.             result = node.render(context)
File "/usr/lib/pymodules/python2.6/django/template/loader_tags.py" in render
  97.         return compiled_parent.render(context)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
  178.         return self.nodelist.render(context)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
  779.                 bits.append(self.render_node(node, context))
File "/usr/lib/pymodules/python2.6/django/template/debug.py" in render_node
  71.             result = node.render(context)
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
  946.                             autoescape=context.autoescape))
File "/usr/lib/pymodules/python2.6/django/template/__init__.py" in render
  779.                 bits.append(self.render_node(node, context))
File "/usr/lib/pymodules/python2.6/django/template/debug.py" in render_node
  81.             raise wrapped

Exception Type: TemplateSyntaxError at /djangonyc/exampleapp/
Exception Value: Caught an exception while rendering: No module named app.models
+2  A: 

The actual error message is this:

Caught an exception while rendering: No module named app.models

So somewhere in your code you are trying to import app.models, which either doesn't exist or isn't on your pythonpath. The reason this happens during url reversing is that in order to find all the possible URLs, Django imports all the views - and apparently one of them has an error.

Daniel Roseman
+1 to doublecheck PYTHONPATH.
istruble