treethought / flask-assistant

Framework for Building Virtual Assistants with Dialogflow and python
Apache License 2.0
379 stars 101 forks source link

Django compatibility #62

Closed teolemon closed 6 years ago

teolemon commented 6 years ago

Is there a way to make this project Django-compatible without forking it outright ?

I'm currently building custom code for my Django project, and have that lingering feeling of rebuilding the wheel.

treethought commented 6 years ago

So there is no django support out of the box. Unfortunately I don't intend to add django compatibility at this time.

I haven't tried this, but you may be able to

  1. create a urlconf like: (webhook.py would be replace your views.py)
from django.urls import path

from your_webhook import assist

urlpatterns = [
    path('/', assist._flask_assistant_view_func),
]
  1. Modify the _flask_assistant_view_func and _api_request methods of the Assistant class to use Django's HttpRequest object instead of flask's.

  2. Initialize your Assistant object without a flask app assist = Assistant(route='/')

This is pretty messy because you would still be using flask under the hood. It's been a while since I've used Django as well so I'm not sure if this would even work.