Skip to content

Instantly share code, notes, and snippets.

@krsmedlund
Created January 13, 2012 10:53
Show Gist options
  • Save krsmedlund/1605523 to your computer and use it in GitHub Desktop.
Save krsmedlund/1605523 to your computer and use it in GitHub Desktop.
def update_stuff(request, pk):
instance = get_object_or_404(PCB, pk=pk)
if request.method in ('POST', 'PUT'):
form = FormClass(data=request.POST, files=reuqest.FILES, instance=instance)
if form.is_valid():
form.save()
...
else:
form = FormClass(instance=instance)
render_to_response({'form':form}, ...)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment