Skip to content

Commit

Permalink
feat : Create detail page to see trades
Browse files Browse the repository at this point in the history
Use sample data created by admin page.
main page has a list of region(동)
and detail pages have a list of real-estates of the region
and detail-trade pages have a list of trades of the real estate
Name of classes in View and Templates can be modified.
#8
  • Loading branch information
srlee056 committed Nov 8, 2023
1 parent fdf0f39 commit d49c7d1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
13 changes: 13 additions & 0 deletions trades/templates/trades/detail-trade.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{estate.estate_name}}의 거래 내역 {% if trades %}
<ul>
{% for trade in trades %}
<li>
{{trade.trade_year}}년 {{trade.trade_month}}월 {{trade.trade_day}}일
<br />
거래가 : {{trade.trade_price}}
</li>
{% endfor %}
</ul>
{% else %}
<p>거래가 존재하지 않습니다.</p>
{% endif %}
14 changes: 11 additions & 3 deletions trades/templates/trades/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ <h1>{{region.dong_name}}의 집값 추이는?</h1>
<p>{{biggest_increase}}은 00%로 가장 많이 오른 지역입니다.</p>
<p>{{biggest_decrease}}은 00%로 가장 많이 떨어진 지역입니다.</p>

{% if estates %} {% for estate in estates %}
<p>{{estate.estate_name}}</p>
{% endfor %} {% else %}
{% if estates %}
<ul>
{% for estate in estates %}
<li>
<a href="{% url 'trades:detail-trade' region.id estate.id %}"
>{{estate.estate_name}}</a
>
</li>
{% endfor %}
</ul>
{% else %}
<p>no estates.</p>
{% endif %}
</li>
Expand Down
7 changes: 6 additions & 1 deletion trades/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@

urlpatterns = [
path("", views.index, name="index"),
path("<int:region_id>/detail/", views.detail, name="detail"),
path("detail/<int:region_id>/", views.detail, name="detail"),
path(
"detail/<int:region_id>/<int:estate_id>/",
views.detail_trade,
name="detail-trade",
),
]

0 comments on commit d49c7d1

Please sign in to comment.