How to use native Django migrations?

29 views
Skip to first unread message

Etienne Robillard

unread,
Sep 12, 2016, 2:34:18 PM9/12/16
to Satchmo developers
Hi all,

I'm trying to build my own Satchmo site using Django 1.10. For this to work I need to get manage.py migrate working with the native Django migrations api.

However I get stuck attempting to run migrate, and thus I'm unable to create the required SQL
tables using sqlite3.

Traceback follows:
+ PATH=/bin:/usr/bin:/usr/local/bin
+ PYTHONIOENCODING=UTF-8
+ PYTHON=/usr/bin/python
+ which ipython
+ IPYTHON=
+ FIND=/usr/bin/find
+ HTTPSERVER=/usr/local/bin/httpserver.py
+ dirname -- bin/debug.sh
+ cd -P -- bin/..
+ pwd -P
+ ROOTDIR=/home/erob/src/django-hotsauce/examples
+ LIBDIR=/home/erob/src/django-hotsauce/examples/lib
+ BINDIR=/home/erob/src/django-hotsauce/examples/bin
+ VENDORDIR=/home/erob/src/django-hotsauce/examples/lib/site-packages
+ SYSCONFDIR=/home/erob/src/django-hotsauce/examples/conf
+ test -z
+ echo WARNING: DJANGO_HOME not found, using default
WARNING: DJANGO_HOME not found, using default
+ export DJANGO_HOME=/home/erob/src/django-hotsauce/examples/lib/site-packages
+ PYTHONPATH=/home/erob/src/django-hotsauce/examples:/home/erob/src/django-hotsauce/examples/lib:/home/erob/src/django-hotsauce/examples/lib/site-packages:/home/erob/src/django-hotsauce/examples/lib/site-packages:/home/erob/src/django-hotsauce/examples/conf
+ export PATH PYTHONIOENCODING PYTHONPATH ROOTDIR
+ export SCHEVO_OPTIMIZE=1
+ manage manage migrate
+ shift
+ /usr/bin/python /home/erob/src/django-hotsauce/examples/bin/manage.py migrate
No handlers could be found for logger "keyedcache"
ERROR:no such table: livesettings_setting
Traceback (most recent call last):
  File "/home/erob/src/django-hotsauce/examples/lib/site-packages/livesettings/values.py", line 257, in _value
    val = self.setting.value
  File "/home/erob/src/django-hotsauce/examples/lib/site-packages/livesettings/values.py", line 251, in _setting
    return find_setting(self.group.key, self.key)
  File "/home/erob/src/django-hotsauce/examples/lib/site-packages/livesettings/models.py", line 50, in find_setting
    setting = Setting.objects.get(site__id__exact=siteid, key__exact=key, group__exact=group)
  File "/home/erob/ncvs/django/django/db/models/manager.py", line 85, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/home/erob/ncvs/django/django/db/models/query.py", line 379, in get
    num = len(clone)
  File "/home/erob/ncvs/django/django/db/models/query.py", line 238, in __len__
    self._fetch_all()
  File "/home/erob/ncvs/django/django/db/models/query.py", line 1085, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/home/erob/ncvs/django/django/db/models/query.py", line 54, in __iter__
    results = compiler.execute_sql()
  File "/home/erob/ncvs/django/django/db/models/sql/compiler.py", line 835, in execute_sql
    cursor.execute(sql, params)
  File "/home/erob/ncvs/django/django/db/backends/utils.py", line 79, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/home/erob/ncvs/django/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/erob/ncvs/django/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/home/erob/ncvs/django/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/home/erob/ncvs/django/django/db/backends/sqlite3/base.py", line 337, in execute
    return Database.Cursor.execute(self, query, params)
OperationalError: no such table: livesettings_setting
WARNING:Problem finding settings PAYMENT.SSL, no such table: livesettings_setting

Found 'DJANGO_HOME' .. ok
Found 'DJANGO_SETTINGS_MODULE' .. ok
Traceback (most recent call last):
  File "/home/erob/src/django-hotsauce/examples/bin/manage.py", line 34, in <module>
    init_main(argv=sys.argv)
  File "/home/erob/src/django-hotsauce/examples/bin/manage.py", line 31, in init_main
    execute_from_command_line(argv)
  File "/home/erob/ncvs/django/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/erob/ncvs/django/django/core/management/__init__.py", line 359, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/erob/ncvs/django/django/core/management/base.py", line 305, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/erob/ncvs/django/django/core/management/base.py", line 353, in execute
    self.check()
  File "/home/erob/ncvs/django/django/core/management/base.py", line 385, in check
    include_deployment_checks=include_deployment_checks,
  File "/home/erob/ncvs/django/django/core/management/commands/migrate.py", line 62, in _run_checks
    issues.extend(super(Command, self)._run_checks(**kwargs))
  File "/home/erob/ncvs/django/django/core/management/base.py", line 372, in _run_checks
    return checks.run_checks(**kwargs)
  File "/home/erob/ncvs/django/django/core/checks/registry.py", line 81, in run_checks
    new_errors = check(app_configs=app_configs)
  File "/home/erob/ncvs/django/django/core/checks/urls.py", line 14, in check_url_config
    return check_resolver(resolver)
  File "/home/erob/ncvs/django/django/core/checks/urls.py", line 24, in check_resolver
    for pattern in resolver.url_patterns:
  File "/home/erob/ncvs/django/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/erob/ncvs/django/django/urls/resolvers.py", line 311, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "/home/erob/ncvs/django/django/utils/functional.py", line 35, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "/home/erob/ncvs/django/django/urls/resolvers.py", line 304, in urlconf_module
    return import_module(self.urlconf_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/erob/src/django-hotsauce/examples/lib/satchmo_store/urls/default.py", line 12, in <module>
    urlpatterns.include('satchmo_store.shop.urls', prefix='^shop/')
  File "/home/erob/src/django-hotsauce/lib/notmm/utils/urlmap.py", line 129, in include
    urlconf = import_module(urlobj)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/erob/src/django-hotsauce/examples/lib/satchmo_store/shop/urls.py", line 23, in <module>
    (r'^checkout/', include('payment.urls')),
  File "/home/erob/ncvs/django/django/conf/urls/__init__.py", line 50, in include
    urlconf_module = import_module(urlconf_module)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/erob/src/django-hotsauce/examples/lib/payment/urls.py", line 13, in <module>
    (r'^$', 'contact.contact_info_view', {'SSL': config.SSL.value}, 'satchmo_checkout-step1'),
  File "/home/erob/src/django-hotsauce/examples/lib/site-packages/livesettings/values.py", line 322, in value
    val = self._value()
  File "/home/erob/src/django-hotsauce/examples/lib/site-packages/livesettings/values.py", line 286, in _value
    raise SettingNotSet("Startup error, couldn't load %s.%s" %(self.group.key, self.key))
livesettings.models.SettingNotSet: ("Startup error, couldn't load PAYMENT.SSL", None)

Question: How can I create the SQL tables without Django accessing the livesettings models ?

Many thanks,

Etienne
Reply all
Reply to author
Forward
0 new messages