Example application problem

294 views
Skip to first unread message

Jakub Wiśniowski

unread,
Dec 29, 2010, 3:58:23 AM12/29/10
to django-crowdsourcing
Hi!

I've installed crowdsourcing example app using instructions from:
http://packages.python.org/django-crowdsourcing/developers/index.html#installation

However, each time I try to open http://localhost:8000/ Django
throws an exception:

'crowdsourcing' is not a valid tag library: ImportError raised loading
crowdsourcing.templatetags.crowdsourcing: No module named
crowdsourcing.models

I use Django 1.2.4, crowdsourcing models are synchronized properly.
In Admin Panel I can add new survey. Running ./manage.py shell allows
me to import models from crowdsourcing. The problem is only with
crowdsourcing templatetags.

Full traceback:
Environment:

Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.2.4
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
'crowdsourcing',
'cms']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware')


Template error:
In template /home/ext/virtualenvs/crowd/src/crowdsourcing/example_app/
templates/home.html, error at line 1
'crowdsourcing' is not a valid tag library: ImportError raised
loading crowdsourcing.templatetags.crowdsourcing: No module named
crowdsourcing.models
1 : {% load crowdsourcing %}


2 : <html>


3 : <head>


4 : <title>Example App Home</title>


5 : {% include "header_tags.html" %}


6 : </head>


7 : <body>


8 :


9 : <p>This page demostrates how to embed surveys and survey
reports anywhere on


10 : your site. To see it in action, set a survey up and make it
public.</p>


11 : {% if latest_survey %}


Traceback:
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
core/handlers/base.py" in get_response
100. response = callback(request,
*callback_args, **callback_kwargs)
File "/home/ext/virtualenvs/django-crowdsourcing/example_app/cms/
views.py" in home
14. RequestContext(request))
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
shortcuts/__init__.py" in render_to_response
20. return HttpResponse(loader.render_to_string(*args,
**kwargs), **httpresponse_kwargs)
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
template/loader.py" in render_to_string
181. t = get_template(template_name)
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
template/loader.py" in get_template
160. template = get_template_from_string(template, origin,
template_name)
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
template/loader.py" in get_template_from_string
168. return Template(source, origin, name)
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
template/__init__.py" in __init__
158. self.nodelist = compile_string(template_string, origin)
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
template/__init__.py" in compile_string
186. return parser.parse()
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
template/__init__.py" in parse
282. compiled_result = compile_func(self, token)
File "/home/ext/virtualenvs/crowd/lib/python2.7/site-packages/django/
template/defaulttags.py" in load
928. (taglib, e))

Exception Type: TemplateSyntaxError at /
Exception Value: 'crowdsourcing' is not a valid tag library:
ImportError raised loading crowdsourcing.templatetags.crowdsourcing:
No module named crowdsourcing.models

Dave Aaron Smith

unread,
Dec 29, 2010, 9:26:46 AM12/29/10
to django-crowdsourcing
Hey Jakub, I'm happy you're using crowdsourcing. It seems to me from
your error that crowdsourcing itself isn't installed. Try doing this

$ ./manage.py shell

In [1]: import crowdsourcing

If that throws another import error, then django-crowdsourcing isn't
installed and you'll need to figure out why. Do you use pip?
http://pip.openplans.org/ If you do, you can use

$ pip install django-crowdsourcing

If you use easy_install, I believe this is the command you use, though
I haven't tested to make sure.

$ easy_install django-crowdsourcing

Keep me posted if you're still stuck. Thanks!
Dave

On Dec 29, 3:58 am, Jakub Wiśniowski <restless.be...@gmail.com> wrote:
> Hi!
>
>   I've installed crowdsourcing example app using instructions from:http://packages.python.org/django-crowdsourcing/developers/index.html...

Dave Aaron Smith

unread,
Dec 29, 2010, 9:28:30 AM12/29/10
to django-crowdsourcing
Oh, sorry about that, I see that you thought of this already. Alright,
let me take a look. Thank for the heads up.

On Dec 29, 9:26 am, Dave Aaron Smith <dasmi...@gmail.com> wrote:
> Hey Jakub, I'm happy you're using crowdsourcing. It seems to me from
> your error that crowdsourcing itself isn't installed. Try doing this
>
> $ ./manage.py shell
>
> In [1]: import crowdsourcing
>
> If that throws another import error, then django-crowdsourcing isn't
> installed and you'll need to figure out why. Do you use pip?http://pip.openplans.org/If you do, you can use

Dave Aaron Smith

unread,
Dec 29, 2010, 11:04:40 AM12/29/10
to django-crowdsourcing
Hey Jakub, I tried installing from scratch and I haven't been able to
reproduce the problem. Here are the commands I ran to install a fresh
copy using virtualenv and pip

$ mkvirtualenv dave_crowdsourcing_2
$ add2virtualenv /home/dsmith/svn.wnyc.org/thirdparty/django/
django-1.2.X/
$ hg clone https://django-crowdsourcing.googlecode.com/hg/ django-
crowdsourcing
$ cd django-crowdsourcing
$ pip install -r crowdsourcing_requirements.txt
$ pip install -r example_app/example_app_requirements.txt
$ pip install 'psycopg2>=2.0.8' # I have a postgresql database kicking
around
$ cd example_app/
$ vim local_settings.py # put in my postgresql connection information
$ ./manage.py runserver 0.0.0.0:4567 # I run mine on port 4567

Any ideas? The only difference between our environments is that I'm
running python version 2.6.2. Would that make a difference, anybody
know?

On Dec 29, 9:28 am, Dave Aaron Smith <dasmi...@gmail.com> wrote:
> Oh, sorry about that, I see that you thought of this already. Alright,
> let me take a look. Thank for the heads up.
>
> On Dec 29, 9:26 am, Dave Aaron Smith <dasmi...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Hey Jakub, I'm happy you're using crowdsourcing. It seems to me from
> > your error that crowdsourcing itself isn't installed. Try doing this
>
> > $ ./manage.py shell
>
> > In [1]: import crowdsourcing
>
> > If that throws another import error, then django-crowdsourcing isn't
> > installed and you'll need to figure out why. Do you use pip?http://pip.openplans.org/Ifyou do, you can use

Jakub Wiśniowski

unread,
Dec 29, 2010, 4:24:28 PM12/29/10
to django-crowdsourcing
On 29 Gru, 17:04, Dave Aaron Smith <dasmi...@gmail.com> wrote:
> Hey Jakub, I tried installing from scratch and I haven't been able to
> reproduce the problem. Here are the commands I ran to install a fresh
> copy using virtualenv and pip
>
> $ mkvirtualenv dave_crowdsourcing_2
> $ add2virtualenv /home/dsmith/svn.wnyc.org/thirdparty/django/
> django-1.2.X/
> $ hg clonehttps://django-crowdsourcing.googlecode.com/hg/django-
> crowdsourcing
> $ cd django-crowdsourcing
> $ pip install -r crowdsourcing_requirements.txt
> $ pip install -r example_app/example_app_requirements.txt
> $ pip install 'psycopg2>=2.0.8' # I have a postgresql database kicking
> around
> $ cd example_app/
> $ vim local_settings.py # put in my postgresql connection information
> $ ./manage.py runserver 0.0.0.0:4567 # I run mine on port 4567
I did almost the same, just omitting postgres portion. I used default
sqlite.

> Any ideas? The only difference between our environments is that I'm
> running python version 2.6.2. Would that make a difference, anybody
> know?
Hmm python version? Strange. One more idea. Did you try to visit
0.0.0.0:4567 in your browser? This is when the error is thrown on my
system.

I've also created the following buildout recipe to create environment
I'm familiar with, but the same problem exists:

#buildout.cfg
[buildout]
parts =
django
django-positions
crowdsourcing

[django-positions]
recipe = zerokspot.recipe.git
repository = git://github.com/jpwatts/django-positions.git

[crowdsourcing]
recipe = mercurialrecipe
repository = https://django-crowdsourcing.googlecode.com/hg/

[django]
recipe = djangorecipe
version = 1.2.4
eggs =
Pillow
sorl-thumbnail==3.2.5
geopy
flickrapi
python-oembed
project = example_app
settings=settings
extra-paths =
${buildout:directory}/example_app
${buildout:directory}/parts/crowdsourcing
${buildout:directory}/parts/django-positions
urls = example_app/urls

To use it:

1. mkdir crowd;cd crowd
2. create file buildout.cfg containing the code from above
3. copy example_app from crowdsourcing to crowd directory
4. wget http://svn.zope.org/*checkout*/zc.buildout/trunk/bootstrap/bootstrap.py
(if you have the above already in your repo, then whole installation
is just:)

5. python bootstrap.py
6. bin/buildout
7. bin/django syncdb
8. bin/django runserver

9. go to localhost:8000 in your browser

Best regards
Jakub

>
> On Dec 29, 9:28 am, Dave Aaron Smith <dasmi...@gmail.com> wrote:
>
> > Oh, sorry about that, I see that you thought of this already. Alright,
> > let me take a look. Thank for the heads up.
>
> > On Dec 29, 9:26 am, Dave Aaron Smith <dasmi...@gmail.com> wrote:
>
> > > Hey Jakub, I'm happy you're using crowdsourcing. It seems to me from
> > > your error that crowdsourcing itself isn't installed. Try doing this
>
> > > $ ./manage.py shell
>
> > > In [1]: import crowdsourcing
>
> > > If that throws another import error, then django-crowdsourcing isn't
> > > installed and you'll need to figure out why. Do you use pip?http://pip.openplans.org/Ifyoudo, you can use

Jakub Wiśniowski

unread,
Jan 4, 2011, 6:54:33 AM1/4/11
to django-crowdsourcing
Hi!

I looked a bit deeper into a source code and I see that there is
something wrong with imports on python 2.7. It looks like it always
imports from templatetags/crowdsourcing.py ignoring
"from ..crowdsourcing import (...)" relative import. However I can
make things work removing the leading dots from the above statement so
that the code looks like

from __future__ import absolute_import
(...)
from crowdsourcing.models import (...)

Another way to is to rename templatetags/crowdsourcing.py to
templatetags/crowdsourcing_tags.py and change tags in templates to be:
{% load crowdsourcing_tags %}.

What do you think? Would you like to check the first solution on
python 2.6?

Best regards
Jakub
> > > installed and you'll need to figure out why. Do you use pip?http://pip.openplans.org/Ifyoudo, you can use
>
> > > $ pip install django-crowdsourcing
>
> > > If you use easy_install, I believe this is the command you use, though
> > > I haven't tested to make sure.
>
> > > $ easy_install django-crowdsourcing
>
> > > Keep me posted if you're still stuck. Thanks!
> > > Dave
>

David Smith

unread,
Jan 4, 2011, 2:53:52 PM1/4/11
to django-cro...@googlegroups.com
Thanks so much for looking into that. Absolutely, I can try the first
solution on 2.6. I'm busy with other stuff today, but hopefully I can
get to it quickly. Thanks again,
Dave

2011/1/4 Jakub Wiśniowski <restles...@gmail.com>:

David Smith

unread,
Jan 6, 2011, 3:03:33 PM1/6/11
to django-cro...@googlegroups.com
Alright, it worked just fine. It's checked into the latest version,
1.1.21. http://pypi.python.org/pypi/django-crowdsourcing/

Thanks again Jakub.

Reply all
Reply to author
Forward
0 new messages