Hi again,
I still get this error where the tagging application
is trying to import my project, instead of an application.
What I'm trying to do is just to set an objects tags
using django-tagging outside a running application
and outside of ``manage.py shell``.
kaikuehne/delicious/sync.py:
=====================
#!/usr/bin/env python
# encoding: utf-8
# nifty trick to get ../settings
import os, sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
apppath=os.path.abspath(BASE_DIR + '/../')
sys.path.insert(0, apppath)
import settings
from delicious.models import Post
p = Post.objects.all()[0]
p.tags = "a b c"
Error message:
===========
Traceback (most recent call last):
File "C:\Dev\kaikuehne\delicious\sync.py", line 30, in <module>
p.tags = "a b c"
File "C:\Dev\kaikuehne\..\kaikuehne\delicious\models.py", line 19,
in _set_tags
Tag.objects.update_tags(self, tag_list)
File "C:\Dev\kaikuehne\tagging\managers.py", line 20, in update_tags
ctype = ContentType.objects.get_for_model(obj)
File
"C:\Dev\Python25\lib\site-packages\django\contrib\contenttypes\models.py",
line 20, in get_for_model
model=key[1], defaults={'name': smart_unicode(opts.verbose_name_raw)})
File "C:\Dev\Python25\lib\site-packages\django\db\models\options.py",
line 112, in verbose_name_raw
activate(lang)
File "C:\Dev\Python25\lib\site-packages\django\utils\translation\__init__.py",
line 76, in activate
return real_activate(language)
File
"C:\Dev\Python25\lib\site-packages\django\utils\translation\trans_real.py",
line 195, in activate
_active[currentThread()] = translation(language)
File
"C:\Dev\Python25\lib\site-packages\django\utils\translation\trans_real.py",
line 184, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File
"C:\Dev\Python25\lib\site-packages\django\utils\translation\trans_real.py",
line 167, in _fetch
app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]),
appname[p+1:])
ImportError: No module named kaikuehne
============================
When I run the code above in ``python manage.py shell`` it works perfectly so
I guess I'm just missing to set something what mange.py does:
# python mange.py shell
In [7]: p = Post.objects.all()[0]
In [8]: p
Out[8]: <Post: ANTSTORE - Ameisenshop - Ameisen>
In [9]: p.tags
Out[9]: []
In [10]: p.tags = "a b c"
In [11]: p.tags
Out[11]: [<Tag: a>, <Tag: b>, <Tag: c>]
Can anyone help me? I don't understand why
django-tagging is trying to include my project.
Thanks in advance,
Kai
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---