Skip to content

Commit

Permalink
fix: Update view based on model structure
Browse files Browse the repository at this point in the history
  • Loading branch information
srlee056 committed Nov 7, 2023
1 parent 9de5046 commit 4dded90
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 3 deletions.
8 changes: 8 additions & 0 deletions trades/templates/trades/detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<h1>{{region.dong_name}}의 집값 추이는?</h1>

<ul>
<li>
<p>{{biggest_increase}}은 00%로 가장 많이 오른 지역입니다.</p>
<p>{{biggest_decrease}}은 00%로 가장 많이 떨어진 지역입니다.</p>
</li>
</ul>
29 changes: 29 additions & 0 deletions trades/templates/trades/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<!DOCTYPE html>
<head></head>
<body>
<h1>주택 실거래 가격</h1>
<h3>우리 동네에서 실거래가 변화가 가장 큰 곳은 어디일까?</h3>

<div class="search-dropdown">
<p>드롭다운 검색창 위치</p>
</div>
<div class="map">
<p>지도 위치</p>
</div>
<div>
<p>지역 리스트 위치</p>
{% if regions %}
<ul>
{% for region in regions %}
<li>
<a href="{% url 'trades:detail' region.id %}"
>{{region.dong_name}}</a
>
</li>
{% endfor %}
</ul>
{%else%}
<p>no regions</p>
{%endif%}
</div>
</body>
5 changes: 4 additions & 1 deletion trades/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@
from . import views


urlpatterns = [path("", views.index, name="index")]
urlpatterns = [
path("", views.index, name="index"),
path("<int:region_id>/detail/", views.detail, name="detail"),
]
19 changes: 17 additions & 2 deletions trades/views.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
from django.shortcuts import render
from django.shortcuts import render, get_object_or_404
from django.http import HttpResponse
from .models import *


# Create your views here.
def index(request):
return HttpResponse("Test Response")
regions = Region.objects.all()
context = {"regions": regions}
return render(request, "trades/index.html", context)


def detail(request, region_id):
region = get_object_or_404(Region, pk=region_id)
biggest_increase = "정자동"
biggest_decrease = "상도동"
context = {
"region": region,
"biggest_increase": biggest_increase,
"biggest_decrease": biggest_decrease,
}
return render(request, "trades/detail.html", context)

0 comments on commit 4dded90

Please sign in to comment.