Manage.py迁移在Aldryn项目中一直没有用过 - 好不好吧?

时间:2016-04-16 18:16:52

标签: nginx database-migration django-cms divio

过去几周我在Aldryn网站上工作时偶尔试图运行python manage.py migrate,但它从未奏效过。它并没有让我感到困扰,但我认为它可能应该(我对Django CMS以及它的方式很新,而且我担心如果我不这样做,这会让我感到很生气。让它现在工作)。这是运行命令时得到的输出:

    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'

我知道Python中的NoneType情况意味着调用的东西不存在,或者没有被正确定义,它似乎指向NGINX配置,但我&#39 ;不知道如何解决它。有人在其他地方的线程上(无法记住在哪里)建议有人通过完全摆脱涉及NGINX的代码段来解决基本相同的问题,但是......我需要那个东西!这是aldryn_config.py aldryn-django文件中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) 部分的代码(我不认为有人要我发布整个文件,但我会编辑它,如果有的话它会帮助):

settings.py

我的# -*- 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' ) (因为让我们更久,呃?):

GridView

非常感谢您阅读本文 - 任何建议都会令人惊叹!我喜欢前端编辑,但如果您无法获得CSS,那么它并不是非常有用!我想我可以使用git(git和docker都可以在没有迁移命令的情况下工作,这就是为什么我已经把它推迟了很长时间),但是我怀疑我缺少迁移会导致我的问题虚拟环境,最终可能是一场噩梦:/

1 个答案:

答案 0 :(得分:2)

看起来您正在从本地计算机而不是从docker容器内运行class my_account_invoice_line(osv.osv): _inherit = "account.invoice.line" def _default_analytics_id(self, cr, uid, context=None): if context is None: context = {} custom_id = context.get('custom_field_id', False) if custom_id: # ...your code to do something with custom_id goes here... return True # or whatever suits your needs to be used as default return False _defaults = { 'analytics_id': _default_analytics_id, } my_account_invoice_line()

在容器内部路径不同(例如源代码位于python manage.py migrate),安装了所有需要的要求,并且postgres数据库已链接且可用。

请改为尝试:

/app

这是做什么的:

  • docker-compose run --rm web python manage.py migrate :此命令根据同一目录中docker-compose文件中的配置执行docker操作
  • docker-compose.yml:创建并运行新容器
  • run:在命令完成后删除容器(因为这是一次性命令,没有意义保持它)
  • --rm:选择&#34; web&#34;服务超出web
  • docker-compose.yml:在容器上下文中运行的命令

也可以运行python manage.py migrate作为命令。这将为您提供容器内的交互式提示。