plus code

def response_add(self, request, obj, post_url_continue='../%s/'):
        """
        Determines the HttpResponse for the add_view stage.
        """
        opts = obj._meta
        pk_value = obj._get_pk_val()

        msg = "Item(s) were added successfully."
        # Here, we distinguish between different save types by checking for
        # the presence of keys in request.POST.
        if "_continue" in request.POST:
            self.message_user(request, msg + ' ' + _("You may edit it again 
below."))
            if "_popup" in request.POST:
                post_url_continue += "?_popup=1"
            return HttpResponseRedirect(post_url_continue % pk_value)

        if "_popup" in request.POST:
            return HttpResponse(
                '<!DOCTYPE html><html><head><title></title></head><body>'
                '<script 
type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", 
"%s");</script></body></html>' % \
                # escape() calls force_text.
                (escape(pk_value), escapejs(obj)))
        elif "_addanother" in request.POST:
            self.message_user(request, msg + ' ' + (_("You may add another 
%s below.") % force_text(opts.verbose_name)))
            return HttpResponseRedirect(request.path)
        else:
            self.message_user(request, msg)
            return 
HttpResponseRedirect(reverse("admin:todo_item_changelist"))

thanks 

On Friday, August 24, 2012 4:54:16 PM UTC+1, koiwai wrote:
>
> Hi,
>
> I'm currently working through Django by 
> Examples<http://lightbird.net/dbe/>and I am getting an error when attempting 
> to have the user automatically go 
> back to the listing of 'todo items'  after entering new 'to do items' 
> through creating a new date. The 
> site<http://lightbird.net/dbe/todo_list.html#changing-save-redirect>asks us 
> to copy a function from a template provided by django, and alter a 
> couple of things. The code example and the template are a bit different 
> post altering though (I guess this is because I am using 1.4;s default 
> packages and presumably the author was using 1.2), but I don't think these 
> are relevant to my problem (I use in rather than has.key etc)
>
> Name Error at /admin/todo/datetime/add/
> global name 'escape' is not defined
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/zw4c7aTNGRYJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to