Skip to content

Commit 2101284

Browse files
committed
added website
1 parent b087659 commit 2101284

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+10502
-0
lines changed

website/mysite/blog/__init__.py

Whitespace-only changes.

website/mysite/blog/admin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from django.contrib import admin
2+
from blog.models import Post
3+
4+
admin.site.register(Post)

website/mysite/blog/apps.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import unicode_literals
2+
3+
from django.apps import AppConfig
4+
5+
6+
class BlogConfig(AppConfig):
7+
name = 'blog'
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# -*- coding: utf-8 -*-
2+
# Generated by Django 1.10.6 on 2017-04-08 17:20
3+
from __future__ import unicode_literals
4+
5+
from django.db import migrations, models
6+
7+
8+
class Migration(migrations.Migration):
9+
10+
initial = True
11+
12+
dependencies = [
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='Post',
18+
fields=[
19+
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
20+
('title', models.CharField(max_length=140)),
21+
('body', models.TextField()),
22+
('date', models.DateTimeField()),
23+
],
24+
),
25+
]

website/mysite/blog/migrations/__init__.py

Whitespace-only changes.

website/mysite/blog/models.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from __future__ import unicode_literals
2+
3+
from django.db import models
4+
5+
class Post(models.Model):
6+
title = models.CharField(max_length=140)
7+
body = models.TextField()
8+
date = models.DateTimeField()
9+
10+
def __str__(self):
11+
return self.title
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{% extends "personal/header.html" %}
2+
3+
{% block content %}
4+
{% for post in object_list %}
5+
<h5> {{ post.date|date:"Y-m-d" }}
6+
<a href="/blog/{{post.id}}"> {{post.title}} </a>
7+
</h5>
8+
{% endfor %}
9+
{% endblock %}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{% extends "personal/header.html" %}
2+
3+
{% block content %}
4+
<h3> {{post.title}} </h3>
5+
<h6> on {{post.date}} </h6>
6+
{{post.body|safe|linebreaks}}
7+
{% endblock %}

website/mysite/blog/tests.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

website/mysite/blog/urls.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from django.conf.urls import url, include
2+
from django.views.generic import ListView, DetailView
3+
from blog.models import Post
4+
5+
urlpatterns = [ url(r'^$', ListView.as_view(queryset=Post.objects.all().order_by("-date")[:25],
6+
template_name="blog/blog.html")),
7+
url(r'^(?P<pk>\d+)$', DetailView.as_view(model = Post,
8+
template_name = 'blog/post.html'))]

0 commit comments

Comments
 (0)