title: Custom 'static' template tag in Django
body: <p>everyone!
  I need to make some specific changes for static tag. It's result of hours of my work, but I got not what I needed. Following code works properly only if I remove "django.contrib.staticfiles" from INSTALLED_APPS. But it's not right way, because I turn off whole functionality of this app.
  Please, help me solve this issue. How can I specific a priority of "staticfiles".</p>
  
  <p>settings.py:</p>
  
  <pre><code>INSTALLED_APPS = (
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      # 'django.contrib.staticfiles',        
  )
  </code></pre>
  
  <p>myapp/templatetags/staticfiles.py:</p>
  
  <pre><code>import re
  from django import template
  from django.contrib.staticfiles.templatetags.staticfiles import StaticFilesNode
  from myapp.settings.local import STATIC_VERSION
  
  
  class CustomStaticFilesNode(StaticFilesNode):
  
      @classmethod
      def handle_token(cls, parser, token):
          path = versioning_js_and_css(
              token.split_contents()[1],
              get_actual_version()
          )
          node_obj = super().handle_token(parser, token)
          node_obj.path = parser.compile_filter(path)
          return node_obj
  
  
  def get_actual_version():
      return STATIC_VERSION
  
  
  def versioning_js_and_css(path, version, tpl="'{path}?v={version}'"):
      try:
          cleaned_path = re.search("\'(.*?)\'", path).group(1)
          if cleaned_path.endswith('.css') or cleaned_path.endswith('.js'):
              path = tpl.format(path=cleaned_path, version=version)
      except AttributeError:
          pass
      return path
  
  
  def do_static_custom(parser, token):
      return CustomStaticFilesNode.handle_token(parser, token)
  
  register = template.Library()
  register.tag('static', do_static_custom)
  </code></pre>
  
  <p>Thanks in advance!</p>