Reputation: 1176
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:
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')))
The problem is that django is generating me this error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf3' in position 144: ordinal not in range(128)
and when I take a look at the stack, there is nowhere pointing to my code.. I believe it has a relation to the r'^'
which could be a different type of encoding, but I couldn't find resources to draw any conclusion.
Any help is extremely appreciated
Upvotes: 0
Views: 40
Reputation: 20369
Is that patterns
a typo?
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'))
Upvotes: 1