Created
July 19, 2012 15:21
-
-
Save Bentley4/3144632 to your computer and use it in GitHub Desktop.
models.py in myproject/todo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
from django.contrib import admin | |
class DateTime(models.Model): | |
datetime = models.DateTimeField(auto_now_add = True) | |
def __unicode__(self): | |
return unicode(self.datetime) | |
class Item(models.Model): | |
name = models.CharField(max_length = 60) | |
created = models.DateTimeField(auto_now_add = True) | |
priority = models.IntegerField(default = 0) | |
difficulty = models.IntegerField(default = 0) | |
done = models.BooleanField(default = False) | |
class ItemAdmin(admin.ModelAdmin): | |
list_display = ["name", "priority", "difficulty", "created", "done"] | |
search_fields = ["name"] | |
class ItemInline(admin.TabularInline): | |
model = Item | |
class DateAdmin(admin.ModelAdmin): | |
list_display = ["datetime"] | |
inlines = [ItemInline] | |
admin.site.register(Item, ItemAdmin) | |
admin.site.register(DateTime, DateAdmin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment