신은섭(Shin Eun Seop)

add template

......@@ -38,7 +38,8 @@ INSTALLED_APPS = [
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'restful.apps.RestfulConfig'
'restful.apps.RestfulConfig',
'website'
]
MIDDLEWARE = [
......
......@@ -16,7 +16,9 @@ Including another URLconf
from django.contrib import admin
from django.conf.urls import url, include
urlpatterns = [
url('admin/', admin.site.urls),
url(r'^', include('restful.urls')),
]
url(r'^admin/', admin.site.urls),
url(r'^restapi/', include('restful.urls')),
url(r'^', include('website.urls')),
]
\ No newline at end of file
......
......@@ -5,12 +5,13 @@ from django.db import models
class File(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
title = models.CharField(max_length=100)
file_name = models.CharField(max_length=100)
# file_name = models.CharField(max_length=100, primary_key=True)
object_key = models.CharField(max_length=1025)
size = models.IntegerField()
# owner = models.ForeignKey('auth.User', related_name='snippets', on_delete=models.CASCADE)
class Meta:
ordering = ('title',)
ordering = ('file_name',)
......
from django.contrib import admin
from website.models import Post
admin.site.register(Post)
\ No newline at end of file
from django.apps import AppConfig
class WebsiteConfig(AppConfig):
name = 'website'
from django.db import models
from django.utils import timezone
class Post(models.Model):
author = models.ForeignKey('auth.User', on_delete=models.CASCADE)
title = models.CharField(max_length=200)
text = models.TextField()
created_date = models.DateTimeField(
default=timezone.now)
published_date = models.DateTimeField(
blank=True, null=True)
def publish(self):
self.published_date = timezone.now()
self.save()
def __str__(self):
return self.title
h1 a {
color: #FCA205;
font-family: 'Lobster';
}
body {
padding-left: 15px;
}
.page-header {
background-color: #ff9400;
margin-top: 0;
padding: 20px 20px 20px 40px;
}
.page-header h1, .page-header h1 a, .page-header h1 a:visited, .page-header h1 a:active {
color: #ffffff;
font-size: 36pt;
text-decoration: none;
}
.content {
margin-left: 40px;
}
h1, h2, h3, h4 {
font-family: 'Lobster', cursive;
}
.date {
color: #828282;
}
.save {
float: right;
}
.post-form textarea, .post-form input {
width: 100%;
}
.top-menu, .top-menu:hover, .top-menu:visited {
color: #ffffff;
float: right;
font-size: 26pt;
margin-right: 20px;
}
.post {
margin-bottom: 70px;
}
.post h1 a, .post h1 a:visited {
color: #000000;
}
\ No newline at end of file
{% extends "base_generic.html" %}
{% block content %}
<p>Logged out!</p>
<a href="{% url 'login'%}">Click here to login again.</a>
{% endblock %}
\ No newline at end of file
{% extends "base_generic.html" %}
{% block content %}
{% if form.errors %}
<p>Your username and password didn't match. Please try again.</p>
{% endif %}
{% if next %}
{% if user.is_authenticated %}
<p>Your account doesn't have access to this page. To proceed,
please login with an account that has access.</p>
{% else %}
<p>Please login to see this page.</p>
{% endif %}
{% endif %}
<form method="post" action="{% url 'login' %}">
{% csrf_token %}
<div>
<td>{{ form.username.label_tag }}</td>
<td>{{ form.username }}</td>
</div>
<div>
<td>{{ form.password.label_tag }}</td>
<td>{{ form.password }}</td>
</div>
<div>
<input type="submit" value="login" />
<input type="hidden" name="next" value="{{ next }}" />
</div>
</form>
{# Assumes you setup the password_reset view in your URLconf #}
<p><a href="{% url 'password_reset' %}">Lost password?</a></p>
{% endblock %}
\ No newline at end of file
{% load staticfiles %}
<html>
<head>
<title>Django Girls blog</title>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
<link href="//fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="{% static 'css/posts.css' %}">
</head>
<body>
<div class="page-header">
<h1><a href="/">Django Girls Blog</a></h1>
</div>
<div class="content container">
<div class="row">
<div class="col-md-8">
{% block content %}
{% endblock %}
</div>
</div>
</div>
</body>
</html>
\ No newline at end of file
{{files}}
\ No newline at end of file
{% extends 'website/base.html' %}
{% block content %}
<div class="post">
{% if post.published_date %}
<div class="date">
{{ post.published_date }}
</div>
{% endif %}
<h1>{{ post.title }}</h1>
<p>{{ post.text|linebreaksbr }}</p>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'website/base.html' %}
{% block content %}
{% for post in posts %}
<div class="post">
<div class="date">
<p>published: {{ post.published_date }}</p>
</div>
<h1>
<h1><a href="{% url 'post_detail' pk=post.pk %}">{{ post.title }}</a></h1>
</h1>
<p>{{ post.text|linebreaksbr }}</p>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from website import views
urlpatterns = [
url(r'^$', views.post_list, name='post_list'),
url(r'^post/(?P<pk>\d+)/$', views.post_detail, name='post_detail'),
url(r'^files/', views.file_list, name='file_list'),
]
\ No newline at end of file
from django.shortcuts import render, get_object_or_404
from django.utils import timezone
from website.models import Post
from restful.models import File
# Create your views here.
def post_list(request):
posts = Post.objects.filter(published_date__lte=timezone.now()).order_by('published_date')
return render(request, 'website/post_list.html', {'posts':posts})
def file_list(request):
files = File.objects.all()
return render(request, 'website/file_list.html', {'files': files})
def post_detail(request, pk):
post = get_object_or_404(Post, pk=pk)
return render(request, 'website/post_detail.html', {'post': post})