2

Output looks like this (the project is named parkingtickets):

usr/local/webapps/parkingtickets/django_project$ python manage.py syncdb
Creating tables ...
Creating table parkingtickets_correction

It then hangs forever. If I suspend the process and kill it, it does not die; I have to use kill -9. I've never encountered this before - as of this morning my app was running smoothly. I last ran syncdb successfully 3 days ago. At that time I had correction defined, and it worked fine. I modified the model to include a new field - a noneditable foreign key which was allowed to be null - dropped the table, and hit syncdb. Now this. I am happy to post any information people deem necessary. Relevant settings.py (CRUD is an internal framework we developed that mostly loads generic templates for us):

DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = ()
INTERNAL_IPS=('ADDRESS_OMITTED','ADDRESS_OMITTED')
MANAGERS = ADMINS
DATABASE_ENGINE = 'sql_server.pyodbc'
DATABASE_NAME = 'NAME_OMITTED'
DATABASE_USER = 'USER_OMITTED'             
DATABASE_PASSWORD = 'PASS_OMITTED'         
DATABASE_HOST = 'HOST_OMITTED'           
DATABASE_PORT = '1433'
APPNAME = 'parkingtickets'
DATABASE_OPTIONS = {
  'driver': 'FreeTDS',
  'dsn': 'websiteredesign',
  'timeout': 1,
  'connect_timeout': 1,
  'SQL_ATTR_LOGIN_TIMEOUT': 1}

TIME_ZONE = 'America/New_York'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
MEDIA_ROOT = '/var/www/site-media/'
MEDIA_URL = '/site-media/' + APPNAME
ADMIN_MEDIA_PREFIX = '/media/'
SECRET_KEY = SECRET_KEY_OMITTED
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
)
MIDDLEWARE_CLASSES = (
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.csrf.CsrfResponseMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.middleware.transaction.TransactionMiddleware',
    'debug_toolbar.middleware.DebugToolbarMiddleware',
)
ROOT_URLCONF = 'django_project.urls'
TEMPLATE_DIRS = (
    '/usr/local/webapps/' + APPNAME + '/django_templates/',
    '/usr/local/webapps/crud/',
)
TEMPLATE_CONTEXT_PROCESSORS = ('crud.context_processors.settings',
                               'django.core.context_processors.auth',
                               'django.core.context_processors.media',
                               'django.core.context_processors.request')
INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    APPNAME,
    'crud',
    'crud.crud_tags',
    'django.contrib.admin',
    'debug_toolbar',
)
LOGIN_URL = '/' + APPNAME + '/accounts/login/'  
LOGIN_REDIRECT_URL = '/' + APPNAME + '/'

EDIT: Ok, so that new foreign key I added causes the issue. A foreign key to any other table works fine, and modifications to the foreign key don't change anything (e.g. moving it up and down so it's parsed at a different time, making it editable, making it not accept nulls). Here is the definition of the table I want to foreign key into, Ticket:

class Ticket(CrudModel):
    _amount_due = models.DecimalField(decimal_places=2,max_digits=32,default=Decimal('0.00'),editable=False)
    _amount_paid = models.DecimalField(decimal_places=2,max_digits=32,default=Decimal('0.00'),editable=False)
    number = models.CharField(max_length=128,unique=True)
    ticket_date = models.DateField()
    time = models.TimeField()
    plate_number = models.CharField(max_length=128)
    plate_state = USStateField(default='CT')
    make = models.ForeignKey(Make)
    model = models.CharField(max_length=128)
    color = models.ForeignKey(Color)
    location = models.CharField(max_length=128)
    officer = models.ForeignKey(Officer)
    _class = models.ForeignKey(Class,null=True,blank=True,verbose_name='Class')
    vin = models.CharField(max_length=128,blank=True)
    towed_to = models.CharField(max_length=128,blank=True)
    remarks = models.TextField(blank=True)
    owner = models.ForeignKey(Owner,null=True,blank=True)
    delinquency_letter = models.DateField(null=True,blank=True)
quindraco
  • 1,441
  • 2
  • 11
  • 13
  • Is your database up and running properly? Have you tested it independently? – jdi Aug 13 '12 at 17:04
  • Yes. The project works completely. I actually came back to post an update: if I remove the foreign key field I just added and rerun syncdb, the table is made appropriately. The hang-forever behaviour appears to be based on whether or not I specify the foreign key. Problematic line is here: ticket = models.ForeignKey(Ticket,editable=False,blank=True,null=True) – quindraco Aug 13 '12 at 17:06
  • I guess maybe your database is hitting some kind of constraint conflict. Wonder what would happen if you tried to add this field manually in a direct sql statement? – jdi Aug 13 '12 at 17:08
  • Followup: Moving the line up and down in the class definition relative to other fields changes nothing, nor does making the key editable. – quindraco Aug 13 '12 at 17:08
  • 2
    Postgres tends to hang like this if there are somebody with an open shell or dbshell running. Try to close these bofore making schema changes. – Paulo Scardine Aug 13 '12 at 17:09
  • As noted, I can make schema changes in general; what I can't do is make the specific schema change of adding a foreign key to ticket. I will attempt to add a foreign key to another model, then edit this comment with the new information. – quindraco Aug 13 '12 at 17:17
  • Confirmed; works with foreign keys to other models. I only get a hang when creating a foreign key to Tickets specifically. What about my Ticket model could be causing this? – quindraco Aug 13 '12 at 17:23
  • Show us your `Ticket` model and we might be able to tell you ;) – supervacuo Aug 13 '12 at 17:35
  • Edited original post to show the Ticket model. – quindraco Aug 13 '12 at 18:34

0 Answers0