*Context: Ubuntu linux server 12, Apache 2.2 server, django 1.5.3* * * My project, /home/victor/magazantea is dealt with by admin and it works fine in the development environment (/manage.py runserver 192.168.1.19:8000). I built a view which gets data from the following fields from model "Articoli"
*models.py* class Articoli(models.Model): ......... codice = models.CharField(primary_key=True,db_index=True,max_length=15,db_column='Codice') descrizione = models.CharField(max_length=255, db_column='Descrizione', db_index=True) categoria = models.IntegerField(choices=categoria, db_column='Categoria',default=2) .................... @property def codice_a_barre(self): self.codice = self.codice.strip() cod= self.codice.replace(" ", "_").replace("/","_") return (str(cod)+ '.png') and produces a template *"listarticoli.html" *where* *codice, descrizione,categoria are listed together with the image of the png file referred to by the string codice_a_barre, got from the media dir "/home/victor/magazantea/magazantea/media". It works like a charm in development but when I put it *in production the png files aren't shown* (instead a small blue square whit a question mark inside is shown in each line). These are the relevant files in production: *settings.py * import os ABSOLUTE_PATH='%s/' % os.path.abspath(os.path.dirname(locals.__name__)).replace('\\','/') DEBUG = False ALLOWED_HOSTS=['*'] ................... MEDIA_ROOT='/home/victor/magazantea/magazantea/media/' MEDIA_URL = '/media/' STATIC_ROOT = '' STATIC_URL = '/static/' ............................. ROOT_URLCONF = 'magazantea.urls' ....................... ...................... *urls.py* from django.conf.urls import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', url(r'^admin/doc/', include('django.contrib.admindocs.urls')), url(r'^magazzino/', include(admin.site.urls)), url(r'^listarticoli/', 'magazzino.views.listbarcode', name='listbarcode'), url(r'^listarticoli/(?P<path>.*)$', 'django.views.static.serve',{'document_root': '/home/victor/magazantea/magazantea/media/'}), ) And finally the *Apache config* Listen 8000 WSGIScriptAlias / /home/victor/magazantea/django.wsgi WSGIPythonPath /home/victor/magazantea <VirtualHost *:8000> AliasMatch ^/([^/]*\.css) /home/victor/magazantea/magazantea/static/ AliasMatch ^/([^/]*\.png) /home/victor/magazantea/magazantea/media/ Alias /media/ /home/victor/magazantea/magazantea/media/ Alias /static/ /home/victor/magazantea/magazantea/static/ Alias /templates/ /home/victor/magazantea/magazantea/templates/ <Directory /home/victor/magazantea/magazantea/static> Order deny,allow Allow from all </Directory> <Directory /home/victor/magazantea/magazantea/media> Order deny,allow Allow from all </Directory> <Directory /home/victor/magazantea/magazantea/templates> Order deny,allow Allow from all </Directory> ServerAdmin webmaster@localhost <Directory /home/victor/magazantea/magazantea/> <Files django.wsgi> Order deny,allow Allow from all </Files> </Directory> </VirtualHost> -- 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 http://groups.google.com/group/django-users. For more options, visit https://groups.google.com/groups/opt_out.