Sunday, July 25, 2010

Re: CRUD Views

Me culpa! Ignore this -- got it -- django.views.generic.create_update.

On Sun, Jul 25, 2010 at 5:56 PM, Venkatraman S <venkat83@gmail.com> wrote:
Hi,

I have many tables defined, wherein bulk of the operations which are rendered in the UI are CRUD operations.
Is there any generic way of doing this instead of me explicitly creating ModelForms and then handling each of the CRUD operations in my views?

For eg. for creating an item, i do something like this...and i dont want to repeat the same function(code duplication) for say a Category, Customer, Vendor etc.

def create_item(request):
  if request.method == 'POST':
    form = ItemForm(request.POST)
    if form.is_valid():
      form.save()
      return HttpResponseRedirect("/inventory/")
  else:
    form = ItemForm()
  return render_to_response('create_item.html', {'form':form } , context_instance = RequestContext(request))
 
  -V-
http://twitter.com/venkasub

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment