Comments (7)
One of the problems can occur, if the tag field is not set on the model and django(or django-rest-framework) emits an empty list (because of the ManyToManyField inheritance).
The add() function from the TagRelatedManagerMixin adds the list to the tags and calls _ensure_tags_in_db(), which triggers the error, because the list has no pk attribute of-course.
from django-tagulous.
Same issue when populating my DB from a fixture:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 359, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 294, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/base.py", line 345, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 64, in handle
self.loaddata(fixture_labels)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 104, in loaddata
self.load_label(fixture_label)
File "/usr/local/lib/python3.6/site-packages/django/core/management/commands/loaddata.py", line 167, in load_label
obj.save(using=self.using)
File "/usr/local/lib/python3.6/site-packages/django/core/serializers/base.py", line 204, in save
getattr(self.object, accessor_name).set(object_list)
File "/usr/local/lib/python3.6/site-packages/tagulous/models/managers.py", line 544, in set
self.add(*objs)
File "/usr/local/lib/python3.6/site-packages/tagulous/models/managers.py", line 584, in add
new_tags = self._ensure_tags_in_db(new_tags)
File "/usr/local/lib/python3.6/site-packages/tagulous/models/managers.py", line 522, in _ensure_tags_in_db
if tag.pk:
AttributeError: Problem installing fixture '/app/django/fabrique_a_contacts/fixtures/mydump-20180219.json': 'list' object has no attribute 'pk'
from django-tagulous.
Man, this issue is so affecting me and I kept blaming Django Restframework :-(
There seems simply no way to work with tagulous and add relations in the traditional many-2-many way, by passing a list of id's. Is there really no way to make tagulous work with simple id lists?
Hoping someone can shed some light on this
Thanks
from django-tagulous.
Is there still not much of a way around this? This error continues to pop up when loading a data dump.
from django-tagulous.
+1
from django-tagulous.
I did a temporary "dirty" hack for a quick fix this issue. Can help temporarily.
from django-tagulous.
Firstly, apologies this has gone unanswered for so long.
This is the error you'll see if you haven't enabled the tagulous serializers in your Django settings as per the installation instructions:
SERIALIZATION_MODULES = {
'xml': 'tagulous.serializers.xml_serializer',
'json': 'tagulous.serializers.json',
'python': 'tagulous.serializers.python',
'yaml': 'tagulous.serializers.pyyaml',
}
Although this is in the detailed installation instructions, I now realise that it's missing from the quickstart in the readme - I've updated that.
If this doesn't resolve the issue, please do re-open this.
from django-tagulous.
Related Issues (20)
- Tags are not has any order... HOT 5
- tagulous select2 <-> jquery.dirty
- Best approach for a dropdown select instead of comma separated list? HOT 1
- Is it possible to add a tag creator?
- Remove dependency on jquery HOT 3
- Autocomplete broken on Django 4 HOT 4
- running pytest failed HOT 1
- It's hard to contribute code :( HOT 1
- Want to copy fields to tags automatically by post save signal method HOT 5
- How to trigger Change event with jquery on Tagulous Fields
- Newbie question about paths/views
- documentation html title refers to django-fastview HOT 1
- SingleTagField js parsing seems buggy for tags with spaces
- Django 4.2 python 3.12 tagsfield remain empty HOT 2
- Ist this project dead? HOT 2
- Select2 initialiser broken with Django 4.1 HOT 4
- Document `descendant_count` and `family_count` properties of TagTreeModel
- tagulous.admin.enhance() will change the list_display to a list HOT 2
- Django 5.1 support
- Change history in admin always includes TagFields as "changed" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-tagulous.