Estoy intentando meter el MEDIA_ROOT
en el archivo urls.py
pero cuando ejecuto el comando python manage.py runserver
me aparece el siguiente error:
File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\conf\urls\static.py", line 24, in static
raise ImproperlyConfigured("Empty static prefix not permitted") django.core.exceptions.ImproperlyConfigured: Empty static prefix not permitted
Este es mi archivo urls.py
:
from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from boletin.views import inicio
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^$', inicio, name='inicio')
]
if settings.DEBUG:
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Aquí está mi archivo settings.py
:
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_env", "static_root")
STATIC_URL = '/media/'
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_env", "media_root")
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static_pro", "static"),
]
Así es mi árbol de directorios:
Os pongo el error completo que me da el comando python manage.py runserver
:
Unhandled exception in thread started by <function wrapper at 0x000000000469C3C8> Traceback (most recent call last): File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
self.check(display_num_errors=True) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\core\management\base.py", line 385, in check
include_deployment_checks=include_deployment_checks, File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\core\management\base.py", line 372, in _run_checks
return checks.run_checks(**kwargs) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\core\checks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns: File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\utils\functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\urls\resolvers.py", line 310, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\utils\functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance) File "C:\Users\Manux\Desktop\pd110\lib\site-packages\django\urls\resolvers.py", line 303, in urlconf_module
return import_module(self.urlconf_name) File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module
__import__(name)
Espero vuestra ayuda, un saludo y gracias de antemano.
MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "static_env", "media_root")