I think I might have found an issue related 
to https://code.djangoproject.com/ticket/14849.  The last comment says to 
please email the django-dev group if there are any questions about the 
ticket, so here I am.  I've done my best to provide a complete test case.

I have an Event model with property 'times', which is a ManyToManyField to 
an EventTime model.  https://gist.github.com/c7d8319df96f5eb22cf3
I am processing data from a POST request with a ModelForm on Event, with a 
custom field and widget: https://gist.github.com/653adb9b0ecbcc823339  The 
widget takes a few POST fields and generates a set of date ranges as a list 
of tuples [(<start>, <end>), (<start>, <end>)...].  The to_python() method 
of the custom field takes the date ranges and returns a list of EventTime 
objects.

When I try to .save_m2m() the form (test case 
here: https://gist.github.com/6da4f69ade9bc7dc5b3c) I get...
ValueError: Cannot add "<EventTime: EventTime object>": instance is on 
database "default", value is on database "None"

This looks it might be an issue with the new multi-database stuff.  I could 
also be misunderstanding something, but after scouring the documentation for 
several hours I don't see anything implying that this wouldn't work.  I 
suspect the unusual thing I'm doing is creating instances of a Django model 
within my field's to_python() method.  Most of the existing fields use 
to_python() to cast to datetime or Decimal.  Is it not possible to convert 
value(s) into instances of Django models?

Thanks for your help.

-Ben Standefer

-Ben

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-developers/-/uVcisHlDAzkJ.
To post to this group, send email to django-developers@googlegroups.com.
To unsubscribe from this group, send email to 
django-developers+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en.

Reply via email to