Initial entry of models
This commit is contained in:
0
project_directory/common/__init__.py
Normal file
0
project_directory/common/__init__.py
Normal file
5
project_directory/common/admin.py
Normal file
5
project_directory/common/admin.py
Normal file
@@ -0,0 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from common.models import Category, Sample
|
||||
|
||||
admin.site.register(Category)
|
||||
admin.site.register(Sample)
|
||||
55
project_directory/common/migrations/0001_initial.py
Normal file
55
project_directory/common/migrations/0001_initial.py
Normal file
@@ -0,0 +1,55 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import datetime
|
||||
from south.db import db
|
||||
from south.v2 import SchemaMigration
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Migration(SchemaMigration):
|
||||
|
||||
def forwards(self, orm):
|
||||
# Adding model 'Category'
|
||||
db.create_table(u'common_category', (
|
||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
|
||||
('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
|
||||
('parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['common.Category'], null=True, on_delete=models.SET_NULL, blank=True)),
|
||||
))
|
||||
db.send_create_signal(u'common', ['Category'])
|
||||
|
||||
# Adding model 'Sample'
|
||||
db.create_table(u'common_sample', (
|
||||
(u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
|
||||
('name', self.gf('django.db.models.fields.CharField')(max_length=100)),
|
||||
('active', self.gf('django.db.models.fields.BooleanField')(default=True)),
|
||||
('parent', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['common.Category'], null=True, on_delete=models.SET_NULL, blank=True)),
|
||||
))
|
||||
db.send_create_signal(u'common', ['Sample'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
# Deleting model 'Category'
|
||||
db.delete_table(u'common_category')
|
||||
|
||||
# Deleting model 'Sample'
|
||||
db.delete_table(u'common_sample')
|
||||
|
||||
|
||||
models = {
|
||||
u'common.category': {
|
||||
'Meta': {'object_name': 'Category'},
|
||||
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['common.Category']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'})
|
||||
},
|
||||
u'common.sample': {
|
||||
'Meta': {'object_name': 'Sample'},
|
||||
'active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||
u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'parent': ('django.db.models.fields.related.ForeignKey', [], {'to': u"orm['common.Category']", 'null': 'True', 'on_delete': 'models.SET_NULL', 'blank': 'True'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['common']
|
||||
0
project_directory/common/migrations/__init__.py
Normal file
0
project_directory/common/migrations/__init__.py
Normal file
22
project_directory/common/models.py
Normal file
22
project_directory/common/models.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class CommonInfo(models.Model):
|
||||
name = models.CharField(max_length=100)
|
||||
active = models.BooleanField(default=True)
|
||||
|
||||
def __unicode__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
|
||||
class Category(CommonInfo):
|
||||
parent = models.ForeignKey('self', blank=True, null=True,
|
||||
on_delete=models.SET_NULL)
|
||||
|
||||
|
||||
class Sample(CommonInfo):
|
||||
parent = models.ForeignKey(Category, blank=True, null=True,
|
||||
on_delete=models.SET_NULL)
|
||||
16
project_directory/common/tests.py
Normal file
16
project_directory/common/tests.py
Normal file
@@ -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
project_directory/common/views.py
Normal file
1
project_directory/common/views.py
Normal file
@@ -0,0 +1 @@
|
||||
# Create your views here.
|
||||
Reference in New Issue
Block a user