Django forms: prepopulate form with request.user and url parameter
- by Malyo
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.