Good morning,
I am trying to put the 'MEDIA_ROOT' in 'urls.py' but when I run the 'runserver' I get the following 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
This is my '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)
Here is my '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"),
]
This is my directory tree:
I give you the complete error that the 'runserver' gives me.
Unhandled exception in thread started by 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_resolve (resolve) 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)
I hope your help, greetings and thanks in advance.