Creating dynamic URLS by concatenating strings rises UnicodeEncodeError
<p>I am trying to build my urls dynamically upon my project execution, it retrieves all my projects and concatenates the strings to create the urls like following:</p>

<pre><code>for project in projects: 
    domain = Settings.objects.get(id_project=project).site_domain
    urlpatterns +=  patterns('',
    (r'^'+project.type+r'/'+project.name+r'/', include('apps.'+project.type+'.urls')))
</code></pre>

<p>The problem is that django is generating me this error: </p>

<blockquote>
  <p>UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in
  position 144: ordinal not in range(128)</p>
</blockquote>

<p>and when I take a look at the stack, there is nowhere pointing to my code.. I believe it has a relation to the <code>r'^'</code> which could be a different type of encoding, but I couldn't find resources to draw any conclusion.</p>

<p>Any help is extremely appreciated</p>

<p>Is that <code>patterns</code> a typo? </p>

<pre><code>for project in projects: 
    domain = Settings.objects.get(id_project=project).site_domain
    urlpatterns +=  url(r'^'+project.type+r'/'+project.name+r'/', include('apps.'+project.type+'.urls'))
</code></pre>

python django django-urls url-pattern