Ok I have it urls
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT,}), settings PROJECT_ROOT = os.path.join(os.path.dirname(__file__), '..') SITE_ROOT = PROJECT_ROOT MEDIA_ROOT = os.path.join(SITE_ROOT, 'media') MEDIA_URL = '/media/' W dniu piątek, 13 maja 2016 21:46:03 UTC+2 użytkownik Dariusz Mysior napisał: > > I can't find where is a problem, I try show in template image and he don't > show it. Please help... > > my code > > models > > from django.db import models > from django.contrib.auth.models import AbstractUser > > ################################################## > > class MysiteUser(AbstractUser): > avatar = models.ImageField(upload_to="avatar") > > def __str__(self): > return self.username > > > > template > > <!DOCTYPE html> > <html lang="pl"> > <head> > <meta charset="UTF-8"> > <title></title> > </head> > <body> > {% load staticfiles %} > > {% block content %} > {% if user.is_authenticated %} > Mój profil {{ user.username }} </br> > <img src="{{ user.avatar.url }}" width="200" height="200" > border="1" /> > <a href="{% url 'users:logout-view' %}">Wyloguj się</a> > {% else %} > {% block logout %} > Nie jesteś zalogowany > > {% endblock %} > {% endif %} > {% endblock %} > </body> > </html> > > > > url > > from django.conf.urls import include, url > from django.contrib import admin > from users.views import LoginView > from django.conf import settings > from django.conf.urls.static import static > urlpatterns = [ > url(r'^admin/', include(admin.site.urls)), > url(r'^users/', include('users.urls', namespace='users')), > url(r'^$', LoginView.as_view(), name='login-view'), > > > ] > > static(settings.MEDIA_URL, document_root = settings.MEDIA_ROOT) > > > > settings > > MEDIA_ROOT = '/mysite/media/' > MEDIA_URL = '/media/' > > STATIC_URL = '/static/' > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/c45ad03e-3518-4c93-8a05-ca4ab8a544a7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.