Skip to content
Snippets Groups Projects
Commit 57758efd authored by 김시환's avatar 김시환
Browse files

add search page

parent 1a61a913
No related branches found
No related tags found
No related merge requests found
from django.urls import path from django.urls import path
from .views import UploadFeed, LikeFeed, ViewFeed, DeleteFeed, searchUniv, searchUser from .views import UploadFeed, LikeFeed, ViewFeed, DeleteFeed, searchUniv, searchUser, searchPage
app_name = 'content'
urlpatterns = [ urlpatterns = [
path('upload', UploadFeed.as_view(), name='upload_feed'), path('upload', UploadFeed.as_view(), name='upload_feed'),
...@@ -9,7 +10,8 @@ urlpatterns = [ ...@@ -9,7 +10,8 @@ urlpatterns = [
path('view', ViewFeed.as_view(), name='view'), path('view', ViewFeed.as_view(), name='view'),
## 시환님꺼 ## 시환님꺼
path('delete', DeleteFeed.as_view(), name='delete_feed'), path('delete', DeleteFeed.as_view(), name='delete_feed'),
path('searchUniv', searchUniv.as_view(), name='seacrh_univ'), path('searchUniv', searchUniv.as_view(), name='search_univ'),
path('searchUser', searchUser.as_view(), name='search_user'), path('searchUser', searchUser.as_view(), name='search_user'),
path('searchPage', searchPage.as_view(), name='search_page'),
] ]
from django.shortcuts import render from django.shortcuts import render, redirect
from rest_framework.views import APIView from rest_framework.views import APIView
from content.models import Feed, FeedLike, FeedView from content.models import Feed, FeedLike, FeedView
from rest_framework.response import Response from rest_framework.response import Response
...@@ -100,10 +100,11 @@ class DeleteFeed(APIView): ...@@ -100,10 +100,11 @@ class DeleteFeed(APIView):
def post(self, request): def post(self, request):
feed_id = request.data.get('feed_id') feed_id = request.data.get('feed_id')
email = request.data.get('email') email = request.data.get('email')
# feed_id = 1 # feed_id = 1
# email = "ksshhses@ajou.ac.kr" # email = "ksshhses@ajou.ac.kr"
return redirect('main', permanent=True)
print("안 나오지?")
feed = Feed.objects.filter(id=feed_id).first() feed = Feed.objects.filter(id=feed_id).first()
if feed is None: if feed is None:
...@@ -111,7 +112,8 @@ class DeleteFeed(APIView): ...@@ -111,7 +112,8 @@ class DeleteFeed(APIView):
if feed.email == email: if feed.email == email:
feed.delete() feed.delete()
return render(request, "jinstagram/main.html") #프로필페이지 print("here?")
return redirect('profile') #프로필페이지
else: else:
return Response(status=500, data=dict(message='삭제 실패')) return Response(status=500, data=dict(message='삭제 실패'))
...@@ -139,3 +141,10 @@ class searchUser(APIView): ...@@ -139,3 +141,10 @@ class searchUser(APIView):
return Response(status=404, data=dict(message='유저가 없습니다.')) return Response(status=404, data=dict(message='유저가 없습니다.'))
else: else:
return Response(status=200, data=dict(user=user_list)) return Response(status=200, data=dict(user=user_list))
class searchPage(APIView):
def get(self, request):
univ_list = Univ.objects.all().order_by('univ')
univ_list = {'univ_list':univ_list}
return render(request, 'jinstagram/sample.html', univ_list)
\ No newline at end of file
...@@ -77,18 +77,18 @@ WSGI_APPLICATION = 'jinstagram.wsgi.application' ...@@ -77,18 +77,18 @@ WSGI_APPLICATION = 'jinstagram.wsgi.application'
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases # https://docs.djangoproject.com/en/3.2/ref/settings/#databases
DATABASES = { DATABASES = {
# 'default': {
# 'ENGINE': 'django.db.backends.mysql',
# 'NAME': 'campics',
# 'USER': 'root',
# 'PASSWORD': '1101',
# 'HOST': 'localhost',
# 'PORT': '3306',
# }
'default': { 'default': {
'ENGINE': 'django.db.backends.sqlite3', 'ENGINE': 'django.db.backends.mysql',
'NAME': BASE_DIR / 'db.sqlite3', 'NAME': 'campics',
'USER': 'root',
'PASSWORD': '1101',
'HOST': 'localhost',
'PORT': '3306',
} }
# 'default': {
# 'ENGINE': 'django.db.backends.sqlite3',
# 'NAME': BASE_DIR / 'db.sqlite3',
# }
} }
......
{% for univ in univ_list %}
{{ univ.id }}
{{ univ.univ }}
{% endfor %}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment