Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Jacqueline McKinney
Jacqueline McKinney
2,627 Points

(Django) What does adding the static function with parameters for MEDIA_URL or STATIC_URL to urlpatterns do in urls.py?

I followed an upload file tutorial (https://godjango.com/35-upload-files/) for Django and I do have it working. I just have no clue, why you have to or what it accomplishes to have the static function appended to the end. Why do I need it?

from django.conf.urls.static import static

urlpatterns = patterns('',

) + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

I've also looked here for an explanation: