title: Handle dynamic staticfiles path with Django
body: <p>I'm almost overcoming to finish my <code>Theme Selector</code> with <code>Django</code> but I'm blocking on one point : </p>
  
  <p>==> I don't arrive to get a dynamic staticfiles path according to the form result given by user.</p>
  
  <p>I will explain the process :</p>
  
  <p>User fills a Django form by checking a RadioSelect box. He has a choice between two options :</p>
  
  <ul>
  <li><strong>Datasystems</strong> </li>
  <li><strong>Cameroun</strong></li>
  </ul>
  
  <p>Both options correspond to 2 themes which have two differents background-colors. <strong>Datasystems</strong> is blue &amp; white and <strong>Cameroun</strong> is green &amp; red.</p>
  
  <p>So, I pick up the form result corresponding to one of both theme which are situated in static files :</p>
  
  <pre><code>|--- app1
  |--- app2
  ├── static
  │   └── Theme
  │       ├── Cameroun
  │       │   ├── css
  │       │   │   ├── Base.css
  │       │   │   ├── Base_Accueil.css
  │       │   │   ├── Base_Birthcertificate.css
  │       │   │   ├── Base_Configurations.css
  │       │   │   ├── Base_Identity.css
  │       │   │   ├── Base_Mairie.css
  │       │   │   ├── Base_Recensement.css
  │       │   │   └── Base_Table.css
  │       │   └── images
  │       │       ├── admin.png
  │       │       ├── chantier.jpeg
  │       │       ├── chantier.png
  │       │       ├── employe?\201.png
  │       │       ├── logo.png
  │       │       ├── maire.png
  │       │       ├── officier.png
  │       │       ├── stats.jpeg
  │       │       └── visiteur.png
  │       └── Datasystems
  │           ├── css
  │           │   ├── Base.css
  │           │   ├── Base_Accueil.css
  │           │   ├── Base_Birthcertificate.css
  │           │   ├── Base_Configurations.css
  │           │   ├── Base_Identity.css
  │           │   ├── Base_Mairie.css
  │           │   ├── Base_Recensement.css
  │           │   └── Base_Table.css
  │           └── images
  │               ├── admin.png
  │               ├── chantier.jpeg
  │               ├── chantier.png
  │               ├── employe?\201.png
  │               ├── logo.png
  │               ├── maire.png
  │               ├── officier.png
  │               ├── stats.jpeg
  │               └── visiteur.png
  </code></pre>
  
  <p>In my settings.py file, I have the static path like this :</p>
  
  <pre><code>STATIC_URL = '/static/'
  STATICFILES_DIRS = (os.path.join(BASE_DIR, "/Etat_civil/static/Theme/"),)
  </code></pre>
  
  <p>I'm using templates_tag but I'm not sure if my function could be write like this :</p>
  
  <pre><code>from django import template
  from Configurations.models import Theme
  
  register = template.Library() 
  
  def GetTheme(Theme):
  
      mytheme = Theme.objects.all().last()
      return  mytheme in Theme.objects.all()
  </code></pre>
  
  <p>In my templates, I would like to write static path as a dynamic path depends on variable theme selected by user :</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
  
      {% load staticfiles %}
      {% load user_tags %}
  
      &lt;meta charset="utf-8"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
      {% if mytheme == 'Datasystems' %}
      &lt;link rel="stylesheet" type="text/css" href="{% static 'Datasystems/css/Base_Accueil.css' %}"/&gt;
      {% elif mytheme == 'Cameroun' %}
       &lt;link rel="stylesheet" type="text/css" href="{% static 'Cameroun/css/Base_Accueil.css' %}"/&gt;
      {% endif %}
  
      etc ....
  </code></pre>
  
  <p>I'm a bit lost. I think that my process could work pretty well but maybe something is not written as a pythonic way or something else.</p>
  
  <p>I tried to be concise and specific.</p>
  
  <p>Thank you by advance</p>