Skip to content

Commit

Permalink
List
Browse files Browse the repository at this point in the history
  • Loading branch information
sgd122 committed Mar 11, 2020
1 parent f50dcc6 commit 42d8dc1
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 2 deletions.
17 changes: 16 additions & 1 deletion backend/backend/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

# Application definition

INSTALLED_APPS = [
DJANGO_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand All @@ -41,6 +41,21 @@
'django.contrib.staticfiles',
]

THIRD_PARTY_APPS = ["rest_framework"]

PROJECT_APPS = [
"foods.apps.FoodsConfig",
]

INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + PROJECT_APPS

REST_FRAMEWORK = {
'DEFAULT_RENDERER_CLASSES': [
'rest_framework.renderers.JSONRenderer',
'rest_framework.renderers.BrowsableAPIRenderer',
]
}

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
Expand Down
16 changes: 15 additions & 1 deletion backend/backend/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,22 @@
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include, path
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path("foods/", include("foods.urls")),
]


urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

if settings.DEBUG:
import debug_toolbar

urlpatterns += [
path("__debug__/", include(debug_toolbar.urls)),
]

10 changes: 10 additions & 0 deletions backend/foods/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.urls import path
# from ..view import common_views as views
from . import views

app_name = "foods"

urlpatterns = [
path("list/", views.foods_list),
]

22 changes: 22 additions & 0 deletions backend/foods/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
from django.shortcuts import render
from rest_framework.decorators import api_view
from rest_framework.response import Response
from django.http import HttpResponse,Http404, HttpResponseNotFound

# Create your views here.
@api_view(['GET', 'POST'])
def foods_list(request):
'''
음식점 리스트를 조회한다.
'''
foods_list = [
{ 'id': 1, 'title': '강가네손만두', 'content': '칼국수/만두' },
{ 'id': 2, 'title': '마봉자김밥', 'content': '분식(라면/김밥/오므라이스...)' },
{ 'id': 3, 'title': '맥도날드', 'content': '햄버거' },
{ 'id': 4, 'title': '갈비탕', 'content': '갈비탕' },
{ 'id': 5, 'title': '유가네닭갈비', 'content': '볶음밥' },
{ 'id': 6, 'title': '하늘한우', 'content': '점심특선(고기/된장찌개)' },
{ 'id': 7, 'title': '맘스터치', 'content': '햄버거' },
{ 'id': 8, 'title': '천운숯불갈비', 'content': '점심특선(고기/된장찌개)' },
{ 'id': 9, 'title': '철호국밥', 'content': '국밥' },
{ 'id': 10, 'title': '더도이종가집', 'content': '국밥' },
{ 'id': 11, 'title': '오쇼김밥', 'content': '분식(라면/김밥/오므라이스...)' },
]
return Response(foods_list)
1 change: 1 addition & 0 deletions frontend/src/settings/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export function Food() {
{ id: 8, title: '천운숯불갈비', content: '점심특선(고기/된장찌개)', images: img03 },
{ id: 9, title: '철호국밥', content: '국밥', images: img03 },
{ id: 10, title: '더도이종가집', content: '국밥', images: img03 },
{ id: 11, title: '오쇼김밥', content: '분식(라면/김밥/오므라이스...)', images: img03 },
];

return FoodList;
Expand Down

0 comments on commit 42d8dc1

Please sign in to comment.