开发者

How can I insert a rendered form from a form application in a Django template from another application?

I'm doing a fo开发者_如何学Pythonrm application (similar to django-contact-form) and would like to be able to insert the rendered form in a Django template of another application. What's the best way to do that? Should I create a template for the form (with for example only {{ form.as_p)? If so how can I insert it in another template?

Thanks

Jul


What do you mean when you say a separate 'application'? Do you mean a completely separate Django site, or just a separate app within your current site?

If the latter, there's no issue: just import the form into the view you want to use it in.

If the former, then there isn't really any good way to do it. You could try using an iframe within your template to point to the external site, but it's not a particularly nice architecture.


Couldn't you load the application with the form you need in the settings.py file under INSTALLED_APPS and then call it from your template somehow? I'm a little new to django, but from what I can tell that seems like it would be the "django" way of doing it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜