diff --git a/djangoproject/__init__.py b/djangoproject/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/djangoproject/__init__.pyc b/djangoproject/__init__.pyc new file mode 100644 index 0000000..41fde74 Binary files /dev/null and b/djangoproject/__init__.pyc differ diff --git a/djangoproject/admin.py b/djangoproject/admin.py new file mode 100644 index 0000000..2173ebb --- /dev/null +++ b/djangoproject/admin.py @@ -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) diff --git a/djangoproject/admin.pyc b/djangoproject/admin.pyc new file mode 100644 index 0000000..7086463 Binary files /dev/null and b/djangoproject/admin.pyc differ diff --git a/djangoproject/models.py b/djangoproject/models.py new file mode 100644 index 0000000..efd14c7 --- /dev/null +++ b/djangoproject/models.py @@ -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) diff --git a/djangoproject/models.pyc b/djangoproject/models.pyc new file mode 100644 index 0000000..0813203 Binary files /dev/null and b/djangoproject/models.pyc differ diff --git a/djangoproject/tests.py b/djangoproject/tests.py new file mode 100644 index 0000000..501deb7 --- /dev/null +++ b/djangoproject/tests.py @@ -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) diff --git a/djangoproject/views.py b/djangoproject/views.py new file mode 100644 index 0000000..60f00ef --- /dev/null +++ b/djangoproject/views.py @@ -0,0 +1 @@ +# Create your views here.