Opened 18 years ago

Closed 18 years ago

#1478 closed defect (fixed)

[patch] [magic-removal] Generic views, keeping up with the changes

Reported by: Russell Cloran <russell@…> Owned by: Jacob
Component: Generic views Version: magic-removal
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Hi,

The generic views need to keep up with the Jones's. Here's a little patch to help them do that. (change _set.add to _set.create).

Index: django/views/generic/create_update.py
===================================================================
--- django/views/generic/create_update.py       (revision 2501)
+++ django/views/generic/create_update.py       (working copy)
@@ -39,7 +39,7 @@
             new_object = manipulator.save(new_data)

             if not request.user.is_anonymous():
-                request.user.message_set.add(message="The %s was created sucessfully." % model._meta.verbose_name)
+                request.user.message_set.create(message="The %s was created sucessfully." % model._meta.verbose_name)

             # Redirect to the new object: first by trying post_save_redirect,
             # then by obj.get_absolute_url; fail if neither works.
@@ -111,7 +111,7 @@
             manipulator.save(new_data)

             if not request.user.is_anonymous():
-                request.user.message_set.add(message="The %s was updated sucessfully." % model._meta.verbose_name)
+                request.user.message_set.create(message="The %s was updated sucessfully." % model._meta.verbose_name)

             # Do a post-after-redirect so that reload works, etc.
             if post_save_redirect:
@@ -178,7 +178,7 @@
     if request.META['REQUEST_METHOD'] == 'POST':
         object.delete()
         if not request.user.is_anonymous():
-            request.user.message_set.add(message="The %s was deleted." % model._meta.verbose_name)
+            request.user.message_set.create(message="The %s was deleted." % model._meta.verbose_name)
         return HttpResponseRedirect(post_delete_redirect)
     else:
         if not template_name:

Change History (1)

comment:1 by jkocherhans, 18 years ago

Resolution: fixed
Status: newclosed

(In [2503]) magic-removal: fixed #1478. Thanks Russell Cloran.

Note: See TracTickets for help on using tickets.
Back to Top