Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed Django 2 error in m2m fields #113

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ django-autofixture

|build| |package|

*** Compatible with Django version 2.X


This app aims to provide a simple way of loading masses of randomly generated
test data into your development database. You can use a management command to
load test data through command line.
Expand Down
6 changes: 5 additions & 1 deletion autofixture/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,11 @@ def process_field(self, instance, field):
value = self.get_value(field)
if value is self.IGNORE_FIELD:
return
setattr(instance, field.name, value)
elif isinstance(field, related.ManyToManyField):
instance.save()
getattr(instance, field.name).set(value)
else:
setattr(instance, field.name, value)

def process_m2m(self, instance, field):
# check django's version number to determine how intermediary models
Expand Down