OK, tried all that, got pretty much the same results: >> import bookmarks >>> dir(bookmarks) ['__builtins__', '__doc__', '__file__', '__name__', '__path__', 'models'] >>> bookmarks.__file__ '/home/chrisamico/lib/python2.5/bookmarks/__init__.pyc' >>> from bookmarks import templatetags >>> dir(templatetags) ['__builtins__', '__doc__', '__file__', '__name__', '__path__'] >>> templatetags.__file__ '/home/chrisamico/lib/python2.5/bookmarks/templatetags/__init__.pyc' >>> from bookmarks.templatetags import bookmark_tags > /home/chrisamico/lib/python2.5/bookmarks/templatetags/bookmark_tags.py(4)<module>() -> from bookmarks.models import Bookmark (Pdb) from bookmarks.models import Bookmark *** ImportError: No module named models
Outside the debugger (in python manage.py shell): >>> from bookmarks.models import Bookmark >>> So it's only hitting the import error within bookmark_tags.py. Here's the directory structure: *bookmarks __init__.py admin.py models.py views.py *templatetags __init__.py bookmark_tags.py On Oct 16, 12:56 am, felix <[EMAIL PROTECTED]> wrote: > oh well. > > check that you have an __init__.py file in the templatetags directory > > try this: > in bookmark_tags.py (and do keep the name that way, or later you will be > caught by this) > > right before the import line throw it in into the debugger: > > import pdb; pdb.set_trace() > > in the debugger try: > > >>> import bookmarks > >>> dir(bookmarks) > >>> bookmarks.__file__ > > if you can't even import bookmarks then its not actually on your python > path. remember that your python path needs to include the directory > directly above the bookmarks app. > > f;lix > > On Thu, Oct 16, 2008 at 4:53 AM, Chris Amico <[EMAIL PROTECTED]> wrote: > > > Tried that. Still no good. I renamed the file as bookmark_tags.py and > > deleted every .pyc file in the app. Nothing in my templatetags > > directory actually compiled--neither __init__.py nor bookmarks.py > > (even after being renamed). > > > Like I said before, when I take out the import line (from > > bookmarks.models import Bookmark) the library loads (even when called > > bookmarks.py) and only hits an error when it tries to access > > Bookmark.objects.all(). > > > On Oct 15, 6:22 pm, felix <[EMAIL PROTECTED]> wrote: > > > this gets me every time. > > > > the error is yes because the template tag is called bookmarks.py > > > and its inside a module called bookmarks.py > > > > rename it to bookmarks_tags.py ... > > > > and now .... > > > > DELETE THE DAMNED OLD bookmarks.pyc file ! > > > > python is still finding the old compiled file. > > > > its happened to me twice already in the exact same fashion. > > > > -f;lix > > > > On Oct 15, 7:17 pm, Chris Amico <[EMAIL PROTECTED]> wrote: > > > > > The templatetag file is indeed called bookmarks.py. I thought of that, > > > > tried renaming it as bookmark_tags.py, and got the same error. I'll > > > > add that the bookmarks app lives on my python path, not in any > > > > particular project, since I'm trying to make this as reusable as > > > > possible. > > > > > At one point, I tried just removing the line 'from bookmarks.models > > > > import Bookmark', and the library loaded, but it hit an error > > > > (correctly) when I tried use it, saying Bookmark wasn't defined. > > > > > On Oct 14, 11:45 pm, Daniel Roseman <[EMAIL PROTECTED]> > > > > wrote: > > > > > > On Oct 15, 7:38 am, Chris Amico <[EMAIL PROTECTED]> wrote: > > > > > > > I have a simple bookmarks model based on the one in James Bennett's > > <a > > > > > > href="http://code.google.com/p/cab/source/browse/trunk/models.py? > > > > > > r=130">Cab</a> application. I'm using a generic relation so it can > > > > > > live in its own app and a user can bookmark any object on the site > > > > > > (I'm planning on reusing this app on a couple projects). I'm > > running > > > > > > into a problem creating an {% if_bookmarked %}templatetag. > > > > > > > When I load the tag library I get this error: 'bookmarks' is not a > > > > > > valid tag library: Could not loadtemplatelibrary from > > > > > > django.templatetags.bookmarks,Nomodulenamedmodels > > > > > > > Here's what the tagmodulelooks like: > > > > > > <snip> > > > > > > > The bookmarking model works fine on its own, and I've gotten the > > > > > > functions in thetemplatetag to work in isolation in the > > interpreter, > > > > > > but when I load the tag library it breaks thetemplate. What am I > > > > > > missing here? > > > > > > Is the templatetag file itself called bookmarks.py, by any chance? If > > > > > so, the code may be trying to import that rather than the top-level > > > > > bookmarks directory. Try renaming the file, although I would also > > > > > recommend using full paths when importing (ie from > > > > > projectname.bookmarks.models). > > > > > -- > > > > > DR --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---