hjwp/book-example — pull request #1 by treyhunner (2013-10-04 19:28:06+00:00)
Title: Better form flow

Some things I think this improves upon:

- Remove confusing mixin (self.object referenced the list and not the item)
- Use CreateView so form_valid and other methods work as expected
- Set `list` in `data` form kwargs in the view (I don't like this, but the uniqueness constraint test seems to require it)

Normally I would prefer to override the form's init and save methods like in 0235ced7a10753f52db29a02a5ef37eb2f001fe7, but the testing of the uniqueness constraint creates problems with that approach.

There isn't currently a generic class-based view that can make it easier to update a child element under a parent (item on a list). If this behavior is desired in multiple views, you could make a ListObjectMixin class to handle getting the list or raising a 404 as appropriate.