Hi all,
I'm writing a small app, and get an error when trying to update the
object, the error message is
'QuerySet' object has no attribute '_meta'. and It shows that I made
some mistake on this line:
form = ProjectForm(instance = projectInstance). But I don't know where
am I wrong. The below is my code in views.py.
@login_required
def edit_project(request, project_id = None):
if project_id == None:
projectInstance = Project()
else:
projectInstance = Project.objects.filter(id =
project_id).filter(Q(creater = request.user) | Q(administrator =
request.user))
if projectInstance.count() == 0:
return HttpResponseRedirect('/edit/fail/')
if request.method == 'POST':
form = ProjectForm(request.POST, instance = projectInstance)
if form.is_valid():
project = form.save(commit = False)
if project.creater is None:
project.creater = request.user
else:
project.creater = project.creater
project.save()
form.save_m2m()
return HttpResponseRedirect('/')
else:
form = ProjectForm(instance = projectInstance)
variables = RequestContext(request, {'form': form})
return render_to_response('add_project.html', variables)
My environment is: UBUNTU910, Django 1.1.1. Anyone can help me? Thank you
very much!
--
Deng Chao
--
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.