浏览代码

Fix: Add a mark 'IS_TEST' to decide if we should load image-urls

pull/128/head
winkidney 6 年前
父节点
当前提交
ac469d47f9
共有 4 个文件被更改,包括 14 次插入1 次删除
  1. +1
    -1
      django_images/urls.py
  2. +3
    -0
      manage.py
  3. +3
    -0
      pinry/settings/base.py
  4. +7
    -0
      pinry/urls.py

+ 1
- 1
django_images/urls.py 查看文件

@@ -1,4 +1,4 @@
from django.conf.urls import include, url
from django.conf.urls import url
from . import views

urlpatterns = [


+ 3
- 0
manage.py 查看文件

@@ -6,5 +6,8 @@ if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pinry.settings.development")

from django.core.management import execute_from_command_line
if 'test' in sys.argv:
from django.conf import settings
settings.IS_TEST = True

execute_from_command_line(sys.argv)

+ 3
- 0
pinry/settings/base.py 查看文件

@@ -134,5 +134,8 @@ IMAGE_SIZES = {
'square': {'crop': True, 'size': [125, 125]},
}

# IS_TEST is a variable to mark if the test is running
IS_TEST = False

# User custom settings
IMAGE_AUTO_DELETE = True

+ 7
- 0
pinry/urls.py 查看文件

@@ -19,3 +19,10 @@ if settings.DEBUG:
urlpatterns += [
url(r'^media/(?P<path>.*)$', serve, {'document_root': settings.MEDIA_ROOT, }),
]

if settings.IS_TEST:
urlpatterns += staticfiles_urlpatterns()
# For test running of django_images
urlpatterns += [
url(r'^__images/', include('django_images.urls')),
]

正在加载...
取消
保存