Hi,

I have a newform that works as intended. I want to add admin
functionality such that within the same view I can handle creation of
a newform or passing back a model's values to the template for
editing. This is supposed to be simple with newforms but I'm stuck,
hoping for help.

Here is my simplified code:

def blog_post(request, id=None):

  instance = None
  if id is not None and id != "":
    instance = BlogEntry.objects.get(id)

  if request.method == 'POST':
    form = jacey_forms.BlogEntryForm(request.POST, instance=instance)

    if form.is_valid():
      new_blog_entry = form.save(commit=False)
      ...do some stuff
      new_blog_entry = form.save()
      return HttpResponseRedirect('/')

  else:
    form = jacey_forms.BlogEntryForm(instance=instance)

  return render_to_response('base_post.html', {'form' : form})

--------
By all accounts this should work. But I have no idea how to fill out
my html form with the values of the model that already exists. Any
help is appreciated.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to