splinter icon indicating copy to clipboard operation
splinter copied to clipboard

django driver raises ImproperlyConfigured exception

Open elya5 opened this issue 10 years ago • 3 comments

The django driver raises the following exception:

Python 3.3.5 (default, Jan 17 2015, 23:43:00) 
[GCC 4.8.3] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from splinter import Browser
>>> browser = Browser('django')
>>> browser.visit('http://example.net')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/.local/lib64/python3.3/site-packages/splinter/driver/djangoclient.py", line 92, in visit
    self._response = self._browser.get(url, follow=True)
  File "/home/user/.local/lib64/python3.3/site-packages/django/test/client.py", line 470, in get
    **extra)
  File "/home/user/.local/lib64/python3.3/site-packages/django/test/client.py", line 286, in get
    return self.generic('GET', path, secure=secure, **r)
  File "/home/user/.local/lib64/python3.3/site-packages/django/test/client.py", line 337, in generic
    data = force_bytes(data, settings.DEFAULT_CHARSET)
  File "/home/user/.local/lib64/python3.3/site-packages/django/conf/__init__.py", line 46, in __getattr__
    self._setup(name)
  File "/home/user/.local/lib64/python3.3/site-packages/django/conf/__init__.py", line 40, in _setup
    % (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_CHARSET, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
>>> 

Any suggestions what went wrong or is it bug?

elya5 avatar Feb 06 '15 23:02 elya5

The splinter version is 0.7.0 and the django version is 1.7.4

elya5 avatar Feb 21 '15 09:02 elya5

@elya5 are you using python manage.py shell command?

lucasmagnum-luizalabs avatar Feb 25 '15 16:02 lucasmagnum-luizalabs

@lucasmagnum-luizalabs so I tried it with python manage.py shell and it works. Does that I mean I always have to start a django project to use django as a headless driver for splinter. It should be mentioned in the documentation then.

elya5 avatar Feb 25 '15 22:02 elya5