jul
jul

Reputation: 37484

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

I'm doing a form 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

Upvotes: 1

Views: 74

Answers (2)

Daniel Roseman
Daniel Roseman

Reputation: 599876

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.

Upvotes: 2

rossipedia
rossipedia

Reputation: 59407

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.

Upvotes: 0

Related Questions