Changes between Initial Version and Version 3 of Ticket #29367
- Timestamp:
- Apr 27, 2018, 12:56:35 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #29367
- Property Owner changed from to
- Property Status new → assigned
-
Ticket #29367 – Description
initial v3 30 30 31 31 32 class Anal ist(models.Model):32 class Analyst(models.Model): 33 33 ext_id = models.CharField(primary_key=True, max_length=32) 34 34 groups = models.ManyToManyField(Group) … … 37 37 group_aaa = Group.objects.get(ext_id='AAA') 38 38 39 anal ist_eee = Analist(ext_id='EEE')40 Anal ist.objects.bulk_create([analist_eee])39 analyst_eee = Analyst(ext_id='EEE') 40 Analyst.objects.bulk_create([analyst_eee]) 41 41 42 anal ist_eee.groups.set([group_aaa]) # ValueError: Cannot add "<Group: AAA>": instance is on database "None", value is on database "default"42 analyst_eee.groups.set([group_aaa]) # ValueError: Cannot add "<Group: AAA>": instance is on database "None", value is on database "default" 43 43 }}} 44 44 … … 47 47 A current workaround option is to manually set the `._state.db` after the bulk_create: 48 48 {{{ 49 anal ist_eee = Analist(ext_id='EEE')50 Anal ist.objects.bulk_create([analist_eee])51 anal ist_eee._state.db = 'default'49 analyst_eee = Analyst(ext_id='EEE') 50 Analyst.objects.bulk_create([analyst_eee]) 51 analyst_eee._state.db = 'default' 52 52 53 anal ist_eee.groups.set([group_aaa]) # And now it works53 analyst_eee.groups.set([group_aaa]) # And now it works 54 54 }}}