python - The image isn't displayed on the page (ImageField) -


media_root , media_url aren't defined in settings.py

my models.py

from django.db import models  class profile(models.model):     avatar = models.imagefield(upload_to='avatars') 

views.py

from django.shortcuts import render, get_object_or_404 img.models import profile  def index(request):     p = get_object_or_404(profile, pk=1)     return render(request, '1.html', {'p': p}) 

i don't think important, urls.py

 django.conf.urls import patterns, url  img import views   urlpatterns = patterns('',      url(r'^$', views.index, name='index')  ) 

and template (img src="avatars/00.jpeg in html)

<img src="{{ p.avatar.url }}" />  

my project tree my project tree

what necessary correct?

you need configure static files

have here.

https://docs.djangoproject.com/en/dev/howto/static-files/


Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -