Commits

offline  committed 7d092f9

StaticServe middleware added

  • Participants
  • Parent commits c5ce024

Comments (0)

Files changed (3)

 .*\.pyc
+django_annoying.egg-info

File annoying/middlewares.py

+import re
+
+from django.conf import settings
+from django.views.static import serve
+
+
+
+class StaticServe(object):
+    """
+    Django middleware for serving static files instead of using urls.py
+    
+    """
+
+    def process_request(self, request):
+        if settings.DEBUG:
+            regex = re.search(r'^%s(?P<path>.*)$' % settings.MEDIA_URL, request.path)
+            if regex:
+                return serve(request, regex.group(1), settings.MEDIA_ROOT)
 from setuptools import setup, find_packages
 setup(
     name = "django-annoying",
-    version = "0.7.1",
+    version = "0.7.2",
     packages = find_packages(),
     author = "Anderson",
     author_email = "self.anderson@gmail.com",
             - get_config function - get settings from django.conf if exists, return default value otherwise.
             - AutoOneToOne field - creates related object on first call if it doesnt exists yet.
             - HttpResponseReload - reload and stay on same page from where request was made.
+            - StaticServer middleware - instead of configuring urls.py, just add this middleware and it will serve you static files