class DirEnumVal(models.Model):
str_val = models.CharField(max_length=64, default='')
def unicode(self):
return self.str_val
class DirAttr(models.Model):
BOOL = 'BOOL'
MONO = 'MONO'
SCAL = 'SCAL'
ENUM = 'ENUM'
TYPES = (
(BOOL,'Boolean'),
(MONO,'Monomial'),
(SCAL,'Scalar'),
(ENUM,'Enumeration'),
)
val_type = models.CharField(max_length=4, choices=TYPES)
val_key = models.CharField(max_length=32)
default_bool = models.BooleanField(default=True)
default_num = models.IntegerField(default = 0)
default_float = models.FloatField(default=1.0)
enum_choices = models.ManyToManyField(DirEnumVal, null=True, blank=True)
default_choice = models.CharField(max_length=64, default='')
required = models.BooleanField(default=True)
def unicode(self):
return '{k} :=> {t} ( default = {d} )'.format(
k=self.val_key, t=self.val_type, d=self.default())
I am using a pattern with multiple model files for a single app
my dir structure is:
>app
> models
- __init__.py
- model_file1.py
- model_file2.py
and in my __init__.py I've got code to pull all the models together into one module: app.models
from __future__ import absolute_import
from .model_file1 import model1a,model1b,model1c
from .model_file2 import model2a,model2b,model2c
This way of importing the models has been working long before this trouble of models not being synched came up.
When I access the django project and settings through a python shell I can import the models and instatiate them
but when I save them, PostGres gives me this error:
DatabaseError: current transaction is aborted, commands ignored until end of transaction block
This problem surfaced after I installed django-categories and set up some category models.
I had some trouble at first setting that up but I've got the BaseCategory subclasses behaving nicely now
and have started with a fresh DB.
At some point when I was getting django categories to work there was an error when I synched the DB
that said something about an unexcepted special character being somewhere in my code or the django-categories code.
That seemed suspicious but that doesn't show up anymore and I'm using a fresh DB.
Does anybody see anything obvious or know what type of problems can cause syncdb to ignore models?
I'm running out of ideas about what is wrong
I'm on Django 1.5 using PostGreSQL & MacOS Lion
Best Doug
I am using a pattern with multiple model files for a single app
my dir structure is:
>my_app
> models
- __init__.py
- model_file1.py
- model_file2.py
and in my __init__.py I've got code to pull all the models together into one module: app.models
from __future__ import absolute_import
from .model_file1 import model1a,model1b,model1c
from .model_file2 import model2a,model2b,model2c
class Meta:
app_label = 'my_app'
I had done this on my previous models when I split the models into separate files
but then added some new models and forgot about that requirement.
Django said the models weren't installed since it didn't know to add them to the right app.
QED