Skip to content

Instantly share code, notes, and snippets.

@menecio
Last active September 7, 2019 09:51
Show Gist options
  • Save menecio/fe0fdc8b398f80f62774f01df63e6489 to your computer and use it in GitHub Desktop.
Save menecio/fe0fdc8b398f80f62774f01df63e6489 to your computer and use it in GitHub Desktop.
from aiohttp import web
from django import setup
from django.conf import settings
from mymoviedb import settings as my_settings # not the same as django.conf.settings
from movies.routes import movies_app
async def setup_django(app):
'''
Configures database and installed apps so
we can have Django ORM ready to be used.
'''
settings.configure(
INSTALLED_APPS=my_settings.INSTALLED_APPS,
DATABASES=my_settings.DATABASES)
setup()
app = web.Application()
app.on_startup.append(setup_django)
app.add_subapp('/api/', movies_app)
if __name__ == '__main__':
web.run_app(app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment