Django forms: prepopulate form with request.user and url parameter
Posted
by
Malyo
on Stack Overflow
See other posts from Stack Overflow
or by Malyo
Published on 2013-09-27T12:38:33Z
Indexed on
2013/10/23
9:55 UTC
Read the original article
Hit count: 140
django
|django-forms
I'm building simple Course Management App. I want Users to sign up for Course. Here's sign up model:
class CourseMembers(models.Model):
student = models.ForeignKey(Student)
course = models.ForeignKey(Course)
def __unicode__(self):
return unicode(self.student)
Student model is extended User model - I'd like to fill the form with request.user.
In Course model most important is course_id, which i'm passing into view throught URL parameter (for example http://127.0.0.1:8000/courses/course/1/
).
What i want to achieve, is to generate 'invisible' (so user can't change the inserted data) form with just input, but containing request.user and course_id parameter.
© Stack Overflow or respective owner