sparkholiday
sparkholiday

Reputation: 82

Manage.py migration hasn't ever worked in Aldryn project -- can't be good, right?

I've been occasionally attempting to run python manage.py migrate while working on an Aldryn site for the past few weeks, and it's never worked. It hasn't bothered me much, but I think that it probably should (I'm quite new to Django CMS and its ways, and I'm afraid this will bite me later if I don't get it working now). Here's the output I get when running the command:

    Joey-Keetons-Mac-Pro-2:fringeclass sparkholiday$ python manage.py migrate
    /Users/sparkholiday/Documents/aldryn workspace folder/fringeclass/addons/aldryn-
    django/aldryn_config.py:48: RuntimeWarning: no database configured. Falling back
    to DATABASE_URL=sqlite:////Users/sparkholiday/Documents/aldryn workspace folder
    /fringeclass/data/db.sqlite3
      RuntimeWarning,
    /Users/sparkholiday/Documents/aldryn workspace folder/fringeclass/addons/aldryn-
    django/aldryn_config.py:56: RuntimeWarning: no cache configured. Falling back to
    CACHE_URL=locmem://
      RuntimeWarning,
    Traceback (most recent call last):
      File "manage.py", line 7, in <module>
        startup.manage(path=os.path.dirname(os.path.abspath(__file__)))
      File "/Library/Python/2.7/site-packages/aldryn_django/startup.py", line 12, in
    manage
      utility.execute()
     File "/Library/Python/2.7/site-packages/django/core/management/__init__.py", l
 ine 302, in execute
      settings.INSTALLED_APPS
    File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 55, in
__getattr__
    self._setup(name)
  File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 43, in
_setup
    self._wrapped = Settings(settings_module)
   File "/Library/Python/2.7/site-packages/django/conf/__init__.py", line 99, in
__init__
   mod = importlib.import_module(self.SETTINGS_MODULE)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/i
mportlib/__init__.py", line 37, in import_module
   __import__(name)
  File "/Users/sparkholiday/Documents/aldryn workspace folder/fringeclass/settin
gs.py", line 28, in <module>
    aldryn_addons.settings.load(locals())
  File "/Library/Python/2.7/site-packages/aldryn_addons/settings.py", line 142,
in load
    settings_json_path=settings_json_path,
  File "/Library/Python/2.7/site-packages/aldryn_addons/settings.py", line 174,
in load_addon_settings
     aldryn_config.Form().to_settings(addon_settings, settings)
   File "/Users/sparkholiday/Documents/aldryn workspace folder/fringeclass/addons
/aldryn-django/aldryn_config.py", line 123, in to_settings
     self.server_settings(settings, env=env)
   File "/Users/sparkholiday/Documents/aldryn workspace folder/fringeclass/addons
/aldryn-django/aldryn_config.py", line 211, in server_settings
     os.path.dirname(settings['NGINX_CONF_PATH']),
   File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/posixpat
h.py", line 122, in dirname
      i = p.rfind('/') + 1
AttributeError: 'NoneType' object has no attribute 'rfind'

I know that a NoneType situation in Python means that something is being called that doesn't exist, or isn't properly defined, and it seems to be pointing to the NGINX config here, but I've no clue how to fix it. Somebody on a thread elsewhere (can't remember where) suggested that somebody fix basically the same issue by getting rid of the code segment involving NGINX altogether, but... I need that thing! Here's the code around the part in the aldryn_config.py file for aldryn-django (I don't think anybody wants me to post the whole file, but I'll edit it if it'll help):

def server_settings(self, settings, env):
    settings['PORT'] = env('PORT', 80)
    settings['BACKEND_PORT'] = env('BACKEND_PORT', 8000)
    settings['ENABLE_NGINX'] = env('ENABLE_NGINX', False)
    settings['ENABLE_PAGESPEED'] = env(
        'ENABLE_PAGESPEED',
        env('PAGESPEED', False),
    )
    settings['ENABLE_BROWSERCACHE'] = env(
        'ENABLE_BROWSERCACHE',
        env('BROWSERCACHE', False),
    )
    settings['BROWSERCACHE_MAX_AGE'] = env('BROWSERCACHE_MAX_AGE', 300)
    settings['NGINX_CONF_PATH'] = env('NGINX_CONF_PATH')
    settings['NGINX_PROCFILE_PATH'] = env('NGINX_PROCFILE_PATH')
    settings['PAGESPEED_ADMIN_HTPASSWD_PATH'] = env(
        'PAGESPEED_ADMIN_HTPASSWD_PATH',
        os.path.join(
            os.path.dirname(settings['NGINX_CONF_PATH']),
            'pagespeed_admin.htpasswd',
        )
    )
    settings['PAGESPEED_ADMIN_USER'] = env('PAGESPEED_ADMIN_USER')
    settings['PAGESPEED_ADMIN_PASSWORD'] = env('PAGESPEED_ADMIN_PASSWORD')
    settings['DJANGO_WEB_WORKERS'] = env('DJANGO_WEB_WORKERS', 3)
    settings['DJANGO_WEB_MAX_REQUESTS'] = env('DJANGO_WEB_MAX_REQUESTS', 500)
    settings['DJANGO_WEB_TIMEOUT'] = env('DJANGO_WEB_TIMEOUT', 120)

And my settings.py (because let's make this longer, eh?):

# -*- coding: utf-8 -*-

INSTALLED_ADDONS = [
    # <INSTALLED_ADDONS>  # Warning: text inside the INSTALLED_ADDONS tags is auto-generated. Manual changes will be overwritten.
    'aldryn-addons',
    'aldryn-django',
    'aldryn-sso',
    'aldryn-django-cms',
    'aldryn-devsync',
    'aldryn-background-image',
    'aldryn-bootstrap3',
    'aldryn-categories',
    'aldryn-common',
    'aldryn-disqus',
    'aldryn-emailsettings',
    'aldryn-faq',
    'aldryn-forms',
    'aldryn-gallery',
    'aldryn-mailchimp',
    'aldryn-newsblog',
    'aldryn-people',
    'aldryn-style',
    'djangocms-fbcomments',
    'reversion',
    'aldryn_reversion',
    'sortedm2m',
    'taggit',
    'filer',
    'easy_thumbnails',
    'djangocms_text_ckeditor',
    'aldryn_translation_tools',
    'aldryn_boilerplates',

     # </INSTALLED_ADDONS>
 ]

import aldryn_addons.settings
aldryn_addons.settings.load(locals())


# all django settings can be altered here

INSTALLED_APPS.extend([
    # add you project specific apps here
])

ALDRYN_BOILERPLATE_NAME='bootstrap3'

TEMPLATE_CONTEXT_PROCESSORS.extend([

'aldryn_boilerplates.context_processors.boilerplate',
    # add your template context processors here
])

THUMBNAIL_PROCESSORS = (
    'easy_thumbnails.processors.colorspace',
    'easy_thumbnails.processors.autocrop',
    # 'easy_thumbnails.processors.scale_and_crop',
    'filer.thumbnail_processors.scale_and_crop_with_subject_location',
    'easy_thumbnails.processors.filters',
    'easy_thumbnails.processors.background',
 )

STATICFILES_FINDERS = [
'django.contrib.staticfiles.finders.FileSystemFinder',
# important! place right before     django.contrib.staticfiles.finders.AppDirectoriesFinder
'aldryn_boilerplates.staticfile_finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
]

MIDDLEWARE_CLASSES.extend([
    # add your own middlewares here
])

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'aldryn_boilerplates.template_loaders.AppDirectoriesLoader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader'
 )

Much thanks for reading through this -- any advice would be amazing! I love frontend editing, but it's not very useful if you can't get your CSS to it! I think I can use git (git and docker have both worked without the migration command working, which is why I've put it off for so long), but I have a suspicion that my lack of migrating is causing problems with my virtual environment, and that could eventually be a nightmare :/

Upvotes: 0

Views: 497

Answers (1)

stefanfoulis
stefanfoulis

Reputation: 659

Looks like you are running python manage.py migrate from your local machine instead of from inside the docker container.

Within the container paths are different (e.g the sourcecode is at /app), all the needed requirements are installed and the postgres database is linked and available.

Try this instead:

docker-compose run --rm web python manage.py migrate

What this does is:

  • docker-compose: this command does docker operations based on the configuration in a docker-compose.yml file in the same directory
  • run: create and run a new container
  • --rm: delete the container after the command finishes (since this is a one-off command there is no sense in keeping it around)
  • web: pick the "web" service out of docker-compose.yml
  • python manage.py migrate: the command to run in the context of the container

It is also possible to run bash as the command. This will give you a interactive prompt within the container.

Upvotes: 2

Related Questions