0

I have a code something like below

 """<div id="spc-preview-edit-submit" class="spc-form">
    <form action="{% url new-submission itemtype='%s' %}" 
    ...
    ...
    </div></form></div>""" % value

I am getting %u format: a number is required, not unicode error.

I tried using format() with double braces but, its even raising errors..

Can anyone tell a simple and elegant solution

1
  • You've just got some extra % characters in there. Escape them and you should be fine. Commented Jun 19, 2013 at 18:10

1 Answer 1

3

Escape the additional '%'s:

"""<div id="spc-preview-edit-submit" class="spc-form">
    <form action="{%% url new-submission itemtype='%s' %%}" 
    ...
    ...
    </div></form></div>""" % value

using str.format(), format requires you to escape additional { using {{:

 """<div id="spc-preview-edit-submit" class="spc-form">
    <form action="{{% url new-submission itemtype='{}' %}}" 
    ...
    ...
    </div></form></div>""".format(value)
Sign up to request clarification or add additional context in comments.

Comments

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.