Skip to content

Commit

Permalink
Some tutorials for Django ticket #18581
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinlondon committed Jul 15, 2012
1 parent c432c9b commit 696b7ab
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 0 deletions.
Empty file added djangoproject/__init__.py
Empty file.
Binary file added djangoproject/__init__.pyc
Binary file not shown.
25 changes: 25 additions & 0 deletions djangoproject/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from django.contrib import admin
from djangoproject.models import Author, Article

class AuthorAdmin(admin.ModelAdmin):
pass

class ArticleAdmin(admin.ModelAdmin):
list_display = ['title', 'status']
ordering = ['title']
actions = ['make_published']

def make_published(self, request, queryset):
rows_updated = queryset.update(status='p')
if rows_updated == 1:
message_bit = "1 story was"
else:
message_bit = "%s stories were" % rows_updated
self.message_user(request, "%s successfully marked as published." \
% message_bit)

make_published.short_description = "Mark selected stories as published"


admin.site.register(Author, AuthorAdmin)
admin.site.register(Article, ArticleAdmin)
Binary file added djangoproject/admin.pyc
Binary file not shown.
20 changes: 20 additions & 0 deletions djangoproject/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from django.db import models

STATUS_CHOICES = (
('d', 'Draft'),
('p', 'Published'),
('w', 'Withdrawn'),
)

class Article(models.Model):
title = models.CharField(max_length=100)
body = models.TextField()
status = models.CharField(max_length=1, choices=STATUS_CHOICES)

def __unicode__(self):
return self.title

class Author(models.Model):
name = models.CharField(max_length=100)
title = models.CharField(max_length=3)
birth_date = models.DateField(blank=True, null=True)
Binary file added djangoproject/models.pyc
Binary file not shown.
16 changes: 16 additions & 0 deletions djangoproject/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
This file demonstrates writing tests using the unittest module. These will pass
when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""

from django.test import TestCase


class SimpleTest(TestCase):
def test_basic_addition(self):
"""
Tests that 1 + 1 always equals 2.
"""
self.assertEqual(1 + 1, 2)
1 change: 1 addition & 0 deletions djangoproject/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# Create your views here.

0 comments on commit 696b7ab

Please sign in to comment.