On Monday, January 31, 2011 11:34:48 PM UTC, Jeffrey Stiles wrote:
>
> I would really like to make a form instance a model attribute so that 
> i have access to the form from the template through an object that I 
> have handy. 
>
> When I try to import import any form into models.py, I get an 
> ImportError on each of the import statements in the forms.py file 
> which reference a model in models.py. I'm assuming this is due to 
> circular imports. 
>
> I can't seem to find any information on importing forms into models. 
> Is this possible? If so, how?


I can't imagine why you would want to do this. Since you have to re-create 
the form instance each time - passing it new data on each POST, for example 
- you don't gain anything by having it accessible as a property. Why not 
just pass it explicitly to the template?

If you really want to do this, it's perfectly possible to just do:
    my_model_instance.form = my_form_instance
in your view somewhere. But as I say, I can't see what this gets you.
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to