Opened 10 years ago

Closed 10 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: UI/UX:



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/
--- django/views/generic/       (revision 2501)
+++ django/views/generic/       (working copy)
@@ -39,7 +39,7 @@
             new_object =

             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 @@

             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':
         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)
         if not template_name:

Change History (1)

comment:1 Changed 10 years ago by jkocherhans

  • Resolution set to fixed
  • Status changed from new to closed

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

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