GitHub
github.com › cobrateam › django-htmlmin › issues › 85
NameError: name 'unicode' is not defined · Issue #85 · cobrateam/django-htmlmin
I am using Django 1.8.2 on Python 3.4.2. I have added the appropriate middleware classes and set HTML_MINIFY = True in order to test it while having DEBUG on. When I run my development server, I get a "NameError" type of error, with the message "name 'unicode' is not defined".
Author: cobrateam
Stack Overflow
stackoverflow.com › questions › 60052857 › nameerror-unicode-not-defined-this-error-occurs-when-i-use-save-function-in-d
python - NameError 'unicode' not defined, this error occurs when I use save function in django model - Stack Overflow
CopyNameError at /admin/todo/todomodel/add/ name 'unicode' is not defined Request Method: POST Request URL: http://127.0.0.1:8000/admin/todo/todomodel/add/ Django Version: 2.2 Exception Type: NameError Exception Value: name 'unicode' is not defined
GitHub
github.com › realpython › django-slow-tests › issues › 2
NameError: global name 'unicode' is not defined · Issue #2 · realpython/django-slow-tests
ETraceback (most recent call last): File "manage.py", line 12, in <module> execute_from_command_line(sys.argv) ... File "/Users/troy/.virtualenvs/py33_django16/lib/python3.3/site-packages/django_slowtests/testrunner.py", line 17, in _timer TIMINGS[str(func)] = end_time - start_time NameError: global name 'unicode' is not defined
Author: realpython
Django Documentation
docs.djangoproject.com › en › 5.1 › ref › unicode
Unicode data | Django documentation | Django
If you intend to allow users to upload files, you must ensure that the environment used to run Django is configured to work with non-ASCII file names. If your environment isn’t configured correctly, you’ll encounter UnicodeEncodeError exceptions when saving files with file names or content that contains non-ASCII characters.
GitHub
github.com › mikeorr › Unipath › issues › 16
> NameError: name 'unicode' is not defined · Issue #16 · mikeorr/Unipath
July 21, 2014 - > NameError: name 'unicode' is not defined #16 · Copy link · gersande · opened · on Jul 21, 2014 · Issue body actions · My colleague using Linux is not getting this error, but on OSX running django-admin.py runserver or python manage.py shell causes the command line to throw out this name error - we used unipath in our settings module.
Author: mikeorr
Top answer 1 of 8
293
Python 3 renamed the unicode type to str, the old str type has been replaced by bytes.
if isinstance(unicode_or_str, str):
text = unicode_or_str
decoded = False
else:
text = unicode_or_str.decode(encoding)
decoded = True
You may want to read the Python 3 porting HOWTO for more such details. There is also Lennart Regebro's Porting to Python 3: An in-depth guide, free online.
Last but not least, you could just try to use the 2to3 tool to see how that translates the code for you.
2 of 8
53
If you need to have the script keep working on python2 and 3 as I did, this might help someone
import sys
if sys.version_info[0] >= 3:
unicode = str
and can then just do for example
foo = unicode.lower(foo)
YouTube
youtube.com › watch
NameError: global name 'unicode' is not defined - in Python 3 - YouTube
Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn--Music by Eric Matyashttps://www.soundimage.orgTrack title: Riding S...
Published: March 23, 2023
Django
docs.djangoproject.com › en › 1.10 › topics › python3
Porting to Python 3 | Django documentation | Django
For forwards compatibility, the new names work as of Django 1.4.2. In Python 2, the object model specifies __str__() and ` __unicode__()`_ methods.
GitHub
github.com › LightTable › Python › issues › 24
NameError: name 'unicode' is not defined · Issue #24 · LightTable/Python
February 12, 2015 - AppData\Local\LightTable\plugins\Python\py-src\ltmain.py", line 197, in handleEval code= compile(ensureUtf(code), ensureUtf(data[2]["name"]), 'exec') File "\AppData\Local\LightTable\plugins\Python\py-src\ltmain.py", line 50, in ensureUtf if type(s) == unicode: NameError: name 'unicode' is not defined
Author: LightTable
Stjohnmaronchurch
stjohnmaronchurch.org › rl7a0 › django-nameerror:-name-is-not-defined.html
django nameerror: name is not defined
January 26, 2022 - "name 'request' is not defined in django" Code Answer's NameError: name 'request' is not defined python by Awful Ant on Apr 27 2020 Comment In any case, it's nice to see another person trying out Django. Sorry if you found this is silly questions, i am new. For: Python 3.4 Django 1.6.5 Hi, you should add before imports the next: try: unicode = unicode except NameError: # 'unicode' is undefined, must be Python 3 1.