straight55b / app-engine-patch

Automatically exported from code.google.com/p/app-engine-patch
0 stars 0 forks source link

Unable to import app in app templatetag functions #245

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.  for example, if we add "templatetags" directory in "myapp" folder, and
add in __init__.py and myapp_tags.py file
2.  in myapp_tags.py file, we define our templatetag function (e.g. def
show_person) and tries to import "from myapp.models import Person"
3.  in our template, say "base.html", if we attempt to {% load myapp_tags
%} and call the {% show_person %} custom templatetag, we get an error that
says that we cannot import from django.templatetags.myapp.

What is the expected output? What do you see instead?
Well, the import call in my templatetag function should work and should not
be giving me this error.

What version of the product are you using? On what operating system?
Happens on both linux and windows.

Please provide any additional information below.

Original issue reported on code.google.com by linchuan...@gmail.com on 4 Dec 2009 at 3:35

GoogleCodeExporter commented 9 years ago
Maybe this is a circular import problem?

I'm still a relative newbie to Python, but I sometime resolved importation 
problems by 
using "import xxx" vs "From xxx import yyy".

I believe "import" create a unique "space" for the imported elements, thus 
preventing 
some problems associated to circular imports.

Original comment by sebastie...@gmail.com on 7 Dec 2009 at 7:58