summaryrefslogtreecommitdiff
path: root/django/views/generic/create_update.py
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2005-11-25 21:20:09 +0000
committerAdrian Holovaty <adrian@holovaty.com>2005-11-25 21:20:09 +0000
commit9dda4abee1225db7a7b195b84c915fdd141a7260 (patch)
treef64c44db97559f4a3bf091e82fb78c9d321cc8e1 /django/views/generic/create_update.py
parent4fe5c9b7ee09dc25921918a6dbb7605edb374bc9 (diff)
MERGED NEW-ADMIN BRANCH (except for po/mo files, which will come in a separate commit)
git-svn-id: http://code.djangoproject.com/svn/django/trunk@1434 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/views/generic/create_update.py')
-rw-r--r--django/views/generic/create_update.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/django/views/generic/create_update.py b/django/views/generic/create_update.py
index f06e1d57e5..af853a9f4e 100644
--- a/django/views/generic/create_update.py
+++ b/django/views/generic/create_update.py
@@ -9,7 +9,7 @@ from django.core.exceptions import Http404, ObjectDoesNotExist, ImproperlyConfig
def create_object(request, app_label, module_name, template_name=None,
template_loader=template_loader, extra_context={},
- post_save_redirect=None, login_required=False):
+ post_save_redirect=None, login_required=False, follow=None):
"""
Generic object-creation function.
@@ -22,17 +22,17 @@ def create_object(request, app_label, module_name, template_name=None,
return redirect_to_login(request.path)
mod = models.get_module(app_label, module_name)
- manipulator = mod.AddManipulator()
+ manipulator = mod.AddManipulator(follow=follow)
if request.POST:
# If data was POSTed, we're trying to create a new object
new_data = request.POST.copy()
# Check for errors
errors = manipulator.get_validation_errors(new_data)
+ manipulator.do_html2python(new_data)
if not errors:
# No errors -- this means we can save the data!
- manipulator.do_html2python(new_data)
new_object = manipulator.save(new_data)
if not request.user.is_anonymous():
@@ -48,7 +48,8 @@ def create_object(request, app_label, module_name, template_name=None,
raise ImproperlyConfigured("No URL to redirect to from generic create view.")
else:
# No POST, so we want a brand new form without any data or errors
- errors = new_data = {}
+ errors = {}
+ new_data = manipulator.flatten_data()
# Create the FormWrapper, template, context, response
form = formfields.FormWrapper(manipulator, new_data, errors)
@@ -68,7 +69,7 @@ def create_object(request, app_label, module_name, template_name=None,
def update_object(request, app_label, module_name, object_id=None, slug=None,
slug_field=None, template_name=None, template_loader=template_loader,
extra_lookup_kwargs={}, extra_context={}, post_save_redirect=None,
- login_required=False):
+ login_required=False, follow=None):
"""
Generic object-update function.
@@ -98,13 +99,13 @@ def update_object(request, app_label, module_name, object_id=None, slug=None,
except ObjectDoesNotExist:
raise Http404("%s.%s does not exist for %s" % (app_label, module_name, lookup_kwargs))
- manipulator = mod.ChangeManipulator(object.id)
+ manipulator = mod.ChangeManipulator(object.id, follow=follow)
if request.POST:
new_data = request.POST.copy()
errors = manipulator.get_validation_errors(new_data)
+ manipulator.do_html2python(new_data)
if not errors:
- manipulator.do_html2python(new_data)
manipulator.save(new_data)
if not request.user.is_anonymous():
@@ -120,7 +121,7 @@ def update_object(request, app_label, module_name, object_id=None, slug=None,
else:
errors = {}
# This makes sure the form acurate represents the fields of the place.
- new_data = object.__dict__
+ new_data = manipulator.flatten_data()
form = formfields.FormWrapper(manipulator, new_data, errors)
if not template_name: