Skip to content

Commit ae3fdad

Browse files
author
Katarina Achbergerova
committed
initial commit
1 parent 36b2c48 commit ae3fdad

303 files changed

Lines changed: 33660 additions & 0 deletions

File tree

Some content is hidden

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

blog/__init__.py

Whitespace-only changes.
129 Bytes
Binary file not shown.
252 Bytes
Binary file not shown.
934 Bytes
Binary file not shown.

blog/admin.py

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

blog/migrations/0001_initial.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# -*- coding: utf-8 -*-
2+
from __future__ import unicode_literals
3+
4+
from django.db import models, migrations
5+
from django.conf import settings
6+
import django.utils.timezone
7+
8+
9+
class Migration(migrations.Migration):
10+
11+
dependencies = [
12+
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
13+
]
14+
15+
operations = [
16+
migrations.CreateModel(
17+
name='Post',
18+
fields=[
19+
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
20+
('title', models.CharField(max_length=200)),
21+
('text', models.TextField()),
22+
('created_date', models.DateTimeField(default=django.utils.timezone.now)),
23+
('published_date', models.DateTimeField(null=True, blank=True)),
24+
('author', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
25+
],
26+
),
27+
]

blog/migrations/__init__.py

Whitespace-only changes.
1.08 KB
Binary file not shown.
140 Bytes
Binary file not shown.

blog/models.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from django.db import models
2+
3+
from django.utils import timezone
4+
5+
6+
class Post(models.Model):
7+
author = models.ForeignKey('auth.User')
8+
title = models.CharField(max_length=200)
9+
text = models.TextField()
10+
created_date = models.DateTimeField(
11+
default=timezone.now)
12+
published_date = models.DateTimeField(
13+
blank=True, null=True)
14+
15+
def publish(self):
16+
self.published_date = timezone.now()
17+
self.save()
18+
19+
def __str__(self):
20+
return self.title

0 commit comments

Comments
 (0)