增加 ingredient 和 recipe-ingredient model; 增加相关 API Signed-off-by: Ching <loooching@gmail.com>
23 lines
813 B
Python
23 lines
813 B
Python
from django.conf.urls import include, url
|
|
|
|
from django.urls import path
|
|
from recipe import views
|
|
|
|
|
|
# Wire up our API using automatic URL routing.
|
|
# Additionally, we include login URLs for the browsable API.
|
|
from rest_framework_nested import routers
|
|
|
|
router = routers.DefaultRouter()
|
|
router.register(r'recipe', views.RecipeAPI)
|
|
router.register(r'ingredient', views.IngredientAPI)
|
|
recipe_nested_router = routers.NestedSimpleRouter(router, r'recipe', lookup='recipe')
|
|
recipe_nested_router.register(r'recipe-ingredient', views.RecipeIngredientAPI)
|
|
|
|
urlpatterns = [
|
|
url(r'^week-recipe/$', views.WeekRecipeListAPI.as_view()),
|
|
url(r'^daily-recipe/(?P<pk>\d+)$', views.DailyRecipeAPI.as_view(), name='dailyrecipe-detail'),
|
|
path(r'', include(router.urls)),
|
|
path(r'', include(recipe_nested_router.urls)),
|
|
]
|