0

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

1
  • You can safely replace r'^' and r'/' with '^' and '/'. The r doesn't do anything unless there are backslashes in the string. Commented Oct 13, 2016 at 15:07

1 Answer 1

1

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'))
Sign up to request clarification or add additional context in comments.

2 Comments

you got it! It was looking for actual enconding problems.. stack traces, misleading people for centuries.
It solved one part of the problem but now I have this:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.