-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
권아림
committed
Jul 26, 2024
1 parent
4c2a6cc
commit a0682ca
Showing
7 changed files
with
59 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from rest_framework import serializers | ||
from .models import Friend | ||
|
||
|
||
class FriendSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Friend | ||
fields = "__all__" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from rest_framework import serializers | ||
from .models import Restaurant | ||
|
||
|
||
class RestaurantSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Restaurant | ||
fields = "__all__" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.urls import path, include | ||
from restaurants import views | ||
|
||
|
||
urlpatterns = [ | ||
path("restaurants/", views.restaurant_list), | ||
path("api-auth/", include("rest_framework.urls", namespace="rest_framework")), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,13 @@ | ||
# from django.shortcuts import render | ||
from django.http import JsonResponse | ||
from django.views.decorators.csrf import csrf_exempt | ||
from .models import Restaurant | ||
from .serializers import RestaurantSerializer | ||
|
||
# Create your views here. | ||
|
||
@csrf_exempt | ||
def restaurant_list(request): | ||
if request.method == "GET": | ||
restaurants = Restaurant.objects.all() | ||
serializer = RestaurantSerializer(restaurants, many=True) | ||
return JsonResponse(serializer.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from rest_framework import serializers | ||
from .models import Review, Recommend | ||
|
||
|
||
class ReviewSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Review | ||
fields = "__all__" | ||
|
||
|
||
class RecommendSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = Recommend | ||
fields = "__all__" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from rest_framework import serializers | ||
from .models import User | ||
|
||
|
||
class UserSerializer(serializers.ModelSerializer): | ||
class Meta: | ||
model = User | ||
fields = "__all__" |