Re: django model(s) silently fails to sync to the DB ( for no apparent reason )
On Monday, October 7, 2013 8:40:33 PM UTC-5, Doug S wrote:
I don't think I'm making a rookie mistake, I've looked over my code several times.I've got two pretty simple django models that are just failing to sync to the dbduring the syncdb there are no errors, even with --verbosity 3When I try to make a relation to them I get an error saying the models either don't exist or a re abstractIn fact when I examine the DB, they are not there.syncdb is attempting to sync models before and after these 2 models in the same file.I've dropped my DB and started from scratch several timesI don't know how to debug this issue because I don't know how syncdb works under the covers and what can go wrong.Here are my models, they look pretty simple to me: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 nowand 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 DBthat 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
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/f187fd4d-9d8f-4047-ba97-05ef5a8f30c9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home