first model commit
This commit is contained in:
parent
791bfb060d
commit
488ecaf1ef
|
@ -31,6 +31,8 @@ ALLOWED_HOSTS = []
|
|||
# Application definition
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'flat',
|
||||
'django_extensions',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
django
|
||||
django-flat-theme
|
||||
django-extensions
|
|
@ -1,3 +1,13 @@
|
|||
from django.contrib import admin
|
||||
from django_extensions.admin import ForeignKeyAutocompleteAdmin
|
||||
|
||||
# Register your models here.
|
||||
from todo.models import Context, Project, Task
|
||||
|
||||
class TaskAdmin(ForeignKeyAutocompleteAdmin):
|
||||
related_search_fields = {
|
||||
'project' : ('name',),
|
||||
}
|
||||
|
||||
admin.site.register(Context)
|
||||
admin.site.register(Project)
|
||||
admin.site.register(Task, TaskAdmin)
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import models, migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Context',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Project',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')),
|
||||
('name', models.CharField(max_length=255)),
|
||||
],
|
||||
),
|
||||
migrations.CreateModel(
|
||||
name='Task',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False, auto_created=True, verbose_name='ID')),
|
||||
('description', models.CharField(max_length=2000)),
|
||||
('contexts', models.ManyToManyField(to='todo.Context')),
|
||||
('project', models.ForeignKey(to='todo.Project')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -1,3 +1,22 @@
|
|||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
class Project(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Context(models.Model):
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Task(models.Model):
|
||||
description = models.CharField(max_length=2000)
|
||||
project = models.ForeignKey('Project')
|
||||
contexts = models.ManyToManyField('Context')
|
||||
|
||||
def __str__(self):
|
||||
return self.description
|
||||
|
|
Loading…
Reference in New Issue