Hi everyone,

i've a problem viewing uploaded files via the admin interface. When I
try to view the file, everything I get is a ValueError exception:
invalid literal for int() with base 10...
I know it goes wrong, when your MEDIA_URL is not set correctly.

The link to the file in the admin interface is:
http://localhost:8000/admin/myModel/attachment/1/files/my-file.pdf/

should be:
http://localhost:8000/media/files/my-file.pdf/ <- this one works

Here's are my related code:

settings.py
[...]
MEDIA_ROOT = os.path.join(PROJECT_DIR,'media')
MEDIA_URL = 'localhost:8000/media/'
ADMIN_MEDIA_PREFIX = '/media/admin/'
[...]

urls.py
[...]
from django.conf import settings
if settings.DEBUG:
    urlpatterns += patterns('',
            (r'^media/(?P<path>.*)$', 'django.views.static.serve',
                { 'document_root': settings.MEDIA_ROOT }),
    )

models.py
[...]
class Attachment(models.Model):
    attached_file = models.FileField(upload_to="files")
    filename = models.CharField(max_length=100)
    created_at = models.DateTimeField(auto_now_add=True,
editable=False)
    updated_at = models.DateTimeField(auto_now=True, editable=False)

    def __unicode__(self):
        return self.filename
[...]

Any suggestions?

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.


Reply via email to