mirror of
https://github.com/jazzband/django-dbtemplates.git
synced 2026-05-16 19:41:09 +00:00
Made template name unique and sites required.
This commit is contained in:
parent
cc94071fc4
commit
863e3edaa3
2 changed files with 41 additions and 2 deletions
|
|
@ -0,0 +1,39 @@
|
|||
# encoding: 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 unique constraint on 'Template', fields ['name']
|
||||
db.create_unique('django_template', ['name'])
|
||||
|
||||
|
||||
def backwards(self, orm):
|
||||
|
||||
# Removing unique constraint on 'Template', fields ['name']
|
||||
db.delete_unique('django_template', ['name'])
|
||||
|
||||
|
||||
models = {
|
||||
'dbtemplates.template': {
|
||||
'Meta': {'ordering': "('name',)", 'object_name': 'Template', 'db_table': "'django_template'"},
|
||||
'content': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
|
||||
'creation_date': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'last_changed': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '100'}),
|
||||
'sites': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['sites.Site']", 'symmetrical': 'False'})
|
||||
},
|
||||
'sites.site': {
|
||||
'Meta': {'ordering': "('domain',)", 'object_name': 'Site', 'db_table': "'django_site'"},
|
||||
'domain': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||
}
|
||||
}
|
||||
|
||||
complete_apps = ['dbtemplates']
|
||||
|
|
@ -19,11 +19,11 @@ class Template(models.Model):
|
|||
Defines a template model for use with the database template loader.
|
||||
The field ``name`` is the equivalent to the filename of a static template.
|
||||
"""
|
||||
name = models.CharField(_('name'), max_length=100,
|
||||
name = models.CharField(_('name'), max_length=100, null=False, unique=True,
|
||||
help_text=_("Example: 'flatpages/default.html'"))
|
||||
content = models.TextField(_('content'), blank=True)
|
||||
sites = models.ManyToManyField(Site, verbose_name=_(u'sites'),
|
||||
blank=True, null=True)
|
||||
blank=False, null=False)
|
||||
creation_date = models.DateTimeField(_('creation date'),
|
||||
default=datetime.now)
|
||||
last_changed = models.DateTimeField(_('last changed'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue