﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
14167	Using Instances in Generic Create/Update/Delete	monokrome	nobody	"I would like to proposal that django's create/update/delete methods be able to receive an instance of a model instead of a class reference.

Albeit, it is not difficult to create your own create/update/delete method - using django's generic views would allow an application to easily inherit any additional functionality that might be added to these generic views in the future. It also provides the added benefit of centralizing the work happening to the models, and would help model code follow the DRY principal in many cases.

Here is an example of how a generic view may be used with this idea in mind. In my opinion, this is much more readable than working with the form yourself:

{{{
# Assume that we have a model `Job` with a foreign key `user`
from models import Job

def create_job(request):
     """""" Create a new job. """"""
     job_instance = Job()
     job_instance.user = request.user
 
     kwargs = {
         'instance': job_instance,
         'login_required': True,
         'template_name': 'jobs/create.html',
     }
 
     return create_object(request, **kwargs)
}}}
"		closed	Generic views	1.2		fixed	generic views DRY instance		Unreviewed	1	1	1	1	0	0
