0

I was looking to try django-directupload in one of my Django projects, but I'm new to Django and having some trouble with installation. I'm following the installation instructions in the README. I installed django-directupload using sudo pip install django-directupload.

Here is my urls.py, which I don't think is right:

from django.conf.urls.defaults import patterns, include, url
from testproject import settings

import directupload
from django.contrib import admin
directupload.admin.patch_admin()
admin.autodiscover()

urlpatterns = patterns('testproject.database.views',
    url(r'^(\d+)/$', 'test_view', name="test_page"),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^directupload/', include(directupload.urls))
)

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

Edit:
So I've gained some insight into overriding admin templates (Thanks ilvar for the link). I copied and pasted the contrib/admin/templates/admin/change_form.html file into the project templates directory in the /admin/nameofmyapp/ subdirectory, and added {% load directupload_tags %}{% directupload_head %} below the rest of the load tags. When I go to the Django admin I get the exception: 'module' object has no attribute 'admin' on line 6 of urls.py.

1

2 Answers 2

0

https://docs.djangoproject.com/en/1.4/ref/contrib/admin/#overriding-admin-templates

Sign up to request clarification or add additional context in comments.

8 Comments

I'm still getting a "'admin_static' is not a valid tag library" exception after overriding the admin template. I'll add the additional information to my question.
What are you trying to do in "EDIT" part? I don't see anything like that in directupload's docs.
Like it says in installation: Insert the following into the head of your admin/change_form.html template: {% load directupload_tags %}{% directupload_head %}
So why are you adding {% load url from future %}{% load admin_urls %} to change_list.html then? :)
Woops, had a couple of typos in there. Thanks for pointing that out. They are now fixed. I'm still getting the same error.
|
0

urls.py should look like this:

from django.conf.urls.defaults import patterns, include, url
from testproject import settings

from directupload.admin import patch_admin
from django.contrib import admin
patch_admin()
admin.autodiscover()

urlpatterns = patterns('testproject.database.views',
    url(r'^(\d+)/$', 'test_view', name="test_page"),
    url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
    url(r'^admin/', include(admin.site.urls)),
    url(r'^directupload/', include(directupload.urls))
)

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

My imports were incorrect.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.