Programming/Django49 [Python Django] The Practical Guide - Admin, Relationship The Django Admin FeatureEasy & Powerful Data Administrationbook_outlet//admin.pyadmin.site.register(Book)admin.py Data Relationship데이터는 종종 연결되어 있다. j.k 롤링은 해리포터의 많은 시리즈를 작성했다. 다양한 종류의 데이터 연결 타입이 있다. 일대일, 일대다, 다대다..각각의 관계를 하나씩 살펴보자class Author(models.Model): first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100) author = models.ForeignKey(Author, on_delete=mo.. 2025. 7. 23. [Python Django] The Practical Guide - Data & Models (3) Model URLs li>a href="{% url "book-detail" book.id %}">{{ book.title }} (Rating: {{ book.rating }})a> li> index.htmlurlpatterns = [ path("", views.index), path("", views.book_detail, name="book-detail")]urls.pyURL을 생성하기 위해 {% url %} 템플릿 태그 사용def get_absolute_url(self): return reverse("book-detail", args=[self.id]) models.py li>a href="{{ book.get_absolute_url }}">{{ book.title }} (Rating: {{ bo.. 2025. 7. 22. [Python Django] The Practical Guide - Data & Models (2) {% extends "book_outlet/base.html" %}{% block title %} All Books{% endblock %}{% block content %} {% for book in books %} {{ book.title }} (Rating: {{ book.rating }}) {% endfor %} {% endblock %}index.html from django.shortcuts import get_object_or_404, renderfrom django.http import Http404from .models import Book# Create your views here.def index(request): .. 2025. 7. 22. [Python Django] The Practical Guide - Data & Models 재시작 될 때 마다 모든 데이터가 날아간다. data query functionality가 없다. 현실적이지 않다. 영원히 저장되는 데이터가 필요하다 ! database- What is "Data" and a "Database" ?- Exploring SQL & Models- Django, Models. & Database Queries Different Kinds of Data- Temporary Data: User Input, Selected Blog PostData is used immediately and lost thereafterStore in Memory (Variables)- Semi-Persistent Data: User authentication statusData is stored f.. 2025. 7. 22. [Python Django - The Practical Guide] 장고로 블로그 만들기 프로젝트 (기초) 새로운 프로젝트를 진행한다. 프로젝트는 블로그를 만드는 것!강의를 듣기 전에 내가 할 수 있는 데 까지 해보는 걸로 .. 1. URLs & Viewspath는 3개를 설정한다. /# urls.pyfrom django.urls import pathfrom . import viewsurlpatterns = [ # path("", views.index, name="index"), # path("", views.all_posts, name="blog-post") path(""), path("posts"), path("posts/") # dynamic segment (angle bracket), parameter name -> /posts/my-first-post]# Q. 장고에서.. 2025. 7. 21. [Django] 2. URLs & Views 핵심 요약 1. ✅ URLs (또는 Routes)란?사용자가 접근할 수 있는 경로(Route)를 정의하나의 Django 프로젝트는 다양한 URL을 가질 수 있으며, 각각의 URL에 다른 응답(views) 이 매핑됨URLConf(urls.py)에서 URL 패턴을 등록하고 해당 URL에 맞는 뷰(view)로 연결2. ✅ Views란?URL에 대한 처리 로직을 담은 함수 또는 클래스요청(request)을 받아 데이터를 처리하고 응답(response)을 생성View의 주요 역할:데이터 불러오기 / 가공비즈니스 로직 수행HTML, JSON 등 응답 생성 및 반환def my_view(request): # 요청 처리 로직 return HttpResponse("Hello!")Django에서는 function-based.. 2025. 7. 20. 이전 1 ··· 4 5 6 7 8 9 다음