Django - Import views from separate apps

后端 未结 5 858
轻奢々
轻奢々 2021-02-19 07:59

I\'m new to Django and working my way through \"The Django Book\" by Holovaty and Kaplan-Moss. I have a project called \"mysite\" that contains two applications called \"books\

5条回答
  •  悲哀的现实
    2021-02-19 08:48

    Heres the approach i took for different view/API versions:

    from django.urls import path
    
    from my_app import views as api_v1
    from my_app import views_v2 as api_v2
    
    urlpatterns = [
        path('view_one', api_v1.ViewOne.as_view()),
        path('view_two', api_v2.ViewTwo.as_view()),
    ]
    

提交回复
热议问题