dropbox / nsot

Network Source of Truth is an open source IPAM and network inventory database
https://nsot.readthedocs.io
Other
399 stars 66 forks source link

AttributeError in fetching javascript for admin panel #279

Closed jathanism closed 7 years ago

jathanism commented 7 years ago

This seems to only happen when you start the server using start and then try to visit /admin/jsi18n/:

[2017-07-12 16:04:40 -0500] [1423] [ERROR] Internal Server Error: /admin/jsi18n/
Traceback (most recent call last):
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 254, in wrapper
    return self.admin_view(view, cacheable)(*args, **kwargs)
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 346, in i18n_javascript
    return javascript_catalog(request, packages=['django.conf', 'django.contrib.admin'])
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/views/i18n.py", line 304, in javascript_catalog
    locale = to_locale(get_language())
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 194, in to_locale
    return _trans.to_locale(language)
  File "/Users/jathan/sandbox/virtualenvs/nsot/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 75, in to_locale
    p = language.find('-')
AttributeError: 'NoneType' object has no attribute 'find'
[2017-07-12 16:04:40 -0500] [1423] [INFO] 500 GET /admin/jsi18n/ (127.0.0.1) 354.66ms

Something is screwy which is preventing admin panel widgets from properly loading, displaying only their basic styled HTML rendering. This can be seen in the group add/edit panel where you're selecting permissions for a group.

jathanism commented 7 years ago

As seen here: https://github.com/django/channels/issues/86

It looks like if I add leave_locale_alone = True to nsot.util.commands.NsotCommand it alleviates this issue.