@staff_member_required
@csrf_exempt
def add_bookmark(request):
    if request.method == "POST":
        form = BookmarkForm(user=request.user, data=request.POST)
        if form.is_valid():
            bookmark = form.save()
            if not request.is_ajax():
                messages.success(request, 'Bookmark added')
                if request.POST.get('next'):
                    return HttpResponseRedirect(request.POST.get('next'))
                return HttpResponse('Added')
            return render_to_response(
                'admin_tools/menu/remove_bookmark_form.html',
                RequestContext(request, {
                    'bookmark': bookmark,
                    'url': bookmark.url,
                })
            )
    else:
        form = BookmarkForm(user=request.user)
    return render_to_response(
        'admin_tools/menu/form.html',
        RequestContext(request, {'form': form, 'title': 'Add Bookmark'})
    )
This view serves and validates a bookmark form.
dataset/ETHPy150Open django-admin-tools/django-admin-tools/admin_tools/menu/views.py/add_bookmark