On Apr 14, 11:12 pm, stkpoi <goodwin....@gmail.com> wrote: > 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 haven't shown any code that puts the username in the URL, or explained where that error appears, so it's hard to diagnose your problem. It might help if you showed your urls.py. If you don't want to put the username in the URL, don't put it there. -- DR. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---