add() argument after * must be a sequence, not Groups
django, django-forms
Solution
At the moment django-adaptors doesn't support ManyToManyFields. As there is more and more requests about it, I am going to integrate it soonish.
If you want to workaround that, you should work in 2 steps. The first one would be to create a python object by using a simple CSVModel by removing:
dbModel = Contact
Unfortunately, you would also have to do the update logic manually.
Then you would need to explicitly create the django instance by doing something like:
contact = Contact.objects.create(first_name = csv_object.first_name, ....)
contact.groups.add(csv_object.group)
Hope that helps
Problem
I'm trying to pass a 'group' as an extra field using importer-option from django-adaptors but I'm getting the following error... add() argument after * must be a sequence, not Group ``` ContactCSVModel.import_data(data=self.filepath, extra_fields="1") ``` This is my CsvModel... CsvModel.py ``` class ContactCSVModel(CsvModel): first_name = CharField() last_name = CharField() company = CharField() mobile = CharField() groups = DjangoModelField(Group) class Meta: delimiter = "^" dbModel = Contact update = { 'keys': ['mobile'] } ``` model.py ``` class Contact(models.Model): """ Stores all contacts. """ first_name = models.CharField(max_length=60) last_name = models.CharField(max_length=60) company = models.CharField(max_length=100,blank=True) mobile = models.IntegerField(max_length=20) active = models.BooleanField(help_text="States if pet type is active/selectable.") modified = models.DateTimeField(null=True, auto_now=True, help_text="Shows when object was modified.") created = models.DateTimeField(auto_now_add=True, help_text="Shows when object was created.") #FK groups = models.ManyToManyField(Group, related_name='contacts') ``` Looking at the project on git (below), could there be any issue with the project and many2many fields, maybe, if so how to fix? or is it my code? https://github.com/anthony-tresontani/django-adaptors/blob/master/adaptor/model.py#L436