I would like the url to not include the user's name. For example, it
would be "/submit" and not "/submit/joe_user".
request.user.username is not working for me.
# Model
class Submission(models.Model):
title = models.CharField(max_length=200)
link = models.URLField()
user = models.ForeignKey(User)
# Form
class SubmissionForm(forms.Form):
title = forms.CharField(max_length=200)
link = forms.URLField()
# View
def submit_page(request):
if request.method == 'POST':
form = SubmissionForm(request.POST)
if form.is_valid():
submission = Submission.objects.get_or_create(
title=form['title'],
link=form['link'],
user=request.user.username
)
return HttpResponseRedirect('/submit/submit_success.html')
else:
form = SubmissionForm()
variables = RequestContext(request, {
'form': form, 'user':request.user.username
})
return render_to_response('submit/submission.html', variables)
# Result: Error binding parameter 1 - probably unsupported type
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---