Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Can you use Django and Flask in the same application?

When making a application I would like to use features from both Flask and Django is it possible to use them together?

1 Answer

Hi!

Yes you can do that, you can merge the two at the WSGI level. You python web apps are layered something like this

Browser <-> Internet <-> Webserver <-> WSGI <-> Flask or Django

WSGI looks at the URL on the incoming requests and routes it to the right code. You could set up your Flask app to take care of all urls except for ones beginning with "/django". Then have the django app handle all "/django" requests.

You can read about it here:

http://flask.pocoo.org/docs/0.10/patterns/appdispatch/

I would probably not do this myself. There a lot of issues to think about bridging between the two apps, like if a user is logged in or not.

If you tell me more about the two apps you want to meld perhaps I can give more specific advice.

Good Luck!

Thanks for answering this really helped.