Re: django model(s) silently fails to sync to the DB ( for no apparent reason )

2013-10-21 Thread Doug S

Looks like I found the problem. 
I am using the pattern:

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
This pattern is a nice way of putting models into different files when you 
have a lot of models,
but it also requires you to specify that the models in the different files 
all belong to the one app
by setting a Meta variable:

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

On Monday, October 7, 2013 9:40:33 PM UTC-4, 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 db
> during the syncdb there are no errors, even with --verbosity 3
> When I try to make a relation to them I get an error saying the models 
> either don't exist or a re abstract
> In 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 times
> I 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 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
>

-- 
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+unsubscr...@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 d

Re: django model(s) silently fails to sync to the DB ( for no apparent reason )

2013-10-09 Thread David Cox
I just rtfc, and it might have been a copy-paste mistake, but the 
'str_value' field in your 'DirEnumVal' class has unmatched quotation marks 
for the default attribute.

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 db
> during the syncdb there are no errors, even with --verbosity 3
> When I try to make a relation to them I get an error saying the models 
> either don't exist or a re abstract
> In 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 times
> I 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 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
>

-- 
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+unsubscr...@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.


Re: django model(s) silently fails to sync to the DB ( for no apparent reason )

2013-10-09 Thread David Cox
There's a chance that running 'manage.py sqlall' might show errors that 
syncdb can't display before failing.  'manage.py sqlall' validates the SQL 
without trying to commit it, so to save time in the future, you should 
really run it before syncdb every time.

If not, and the app is installed, check import statements, then model field 
constraints, like trying to assign numbers to 'null' fields or violating 
'unique' constraints.

Since the db sync is failing on transaction commit, it sounds more like the 
latter than the former, though.  Good luck.

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 db
> during the syncdb there are no errors, even with --verbosity 3
> When I try to make a relation to them I get an error saying the models 
> either don't exist or a re abstract
> In 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 times
> I 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 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
>

-- 
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+unsubscr...@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/406e8976-2dad-4e9b-80ed-87f3a1ec869c%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django model(s) silently fails to sync to the DB ( for no apparent reason )

2013-10-08 Thread Rene Zelaya
Hey Doug,

Any chance you haven't included those models in the INSTALLED_APPS in your 
settings.py file?

Best,
Rene

On Monday, October 7, 2013 9:40:33 PM UTC-4, 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 db
> during the syncdb there are no errors, even with --verbosity 3
> When I try to make a relation to them I get an error saying the models 
> either don't exist or a re abstract
> In 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 times
> I 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 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
>

-- 
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+unsubscr...@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/29eb0976-3a4b-4210-a78d-aab8c296180a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


django model(s) silently fails to sync to the DB ( for no apparent reason )

2013-10-07 Thread Doug S
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 db
during the syncdb there are no errors, even with --verbosity 3
When I try to make a relation to them I get an error saying the models 
either don't exist or a re abstract
In 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 times
I 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 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

-- 
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+unsubscr...@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/feb8a865-7223-4876-8764-966ac837e609%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.