Closed petrewoo closed 6 years ago
Hi, @petrewoo.
Did you run python manage.py makemigrations
and python manage.py migrate
before launching the server?
You should create those django tables in SQLite with initial migration to keep django happy.
Hi, @BurkovBA I didn't do that before launching the server. Can you tell me why i should do this? I use postman and httpie request http://localhost:8888/api/ everything works fine. But when i use chrome this error occurred.😂😂 I will try again litter.
@petrewoo Probably, the difference between postman and browser is due to the format of response.
When you're using postman, it requests JSON response, so JSONRenderer is used by Django REST Framework internally.
But when you go with browser, Django REST Framework is trying to use the Browsable API, which relies on core django functionality. And django wants its tables in relational database created for normal functioning - that's why you were getting the error.
@BurkovBA
After run python manage.py makemigrations
and python manage.py migrate
before launching the server, It works finally. Thank you so much.
Environment:
Request Method: GET Request URL: http://localhost:8888/api/
Django Version: 1.9 Python Version: 2.7.14 Installed Applications: ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework_mongoengine', 'mongoengine.django.mongo_auth', 'app', 'users'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/views/generic/base.py" in view
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/views.py" in dispatch
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/views.py" in initial
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/views.py" in perform_authentication
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/request.py" in getattribute
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/request.py" in user
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/request.py" in _authenticate
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/rest_framework/authentication.py" in authenticate
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/utils/functional.py" in inner
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/utils/functional.py" in _setup
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/contrib/auth/middleware.py" in get_user
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/contrib/auth/init.py" in get_user
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/contrib/auth/init.py" in _get_user_session_key
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in getitem
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in _get_session
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in load
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/models/query.py" in get
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/models/query.py" in len
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/models/query.py" in iter
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/utils.py" in exit
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
File "/Users/alex/.virtualenvs/drfm_demo/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
Exception Type: OperationalError at /api/ Exception Value: no such table: django_session