Thanks for the replies and suggestions Simon and Marten.

I am definitely calling form.clean() because I am using the default admin 
for views in my tests.  The field in the case that was tripping me up is 
being used as an auto-populating primary key... so the admin form was 
excluding it from clean() and then redirecting to the wrong url.

Since the behavior is written and working as intended I can tackle this 
particular problem from a different direction.  But in my mind, it still 
seems like ModelClass.objects.create() should return an instance as if it 
were pulled from the database... especially with convenience methods like 
`get_or_create` because the field value would be different in this scenario 
depending on if the method uses get or create to return the instance (I 
haven't looked at the implementation but the name would imply it relies on 
the create method).  But I guess there are cases where you don't need to 
use the returned instance and would waste a few cpu cycles.  This issue 
makes `get_or_create` a little dangerous I think.

I think it adheres to the principle of least surprise since it makes Django
> models behave just like normal Python classes in this regard.
>

I am not sure about this since ModelClass.objects.create() is a manager 
method that returns a new model instance and not the manager "self".  But 
after rereading the documentation about the `create` method it does provide 
an alternate equivalent syntax that I would expect this behavior from.


-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/c7d694d5-74f3-41d0-b21d-a860fc7b4c28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to