본문 바로가기

Python_WEB/Project-Noticeboard

(13)
[Django]User > Views from django.shortcuts import render, redirect from django.core.paginator import Paginator from django.http import Http404 from fcuser.models import Fcuser from tag.models import Tag from .models import Board from .forms import BoardForm # Create your views here. def board_detail(request, pk): try: board = Board.objects.get(pk=pk) except Board.DoesNotExist: raise Http404('게시글을 찾을 수 없습니다.') return..
[Django]User > Forms from django import forms class BoardForm(forms.Form): title = forms.CharField(error_messages={ 'required': '제목을 입력해주세요.' }, max_length=128, label="제목") contents = forms.CharField(error_messages={ 'required': '내용을 입력해주세요.' }, widget=forms.Textarea, label="내용") tags = forms.CharField(required=False, label="태그")
[Django]Board > Templates > HTML > Login {% extends "base.html" %} {% block contents %} 로그인 {{ error }} {% csrf_token %} {% for field in form %} {{ field.label }} {% if field.errors %} {{ field.errors }} {% endif %} {% endfor %} 로그인 {% endblock %}
[Django]User > Templates > HTML > Register {% extends "base.html" %} {% block contents %} 회원가입 {{ error }} {% csrf_token %} 사용자 이름 사용자 이메일 비밀번호 비밀번호 확인 등록 {% endblock %}
[Django]User > Templates > HTML > Home {% extends "base.html" %} {% block contents %} 홈페이지! {% if request.session.user %} 로그아웃 {% else %} 로그인 회원가입 {% endif %} 게시물보기 {% endblock %}
[Django]User > Templates > HTML > Basic {% block contents %} {% endblock %}
[Django]Board > Views from django.shortcuts import render, redirect from django.core.paginator import Paginator from django.http import Http404 from fcuser.models import Fcuser from tag.models import Tag from .models import Board from .forms import BoardForm # Create your views here. def board_detail(request, pk): try: board = Board.objects.get(pk=pk) except Board.DoesNotExist: raise Http404('게시글을 찾을 수 없습니다.') return..
[Django]Board > Forms from django import forms class BoardForm(forms.Form): title = forms.CharField(error_messages={ 'required': '제목을 입력해주세요.' }, max_length=128, label="제목") contents = forms.CharField(error_messages={ 'required': '내용을 입력해주세요.' }, widget=forms.Textarea, label="내용") tags = forms.CharField(required=False, label="태그")