I get two specific errors: One resulting from the block:
def save(self, force_insert=False, force_update=False): from markdown import markdown from smartypants import smartypants self.copy_html = smartypants(markdown(self.copy, ['abbr', 'headerid(level=2)'])) super(Entry, self).save(force_insert=False, force_update=False) The code works if I remove only 'smartypants(' in the 4th line. Running this in shell does not throw errors: from django.db import models copy = models.TextField() copy_html = models.TextField(blank=True) def save(self, force_insert=False, force_update=False): from markdown import markdown from smartypants import smartypants self.copy_html = smartypants(markdown(self.copy, ['abbr', 'headerid(level=2)'])) super(Entry, self).save(force_insert=False, force_update=False) ---------------- If I then try to use this template; I get another error: {% extends "base.html" %} {% load typogrify %} {% block content %} {{ entry.title|smartypants }} {% endblock %} results in: Environment: Request Method: GET Request URL: http://127.0.0.1:8000/blog/ Django Version: 1.1.1 Python Version: 2.6.5 Installed Applications: ['django.contrib.auth', 'django.contrib.comments', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sitemaps', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.redirects', 'south', 'compress', 'participationgraphs', 'typogrify', 'smartypants', 'hwo.apps.blog', Installed Middleware: ('django.middleware.http.ConditionalGetMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.gzip.GZipMiddleware', 'staticgenerator.middleware.StaticGeneratorMiddleware', 'flother.utils.middleware.http.SetRemoteAddrFromForwardedFor') Template error: In template /mnt/hgfs/Web/django/flother/apps/blog/templates/blog/ entry_index.html, error at line 5 Caught an exception while rendering: 'module' object has no attribute 'smartyPants' 1 : {% extends "base.html" %} 2 : {% load typogrify %} 3 : 4 : {% block content %} 5 : {{ entry.title|smartypants|widont }} 6 : {% endblock %} 7 : 8 : Traceback: File "/usr/lib/pymodules/python2.6/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/mnt/hgfs/Web/django/flother/apps/blog/views.py" in entry_index 23. 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/loader_tags.py" in render 24. result = 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 24. result = 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 81. raise wrapped Exception Type: TemplateSyntaxError at /blog/ Exception Value: Caught an exception while rendering: 'module' object has no attribute 'smartyPants' Original Traceback (most recent call last): File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 71, in render_node result = node.render(context) File "/usr/lib/pymodules/python2.6/django/template/debug.py", line 87, in render output = force_unicode(self.filter_expression.resolve(context)) File "/usr/lib/pymodules/python2.6/django/template/__init__.py", line 572, in resolve new_obj = func(obj, *arg_vals) File "/usr/local/lib/python2.6/dist-packages/typogrify/templatetags/ typogrify.py", line 180, in smartypants output = smartypants.smartyPants(text) AttributeError: 'module' object has no attribute 'smartyPants' Now for some reason importing typogrify gives the following error: hi...@hidde-desktop:/mnt/hgfs/Web/django/flother$ ./manage.py shellPython 2.6.5rc2 (r265rc2:78822, Mar 11 2010, 13:01:50) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> from typogrify import typogrify Traceback (most recent call last): File "<console>", line 1, in <module> ImportError: cannot import name typogrify >>> from typogrify.templatetags.typogrify import typogrify >>> I've run out of ideas. Something is funky, but I have no clue what. On Apr 15, 7:25 am, johan sommerfeld <johan.sommerf...@gmail.com> wrote: > Have you tried to run the actual code in django shell? > > Have you imported it corectly (paste some code from where the > exception gets thrown. > > /J > > > > On Thursday, April 15, 2010, HiddenWolf <hbrugm...@gmail.com> wrote: > > Hi all, > > > I'm trying to get a blog app working, and I keep running into the > > weirdest error. > > > Both typogrify and smartypants.py are on my django-path and import > > fine from a shell. I get a similar error when trying to import and use > > smartypants in a model, so it might very well be my install. I just > > can't figure out why things are broken. > > > Does anyone have some tips? > > > Thank you, > > > HiddenWolf > > ------------- > > TemplateSyntaxError at /blog/ > > > Caught an exception while rendering: 'module' object has no attribute > > 'smartyPants' > > > Original Traceback (most recent call last): > > File "/usr/lib/pymodules/python2.6/django/template/debug.py", line > > 71, in render_node > > result = node.render(context) > > File "/usr/lib/pymodules/python2.6/django/template/debug.py", line > > 87, in render > > output = force_unicode(self.filter_expression.resolve(context)) > > File "/usr/lib/pymodules/python2.6/django/template/__init__.py", > > line 572, in resolve > > new_obj = func(obj, *arg_vals) > > File "/mnt/hgfs/Web/django/typogrify/templatetags/typogrify.py", > > line 180, in smartypants > > output = smartypants.smartyPants(text) > > AttributeError: 'module' object has no attribute 'smartyPants' > > > Request Method: GET > > Request URL: http://127.0.0.1:8000/blog/ > > Exception Type: TemplateSyntaxError > > Exception Value: > > > Caught an exception while rendering: 'module' object has no attribute > > 'smartyPants' > > > Original Traceback (most recent call last): > > File "/usr/lib/pymodules/python2.6/django/template/debug.py", line > > 71, in render_node > > result = node.render(context) > > File "/usr/lib/pymodules/python2.6/django/template/debug.py", line > > 87, in render > > output = force_unicode(self.filter_expression.resolve(context)) > > File "/usr/lib/pymodules/python2.6/django/template/__init__.py", > > line 572, in resolve > > new_obj = func(obj, *arg_vals) > > File "/mnt/hgfs/Web/django/typogrify/templatetags/typogrify.py", > > line 180, in smartypants > > output = smartypants.smartyPants(text) > > AttributeError: 'module' object has no attribute 'smartyPants' > > > Exception Location: /usr/lib/pymodules/python2.6/django/template/ > > debug.py in render_node, line 81 > > Python Executable: /usr/bin/python > > Python Version: 2.6.5 > > Python Path: ['/usr/bin', '/usr/local/lib/python2.6/dist-packages/ > > staticgenerator-1.4.1-py2.6.egg', '/usr/local/lib/python2.6/dist- > > packages/South-0.7-py2.6.egg', '/mnt/hgfs/Web/django', '/usr/lib/ > > python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib- > > tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/ > > usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/ > > PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/ > > python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/ > > pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist- > > packages'] > > Server time: Thu, 15 Apr 2010 05:58:34 +0200 > > Template error > > > In template /mnt/hgfs/Web/django/flother/apps/blog/templates/blog/ > > entry_index.html, error at line 5 > > Caught an exception while rendering: 'module' object has no attribute > > 'smartyPants' > > 1 {% extends "base.html" %} > > 2 {% load comments typogrify %} > > 3 > > 4 {% block headtitle %}Blog{% endblock %} > > 5 {% block pagetitle %}<a > > href="{{ latest_entry.get_absolute_url }}">{{ latest_entry.title| > > widont|smartypants }}</a>{% endblock %} > > ----------- > > > > -- > > You received this message because you are subscribed to the Google Groups > > "Django users" group. > > To post to this group, send email to django-us...@googlegroups.com. > > To unsubscribe from this group, send email to > > django-users+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.