Thanks for posting this.  I was just about to post a question with the
same exact scenario.

Maybe we are missing it in the docs somewhere???



On Tue, Nov 12, 2013 at 12:30 PM, MikeKJ <mike.jo...@paston.co.uk> wrote:
> This is driving me nuts....  I do not want the user to be able to select
> organisation I want to populate the form field with the known
> organisation....
>
> organisation is a foreignkey to the model I am creating this form on
>
> so
>
> class AdviceLevel(models.Model):
>     advice = models.ForeignKey(Advice)
>     organisation = models.ForeignKey(Organisation)
>     level_1 = models.BooleanField()
>     level_2 = models.BooleanField()
>     level_3 = models.BooleanField()
>     level_4 = models.BooleanField()
>
> class AdviceForm(ModelForm):
>     class Meta:
>         model = AdviceLevel
>         exclude = ('organisation',)
>
> BUT excluding organisation in the form builder disables being able to use
> form.save() in the view even though I explicitly set organisation to the
> correct value in the view,, even added <p><label
> for="id_organisation">Organisation:</label><input type="text"
> name="organisation" id="id_organisation" value="{{ org }}" /></p> to the
> form to no avail
>
> so how can I explicitly set the value of the organisation bearing in mind I
> can't access a session value in the AdviceForm (or so it seems) to use
> something like organisation = queryset(Organisation.objects.get(pk=org_id)
> where org_id is a session value.
>
> Im probably not seeing the woods for the trees here
>
> --
> 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+unsubscr...@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/31885005-52f5-49b7-8ad4-c770961c6481%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.



-- 
MLHIM VIP Signup: http://goo.gl/22B0U
============================================
Timothy Cook, MSc           +55 21 94711995
MLHIM http://www.mlhim.org
Like Us on FB: https://www.facebook.com/mlhim2
Circle us on G+: http://goo.gl/44EV5
Google Scholar: http://goo.gl/MMZ1o
LinkedIn Profile:http://www.linkedin.com/in/timothywaynecook

-- 
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+unsubscr...@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/CA%2B%3DOU3Xd%3DP6_h%3Dw8%2B8-W6JXi5tfPoBJ9%2Bipv04S%3DNdGS7%2Bz1DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to