开发者

Django Admin site TemplateSyntaxError at /admin/: name not defined

开发者 https://www.devze.com 2022-12-17 05:14 出处:网络
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 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!


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消