Skip to content

Commit d25b7fa

Browse files
committed
Added app
1 parent 954b72d commit d25b7fa

22 files changed

+195
-0
lines changed

blog/__init__.py

Whitespace-only changes.
132 Bytes
Binary file not shown.

blog/__pycache__/admin.cpython-34.pyc

565 Bytes
Binary file not shown.
1.4 KB
Binary file not shown.

blog/admin.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.contrib import admin
2+
from . import models
3+
4+
class EntryAdmin(admin.ModelAdmin):
5+
list_display = ("title", "created")
6+
prepopulated_fields = {"slug": ("title",)}
7+
8+
admin.site.register(models.Entry, EntryAdmin)
9+
from django.contrib import admin
10+
11+
# Register your models here.

blog/migrations/0001_initial.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
6+
7+
class Migration(migrations.Migration):
8+
9+
dependencies = [
10+
]
11+
12+
operations = [
13+
migrations.CreateModel(
14+
name='Entry',
15+
fields=[
16+
('id', models.AutoField(primary_key=True, verbose_name='ID', auto_created=True, serialize=False)),
17+
('title', models.CharField(max_length=200)),
18+
('body', models.TextField()),
19+
('slug', models.SlugField(max_length=200, unique=True)),
20+
('publish', models.BooleanField(default=False)),
21+
('created', models.DateTimeField(auto_now_add=True)),
22+
('modified', models.DateTimeField(auto_now=True)),
23+
],
24+
options={
25+
'verbose_name_plural': 'Blog Entries',
26+
'verbose_name': 'Blog Entry',
27+
'ordering': ['-created'],
28+
},
29+
bases=(models.Model,),
30+
),
31+
]

blog/migrations/__init__.py

Whitespace-only changes.
Binary file not shown.
143 Bytes
Binary file not shown.

blog/models.py

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from django.db import models
2+
from django.core.urlresolvers import reverse
3+
4+
class EntryQuerySet(models.QuerySet):
5+
def published(self):
6+
return self.filter(publish=True)
7+
8+
class Entry(models.Model):
9+
title = models.CharField(max_length=200)
10+
body = models.TextField()
11+
slug = models.SlugField(max_length=200, unique=True)
12+
publish = models.BooleanField(default=False)
13+
created = models.DateTimeField(auto_now_add=True)
14+
modified = models.DateTimeField(auto_now=True)
15+
16+
objects = EntryQuerySet.as_manager()
17+
18+
def __str__(self):
19+
return self.title
20+
21+
class Meta:
22+
verbose_name = "Blog Entry"
23+
verbose_name_plural = "Blog Entries"
24+
ordering = ["-created"]
25+
from django.db import models
26+
27+
# Create your models here.

blog/tests.py

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

blog/views.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.shortcuts import render
2+
3+
# Create your views here.

db.sqlite3

38 KB
Binary file not shown.

django_blog/__init__.py

Whitespace-only changes.
139 Bytes
Binary file not shown.
1.64 KB
Binary file not shown.
348 Bytes
Binary file not shown.
568 Bytes
Binary file not shown.

django_blog/settings.py

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
"""
2+
Django settings for django_blog project.
3+
4+
For more information on this file, see
5+
https://docs.djangoproject.com/en/1.7/topics/settings/
6+
7+
For the full list of settings and their values, see
8+
https://docs.djangoproject.com/en/1.7/ref/settings/
9+
"""
10+
11+
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
12+
import os
13+
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
14+
15+
16+
# Quick-start development settings - unsuitable for production
17+
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
18+
19+
# SECURITY WARNING: keep the secret key used in production secret!
20+
SECRET_KEY = '*!tgz!1#krd#w7d9lgs_t1(8kx30%n23xmy21j0+!g6342a&ds'
21+
22+
# SECURITY WARNING: don't run with debug turned on in production!
23+
DEBUG = True
24+
25+
TEMPLATE_DEBUG = True
26+
27+
ALLOWED_HOSTS = []
28+
29+
30+
# Application definition
31+
32+
INSTALLED_APPS = (
33+
'django.contrib.admin',
34+
'django.contrib.auth',
35+
'django.contrib.contenttypes',
36+
'django.contrib.sessions',
37+
'django.contrib.messages',
38+
'django.contrib.staticfiles',
39+
'blog',
40+
'django_markdown',
41+
)
42+
43+
MIDDLEWARE_CLASSES = (
44+
'django.contrib.sessions.middleware.SessionMiddleware',
45+
'django.middleware.common.CommonMiddleware',
46+
'django.middleware.csrf.CsrfViewMiddleware',
47+
'django.contrib.auth.middleware.AuthenticationMiddleware',
48+
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
49+
'django.contrib.messages.middleware.MessageMiddleware',
50+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
51+
)
52+
53+
ROOT_URLCONF = 'django_blog.urls'
54+
55+
WSGI_APPLICATION = 'django_blog.wsgi.application'
56+
57+
58+
# Database
59+
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
60+
61+
DATABASES = {
62+
'default': {
63+
'ENGINE': 'django.db.backends.sqlite3',
64+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
65+
}
66+
}
67+
68+
# Internationalization
69+
# https://docs.djangoproject.com/en/1.7/topics/i18n/
70+
71+
LANGUAGE_CODE = 'en-us'
72+
73+
TIME_ZONE = 'UTC'
74+
75+
USE_I18N = True
76+
77+
USE_L10N = True
78+
79+
USE_TZ = True
80+
81+
82+
# Static files (CSS, JavaScript, Images)
83+
# https://docs.djangoproject.com/en/1.7/howto/static-files/
84+
85+
STATIC_URL = '/static/'

django_blog/urls.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from django.conf.urls import patterns, include, url
2+
from django.contrib import admin
3+
4+
urlpatterns = patterns('',
5+
# Examples:
6+
# url(r'^$', 'django_blog.views.home', name='home'),
7+
# url(r'^blog/', include('blog.urls')),
8+
url(r'^markdown/', include('django_markdown.urls')),
9+
10+
url(r'^admin/', include(admin.site.urls)),
11+
)

django_blog/wsgi.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
"""
2+
WSGI config for django_blog project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_blog.settings")
12+
13+
from django.core.wsgi import get_wsgi_application
14+
application = get_wsgi_application()

manage.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/usr/bin/env python
2+
import os
3+
import sys
4+
5+
if __name__ == "__main__":
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_blog.settings")
7+
8+
from django.core.management import execute_from_command_line
9+
10+
execute_from_command_line(sys.argv)

0 commit comments

Comments
 (0)