0

I have been trying for the last many hours to trace the source of an error

AttributeError: 'Options' object has no attribute 'model_name'

I am getting it while trying to run syncdb or migrations.

My installed apps consist of :

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.comments',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.formtools',
'django.contrib.sitemaps',
'django.contrib.humanize',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
# Uncomment the next line to enable the admin:
'django.contrib.admin',

'customer',
'monitor',
'accounts',
'payments',

'cms',
'mptt',
'menus',
'south',
'sekizai',
'reversion',

'cms.plugins.text',
'cms.plugins.picture',
'cms.plugins.link',
'cms.plugins.file',
'cms.plugins.snippet',
'cms.plugins.googlemap',
'cms.plugins.video',

'zinnia',
'tagging',
'cmsplugin_zinnia',

'registration',
'django_filters',
'rest_framework',
'django_countries',
'smartagent',
'captcha',
'django.contrib.markup',
'knowledge',

'djcelery',
'djcelery_email',

'paypal.standard.ipn',
'paypal.standard.pdt',

'raven.contrib.django.raven_compat',
'django_statsd',

)

and requirements file has:

#Requirements for the application
Django>=1.5
Fabric>=1.4.1
South>=0.7.4
psycopg2>=2.4.5
gunicorn>=0.14.1
#newrelic==1.2.0.246
django-celery>=3.0.21
requests
numpy>=1.7.1
raven>=4.0.3
django-statsd-mozilla>=0.3.9


django-mptt>=0.6.0
django-cache-machine==0.6
cssmin==0.1.4
django-cms>=2.4.3
django-blog-zinnia>=0.12.3
cmsplugin_zinnia>=0.4.0

django-reversion<1.8
pil
django-registration>=1.0
djangorestframework
markdown
django-filter
django-countries
django-download-stats>=0.2
django-smartagent>=0.1.1
django-recaptcha>=0.0.6
django-celery-email>=1.0.4
django-knowledge
xlwt>=0.7.5
#django-paypal>=0.1.2

Is there a way of forcing syncdb to show the full stack trace of the error. I tried adding --verbosity 2 but that did not help.

I appreciate your feedback.

Bwire
  • 1,181
  • 1
  • 14
  • 25
  • If you run the syncdb command in a debugger you could probably stop at the exception with a stack trace. I use an IDE (PyCharm) which does this well, though I suspect any cmdline or IDE debugger could do this. – Nils Jan 29 '14 at 16:50

2 Answers2

1

This ticket might be relevant, specifically:

The reason you're getting this AttributeError upon _meta.model_name access is that property was only introduced in Django 1.6. I'm afraid you'll have to access _meta.module_name and lower case it on Django < 1.6 to get the same result.

I notice you're specifying Django 1.5 in your requirements.txt. Possibly one of your third party apps is designed to work with Django 1.6+?

ptr
  • 3,292
  • 2
  • 24
  • 48
  • Isn't there a way I can get the full error stack to allow me get to deal with particular application. Funny enough locally the same setup works without issues. – Bwire Jan 29 '14 at 16:43
  • That could be for a number of reasons, differing environments etc. But no I don't know of any way to paste a full stack trace (not to say there isn't one) – ptr Jan 29 '14 at 16:44
  • 1
    a quick search of github for `_meta.model_name` shows it is in use in the django `zinnia` package, try there first maybe. – ptr Jan 29 '14 at 16:48
  • 1
    https://pypi.python.org/pypi/django-blog-zinnia/ - Latest changelog shows django 1.5 is no longer supported. You'll need to either upgrade to django 1.6 (might cause trouble with other apps) or use a version of zinnia that does support django 1.5 (your requirements.txt currently just grabs the latest version) – ptr Jan 29 '14 at 16:51
  • 1
    As an aside, this is why it's a best practice to pin your requirements to a specific version of a package. – ptr Jan 29 '14 at 16:53
  • Thanks so much @Pete I practically wasted an afternoon trying to pin this down. Zinnia was my problem. – Bwire Jan 29 '14 at 17:01
0

I think adding --traceback to the syncdb or migrate command should do what you asked for.

Max K
  • 11
  • 1
  • 4
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). – Cyclonecode Mar 27 '14 at 20:03
  • Isn't this exactly what was asked for? The question was how to force syncdb to show the full stack trace of error. Adding --traceback to syncdb does this on my system. – Max K Mar 28 '14 at 13:10