A two-mode view handles both adding a new object and editing an existing one, avoiding two nearly identical view functions. In Django, a default ID of 0 can represent Add mode; a real object ID selects Edit mode. section 7.2.5
A practical request flow looks like this:
- Register one route without an ID for adding and another route with an ID for editing. section 7.2.5
RiffMates seeking ads
The seeking_ad(request, ad_id=0) view displays a blank SeekingAdForm at /seeking_ad/ and prepopulates the same form at /edit_seeking_ad/<id>/ using the selected owner's ad.
