dlamotte / django-tagging

Automatically exported from code.google.com/p/django-tagging
Other
0 stars 0 forks source link

something broken regarding TagField? #172

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi, I just svn checkout the django-tagging trunk version and the django trunk 
version and started playing with it. Unfortunately it seems the TagField is not 
working quite properly. Here are the steps to reproduce:

1. add 'tagging' to INSTALLED_APP
2. python manage.py startapp tests
3. create a simple model under tests/models.py as

from django.db import models
from tagging.forms import TagField

class TagTest(models.Model):
    name = models.CharField(max_length=255)
    tags = TagField()

4. python manage.py syncdb
5. python manage.py shell
6. >>> from tests.models import TagTest
   >>> TagTest.objects.create(name='t1')
   <TagTest: TagTest object>
7. 
>>> TagTest.objects.create(tags=u't2 t3')
Traceback (most recent call last):
  File "<console>", line 1, in ?
  File "/usr/local/src/djtrunk/django/db/models/manager.py", line 99, in create
    return self.get_query_set().create(**kwargs)
  File "/usr/local/src/djtrunk/django/db/models/query.py", line 318, in create
    obj = self.model(**kwargs)
  File "/usr/local/src/djtrunk/django/db/models/base.py", line 265, in __init__
    raise TypeError, "'%s' is an invalid keyword argument for this function" % 
kwargs.keys()[0]
TypeError: 'tags' is an invalid keyword argument for this function

Which it quite contrary to tagging/tests/tests.py's FormTest example.

Also if I do save on the model, it doesn't persist to the DB
>>> t1 = TagTest.objects.get(pk=1)
>>> t1.tags = u't2 t3'
>>> t1.tags
u't2 t3'
>>> t1.save()
>>> t1 = TagTest.objects.get(pk=1)
>>> t1
<TagTest: TagTest object>
>>> t1.tags
<tagging.forms.TagField object at 0xc6e150>

So the tags are missing. Is there something fundamentally broken? Or am I 
missing 
something obvious?

Thanks

Original issue reported on code.google.com by waifun...@gmail.com on 12 Nov 2008 at 8:01

GoogleCodeExporter commented 8 years ago
My bad, I imported the wrong TagField! After changing it to

from tagging.fields import TagField 

It works fine now. Sorry for the false alarm.

Original comment by waifun...@gmail.com on 12 Nov 2008 at 8:50

GoogleCodeExporter commented 8 years ago

Original comment by bros...@gmail.com on 22 Jan 2010 at 10:19