Coder Social home page Coder Social logo

Comments (7)

SuperNascher avatar SuperNascher commented on August 16, 2024 2

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.

alexandrenorman avatar alexandrenorman commented on August 16, 2024

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.

4levels avatar 4levels commented on August 16, 2024

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.

hexstr1p avatar hexstr1p commented on August 16, 2024

Is there still not much of a way around this? This error continues to pop up when loading a data dump.

from django-tagulous.

alex-msk avatar alex-msk commented on August 16, 2024

+1

from django-tagulous.

alex-msk avatar alex-msk commented on August 16, 2024

alex-msk@f69b0d2

I did a temporary "dirty" hack for a quick fix this issue. Can help temporarily.

from django-tagulous.

radiac avatar radiac commented on August 16, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.