Hi,
I have created modelFormset using SchoolHistory model and SchoolForm form.
"SchoolFormSet = modelformset_factory(SchoolHistory, form=SchoolForm)"
I get other content from Form, but should save current user to SchoolHistory model too.
user=models.ForeignKey(User)
school_name = models.CharField(max_length = 100)
rating_average = models.PositiveIntegerField()
I am overriding is_valid or save in order to save user field.
My question is how to find current user in model or form level as there is no request parameter available ( request.user).
request was available in Formset level but I cannot save user to each record there, or could I?
-Thanks
-- I have created modelFormset using SchoolHistory model and SchoolForm form.
"SchoolFormSet = modelformset_factory(SchoolHistory, form=SchoolForm)"
I get other content from Form, but should save current user to SchoolHistory model too.
user=models.ForeignKey(User)
school_name = models.CharField(max_length = 100)
rating_average = models.PositiveIntegerField()
I am overriding is_valid or save in order to save user field.
My question is how to find current user in model or form level as there is no request parameter available ( request.user).
request was available in Formset level but I cannot save user to each record there, or could I?
-Thanks
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/19432f21-d928-4878-b6c8-3ac20aaa04ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment