views:

566

answers:

2

I have an issue where, when I log in to the Django admin site, I get a template syntax error in /Library/Python/2.6/site-packages/django/template/debug.py in render_node, line 81.

I can't find out how to solve this as it is part of Django, I didn't write the code and I have no idea how it works.

This did work fine up until a few days ago when I last tried it.

The error is: Caught an exception while rendering: name 'pest' is not defined Where pest is the name of my project. As far as I know, I have all the apps in my project installed correctly.

Thanks in advance!

+1  A: 

It seems like an error in the admin.py file for your app.

It may be a missing import, or even a typo, but it's hard to tell without any code. It would be great if you could post your admin.py file so we can take a look.

TemplateSyntaxErrors in Django are terrible, they almost never tell you what the real problem is. In this case, for example, the template is part of Django, but the error is probably something in your admin file, which Django reads to create the admin interface. The traceback is too deep to find out right away where in your code the problem is.

Flávio Amieiro
Thank you, I will check all the admin.py files that I have in the project. It must be something I have done as I haven't edited the Django installation at all and it was working until today. Unfortunately, I have written 600 lines today and don't know at what point it went wrong.
danpalmer
@danpalmer If you are using any SCM, you can go back in time and see when you broke it, than just figure out what was the difference. Anyway, as I said, it's most likely a typo or an import error.
Flávio Amieiro
It fails on this line in the template:{% url django-admindocs-docroot as docsroot %}The admin.py file (the one I have added since it last worked) is really basic though:from django.contrib import adminfrom pest.error_logging.models import Erroradmin.site.register(Error)
danpalmer
@flavio-amieiro I am using subversion, but not as well as I should be and I think it was part of a massive commit where I added an entire new app to the project :(
danpalmer
@flavio-amieiro Also, there are 28 items in the traceback and all are in the Django code, not in my own.
danpalmer
@danpalmer Is pest in your python path? Try importing pest.error_logging.models from a shell (in the same dir as the admin.py file is). This will at least tell you if it is an import error in this file.
Flávio Amieiro
A: 

It turns out it was a rather simple thing, I am just not experienced enough with Python and I was calling on my .NET experience. Bad mistake.

I called project.settings.SETTING where I should have imported project.settings and then accessed settings.SETTING.

In .NET the imports act just shortcuts so you don't have to type the whole 'path' to the function or setting, whereas in Python it seems that you must have the things you are using imported.

I don't know if that makes any sense, or if it even correct, but it now works. Thanks for everyone's help, you are always a great help and I wouldn't be able to do this development and advance my knowledge without the resources here.

danpalmer