Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: name 'basestring' is not defined #63

Closed
drnow4u opened this issue Jul 2, 2014 · 10 comments
Closed

NameError: name 'basestring' is not defined #63

drnow4u opened this issue Jul 2, 2014 · 10 comments

Comments

@drnow4u
Copy link

drnow4u commented Jul 2, 2014

Hi,

I try this modul with Python 3.4.1, Django 1.6.5, django-smart-selects
1.0.9 and got following error:

Validating models...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x014CA588>
Traceback (most recent call last):
  File "C:\workspace\03-src\lib\site-packages\django\utils\autoreload.py", line 93, in wrapper
    fn(*args, **kwargs)
  File "C:\workspace\03-src\lib\site-packages\django\core\management\commands\runserver.py", line 101, in
inner_run
    self.validate(display_num_errors=True)
  File "C:\workspace\03-src\lib\site-packages\django\core\management\base.py", line 310, in validate
    num_errors = get_validation_errors(s, app)
  File "C:\workspace\03-src\lib\site-packages\django\core\management\validation.py", line 34, in get_valid
ation_errors
    for (app_name, error) in get_app_errors().items():
  File "C:\workspace\03-src\lib\site-packages\django\db\models\loading.py", line 196, in get_app_errors
    self._populate()
  File "C:\workspace\03-src\lib\site-packages\django\db\models\loading.py", line 75, in _populate
    self.load_app(app_name, True)
  File "C:\workspace\03-src\lib\site-packages\django\db\models\loading.py", line 99, in load_app
    models = import_module('%s.models' % app_name)
  File "C:\workspace\03-src\lib\importlib\__init__.py", line 109, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1129, in _exec
  File "<frozen importlib._bootstrap>", line 1471, in exec_module
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "C:\workspace\03-src\djangoproject\service\models.py", line 34, in <module>
    class Vehicle(models.Model):
  File "C:\workspace\03-src\djangoproject\service\models.py", line 45, in Vehicle
    auto_choose=True
  File "C:\workspace\03-src\lib\site-packages\smart_selects\db_fields.py", line 20, in __init__
    if isinstance(to, basestring):
NameError: name 'basestring' is not defined

I found some advice: oxplot/fysom#1

@elvisperez
Copy link

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
str = str
unicode = str
bytes = bytes
basestring = (str,bytes)
else:
# 'unicode' exists, must be Python 2
str = str
unicode = unicode
bytes = str
basestring = basestring

@SalahAdDin
Copy link
Contributor

Hi, where i have put this code?

Can you anyone fix this for full compatibility with Python 3.4 and Django 1.7?

Please, it's very important fix this issue for a urgent project for my work!

@elvisperez
Copy link

Hi. In all class where you have this problem
El feb 7, 2015 2:33 AM, "Yusuf (Josè) Luis" [email protected]
escribió:

Hi, where i have put this code?


Reply to this email directly or view it on GitHub
#63 (comment)
.

@dmytrokyrychuk
Copy link

I am going to work on this issue today.

UPD: this is already fixed by this PR.

@SalahAdDin
Copy link
Contributor

@orgkhnargh But, have i to modify theses packages files for fix this bug?
@elvisperez but, i put this in my code and i have a problem with unicode and basestring,s we have import six?

@dmytrokyrychuk
Copy link

@SalahAdDin yes, you have to modify django-smart-selects package files to fix this error. However you do not have to do it yourself. @d9pouces have already did it. You may want to build a package from this repo: https://github.com/d9pouces/django-smart-selects

Django ships with built in six module. Take a look at this page: https://docs.djangoproject.com/en/1.7/topics/python3/

@SalahAdDin
Copy link
Contributor

Ah ok, thank you, i did all manually.

@SalahAdDin
Copy link
Contributor

Guys, i think that we should create a own fork of django-smart-selects and put in it all PR for update and put many features for this. SmartSelect's author don't want update this repo and this is not good.

@SalahAdDin
Copy link
Contributor

Now, we have the next warning:

/home/tulipan/Proyectos/TiempoTurco/lib/python3.4/site-packages/smart_selects/views.py:10: RemovedInDjango19Warning: django.db.models.get_model is deprecated.
  model_class = get_model(app, model)

Can anyone fix it?

@jimmykobe1171
Copy link
Collaborator

fixed in new release 1.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants