I'm following along with Chapter 18 of the book as well as a tutorial
on newforms, but I'm getting hung up on one thing the book says to
use.  I import the staff_member_required decorator, and I put
"@staff_member_required" just before my view method definition (see
code below), but I get the error:

SyntaxError at /ce/admin/tech_tasks/request/add/
invalid syntax (admin.py, line 10)

Here's my views/admin.py (note that everything works, until I added
line 10 - "@staff_member_required"):

from django import newforms as forms
from django.newforms import widgets
from django.template.loader import get_template
from django.template import Context
from django.http import HttpResponseRedirect, HttpResponse
from django.contrib.admin.views.decorators import
staff_member_required

from ce.tech_tasks.models import Request

@staff_member_required
def aud_request(request, id=None, delete=False):
    if id is None:
        if delete is True:
            req = Request.objects.get(id=id)
            req.delete()
        else:
            RequestForm = forms.models.form_for_model(Request)
    else:
        req = Request.objects.get(id=id)
        RequestForm = forms.models.form_for_instance(req)

    if request.method == 'POST':
        form = RequestForm(request.POST)
        if form.is_valid():
            req = form.save(commit=False)
            if id is None:
               req.requestor = request.user
            req.save()

            return HttpResponseRedirect("/ce/admin/tech_tasks/
request/")
    else:
        form = RequestForm()

    t = get_template('admin/tech_tasks/request/aud_request.html')

    c = Context({
        'form': form,
    })
    return HttpResponse(t.render(c))


Thanks so much in advance for any advice!


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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