Read-only file system: '/srv/media/house_preview/question_4.PNG' - django

I have a simple Django app deployed to App Engine, which connects to Cloud SQL (PostgreSQL) instance. This Django app allows users to login/register and put up items for sale. Login/register works fine, but when putting up items for sale I get the following error:
Request Method: POST
Django Version: 3.0.3
Python Version: 3.7.7
Installed Applications:
['projects',
'blog',
'users.apps.UsersConfig',
'crispy_forms',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles']
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.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/env/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
response = get_response(request)
File "/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/env/lib/python3.7/site-packages/django/contrib/auth/decorators.py", line 21, in _wrapped_view
return view_func(request, *args, **kwargs)
File "/srv/projects/views.py", line 28, in createListing
link.save()
File "/srv/projects/models.py", line 24, in save
super(Listing_Database, self).save(*args, **kwargs)
File "/env/lib/python3.7/site-packages/django/db/models/base.py", line 746, in save
force_update=force_update, update_fields=update_fields)
File "/env/lib/python3.7/site-packages/django/db/models/base.py", line 784, in save_base
force_update, using, update_fields,
File "/env/lib/python3.7/site-packages/django/db/models/base.py", line 887, in _save_table
results = self._do_insert(cls._base_manager, using, fields, returning_fields, raw)
File "/env/lib/python3.7/site-packages/django/db/models/base.py", line 926, in _do_insert
using=using, raw=raw,
File "/env/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/env/lib/python3.7/site-packages/django/db/models/query.py", line 1204, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
File "/env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1383, in execute_sql
for sql, params in self.as_sql():
File "/env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1328, in as_sql
for obj in self.query.objs
File "/env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1328, in <listcomp>
for obj in self.query.objs
File "/env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1327, in <listcomp>
[self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
File "/env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1278, in pre_save_val
return field.pre_save(obj, add=True)
File "/env/lib/python3.7/site-packages/django/db/models/fields/files.py", line 288, in pre_save
file.save(file.name, file.file, save=False)
File "/env/lib/python3.7/site-packages/django/db/models/fields/files.py", line 87, in save
self.name = self.storage.save(name, content, max_length=self.field.max_length)
File "/env/lib/python3.7/site-packages/django/core/files/storage.py", line 52, in save
return self._save(name, content)
File "/env/lib/python3.7/site-packages/django/core/files/storage.py", line 267, in _save
fd = os.open(full_path, self.OS_OPEN_FLAGS, 0o666)
Exception Type: OSError at /projects/createListing
Exception Value: [Errno 30] Read-only file system: '/srv/media/house_preview/question_4.PNG'
I'm pretty sure it's something to do with image upload.

Writing to Google App Engine instance is not allowed,
you should use Google Cloud Storage if you want everything in Google realm
Edit your code to support different Google cloud storage backend -> for example using django-storage

It not possible to write files in the Google App Engine Standard Python3 environment except in the /tmp directory. As stated in the Python3 GAE official documentation:
The runtime includes a full filesystem. The filesystem is read-only except for the location /tmp, which is a virtual disk storing data in your App Engine instance's RAM.

Related

Getting 'Cannot use MongoClient' exception when refreshing django API request

I currently have an AWS EC2 instance running that is running a web server using Apache (httpd) to deploy the server in the instance. The project uses the Django, Djongo, and Django Rest Framework python libraries. It works initially as it gives back an API response via JSON. However, when making another API call, it comes out with the following exception:
DatabaseError at /profile/7/
No exception message supplied
Environment:
Request Method: GET
Request URL: https://[redacted]/profile/7/?format=json
Django Version: 3.2.16
Python Version: 3.7.10
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'api']
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.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 808, in __iter__
yield from iter(self._query)
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 166, in __iter__
for doc in cursor:
File "/usr/local/lib64/python3.7/site-packages/pymongo/cursor.py", line 1248, in next
if len(self.__data) or self._refresh():
File "/usr/local/lib64/python3.7/site-packages/pymongo/cursor.py", line 1165, in _refresh
self.__send_message(q)
File "/usr/local/lib64/python3.7/site-packages/pymongo/cursor.py", line 1053, in __send_message
operation, self._unpack_response, address=self.__address
File "/usr/local/lib64/python3.7/site-packages/pymongo/_csot.py", line 105, in csot_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", line 1335, in _run_operation
retryable=isinstance(operation, message._Query),
File "/usr/local/lib64/python3.7/site-packages/pymongo/_csot.py", line 105, in csot_wrapper
return func(self, *args, **kwargs)
File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", line 1441, in _retryable_read
server = self._select_server(read_pref, session, address=address)
File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", line 1247, in _select_server
topology = self._get_topology()
File "/usr/local/lib64/python3.7/site-packages/pymongo/mongo_client.py", line 1203, in _get_topology
self._topology.open()
File "/usr/local/lib64/python3.7/site-packages/pymongo/topology.py", line 192, in open
self._ensure_opened()
File "/usr/local/lib64/python3.7/site-packages/pymongo/topology.py", line 592, in _ensure_opened
raise InvalidOperation("Cannot use MongoClient after close")
The above exception (Cannot use MongoClient after close) was the direct cause of the following exception:
File "/usr/local/lib/python3.7/site-packages/djongo/cursor.py", line 65, in fetchmany
ret.append(self.result.next())
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 797, in __next__
result = next(self._result_generator)
File "/usr/local/lib/python3.7/site-packages/djongo/sql2mongo/query.py", line 830, in __iter__
raise exe from e
The above exception (
Keyword: FAILED SQL: SELECT "api_account"."userID", "api_account"."phoneNum", "api_account"."displayName", "api_account"."seeking", "api_account"."birthday", "api_account"."motto", "api_account"."faithID", "api_account"."job", "api_account"."hobbies", "api_account"."politicsID", "api_account"."city", "api_account"."stateID", "api_account"."bio", "api_account"."facePlot" FROM "api_account" WHERE "api_account"."userID" = %(0)s LIMIT 21
Params: (7,)
Version: 1.3.6
Sub SQL: None
FAILED SQL: None
Params: None
Version: None) was the direct cause of the following exception:
File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 97, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/djongo/cursor.py", line 70, in fetchmany
raise db_exe from e
The above exception () was the direct cause of the following exception:
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.7/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/usr/local/lib/python3.7/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/generics.py", line 282, in get
return self.retrieve(request, *args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/mixins.py", line 54, in retrieve
instance = self.get_object()
File "/usr/local/lib/python3.7/site-packages/rest_framework/generics.py", line 96, in get_object
obj = get_object_or_404(queryset, **filter_kwargs)
File "/usr/local/lib/python3.7/site-packages/rest_framework/generics.py", line 19, in get_object_or_404
return _get_object_or_404(queryset, *filter_args, **filter_kwargs)
File "/usr/local/lib/python3.7/site-packages/django/shortcuts.py", line 76, in get_object_or_404
return queryset.get(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 431, in get
num = len(clone)
File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 262, in __len__
self._fetch_all()
File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 1324, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "/usr/local/lib/python3.7/site-packages/django/db/models/query.py", line 51, in __iter__
results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1208, in execute_sql
return list(result)
File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1646, in cursor_iter
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/local/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1646, in <lambda>
for rows in iter((lambda: cursor.fetchmany(itersize)), sentinel):
File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 97, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 90, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/usr/local/lib/python3.7/site-packages/django/db/utils.py", line 97, in inner
return func(*args, **kwargs)
File "/usr/local/lib/python3.7/site-packages/djongo/cursor.py", line 70, in fetchmany
raise db_exe from e
Exception Type: DatabaseError at /profile/7/
Exception Value:
It starts working at one point, but then gives the exception a few other times. I could gleam that the exception actually is 'Cannot use MongoClient after close.' However, I'm not sure what exactly would be causing this as I haven't modified any other code to the underlying workings of Django. What would be causing this?
Versions of the python libraries:
Django 3.2.16
djangorestframework 3.14.0
djongo 1.3.6
pymongo 4.3.2
sqlparse 0.2.4
Finally found out what the issue was. Turns out the version of Pymongo installed with the rest of the libraries was causing the issue. Here is the combination of library versions that seem to work best with eachother:
Django 4.1.2
Pymongo 3.12.1
DjangoRestFramework 3.14.0
Hopefully this saves someone else time. In my instance, ensuring I had Python 3.8 installed helped as well.

Error message "`coreapi` must be installed for schema support"

I am trying to generate Swagger documentation using drf_yasg and it was working fine, but now it’s not.
It’s giving me an error and I can not find a solution for it.
Why am I getting this error?
Environment:
Request Method: GET
Request URL: http://0.0.0.0:8007/doc/
Django Version: 3.2.4
Python Version: 3.9.5
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'rest_framework',
'drf_yasg',
'promotions',
'vendor',
'settings']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'includes.common.middlewares.identity.IdentityMiddleware',
'includes.common.middlewares.timezone.TimezoneMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
response = get_response(request)
File "/usr/local/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/django/views/generic/base.py", line 70, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
response = self.handle_exception(exc)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
raise exc
File "/usr/local/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/drf_yasg/views.py", line 92, in get
generator = self.generator_class(info, version, url, patterns=[])
File "/usr/local/lib/python3.9/site-packages/drf_yasg/generators.py", line 183, in __init__
self._gen = SchemaGenerator(info.title, url, info.get('description', ''), patterns, urlconf)
File "/usr/local/lib/python3.9/site-packages/rest_framework/schemas/coreapi.py", line 120, in __init__
assert coreapi, '`coreapi` must be installed for schema support.'
Exception Type: AssertionError at /doc/
Exception Value: `coreapi` must be installed for schema support.
It was a silly mistake. I had made a directory to store extra files and drf_yasg was considering it as an app and was trying to generate URLs for it.
I removed the __init__.py files from that directory and it worked.

Attempt to write a readonly SQLite database in Django

I have implemented my simple Django applications on server, but my forms for users can not save anything.
My database settings looks like this:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
My error which template receives looks like this:
nvironment:
Request Method: POST
Request URL: http://68.183.76.239/wyniki-wyszukiwania/konta-bankowe/
Django Version: 2.2.2
Python Version: 3.5.2
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'app',
'django_filters',
'crispy_forms',
'django_select2']
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.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "/home/app/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
84. return self.cursor.execute(sql, params)
File "/home/app/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py" in execute
383. return Database.Cursor.execute(self, query, params)
The above exception (attempt to write a readonly database) was the direct cause of the following exception:
File "/home/app/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
34. response = get_response(request)
File "/home/app/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "/home/app/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/app/app/app/views.py" in search_results_account
149. product_broken_form.save()
File "/home/app/lib/python3.5/site-packages/django/forms/models.py" in save
458. self.instance.save()
File "/home/app/lib/python3.5/site-packages/django/db/models/base.py" in save
741. force_update=force_update, update_fields=update_fields)
File "/home/app/lib/python3.5/site-packages/django/db/models/base.py" in save_base
779. force_update, using, update_fields,
File "/home/app/lib/python3.5/site-packages/django/db/models/base.py" in _save_table
870. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/home/app/lib/python3.5/site-packages/django/db/models/base.py" in _do_insert
908. using=using, raw=raw)
File "/home/app/lib/python3.5/site-packages/django/db/models/manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/home/app/lib/python3.5/site-packages/django/db/models/query.py" in _insert
1186. return query.get_compiler(using=using).execute_sql(return_id)
File "/home/app/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
1335. cursor.execute(sql, params)
File "/home/app/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
99. return super().execute(sql, params)
File "/home/app/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
67. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/app/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
76. return executor(sql, params, many, context)
File "/home/app/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
84. return self.cursor.execute(sql, params)
File "/home/app/lib/python3.5/site-packages/django/db/utils.py" in __exit__
89. raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/app/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
84. return self.cursor.execute(sql, params)
File "/home/app/lib/python3.5/site-packages/django/db/backends/sqlite3/base.py" in execute
383. return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /wyniki-wyszukiwania/konta-bankowe/
Exception Value: attempt to write a readonly database
How can I add changes to get rid of an error? I found similar answers on Stack Overflow, but I did not find information on how to allow everyone to write changes to SQLite (to make the error disappear).
The first place that I would look for is whether or not the user who is running the Django app has write permissions on db.sqlite file.

Programming Error: "user_id of relation APP_MODEL does not exist"

I've set User as a foreign key on my Video model. I am using the default django auth User model, and have managed to create a user using the serializer and view that I set up for it. The problem is that whenever I try to create a video entry I hit the title error.
I've tried clearing the database, redoing the migrations, but there aren't any migrations for the app that handles the user serializer.
The Model
from django.contrib.auth.models import User
class Video(models.Model):
user = models.ForeignKey(
User,
on_delete=models.CASCADE,
null=True
)
map_marker = models.ForeignKey(MapMarker, on_delete=models.CASCADE)
created = models.DateTimeField()
ip_addr = models.TextField()
file_id = models.TextField()
class Meta:
ordering = ('created',)
Full traceback:
Environment:
Request Method: POST
Request URL: http://127.0.0.1:8000/videos/
Django Version: 2.2.1
Python Version: 3.7.2
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
'userbase',
'trickspot',
'profanity']
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.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware']
Traceback:
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\backends\utils.py" in _execute
84. return self.cursor.execute(sql, params)
The above exception (column "user_id" of relation "trickspot_video" does not exist
LINE 1: INSERT INTO "trickspot_video" ("user_id", "map_marker_id", "...
^
) was the direct cause of the following exception:
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\core\handlers\exception.py" in inner
34. response = get_response(request)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\core\handlers\base.py" in _get_response
115. response = self.process_exception_by_middleware(e, request)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\core\handlers\base.py" in _get_response
113. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\views\decorators\csrf.py" in wrapped_view
54. return view_func(*args, **kwargs)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\viewsets.py" in view
116. return self.dispatch(request, *args, **kwargs)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\views.py" in dispatch
495. response = self.handle_exception(exc)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\views.py" in handle_exception
455. self.raise_uncaught_exception(exc)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\views.py" in dispatch
492. response = handler(request, *args, **kwargs)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\mixins.py" in create
21. self.perform_create(serializer)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\mixins.py" in perform_create
26. serializer.save()
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\serializers.py" in save
214. self.instance = self.create(validated_data)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\rest_framework\serializers.py" in create
943. instance = ModelClass._default_manager.create(**validated_data)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\query.py" in create
422. obj.save(force_insert=True, using=self.db)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\base.py" in save
741. force_update=force_update, update_fields=update_fields)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\base.py" in save_base
779. force_update, using, update_fields,
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\base.py" in _save_table
870. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\base.py" in _do_insert
908. using=using, raw=raw)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\manager.py" in manager_method
82. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\query.py" in _insert
1186. return query.get_compiler(using=using).execute_sql(return_id)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\models\sql\compiler.py" in execute_sql
1335. cursor.execute(sql, params)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\backends\utils.py" in execute
99. return super().execute(sql, params)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\backends\utils.py" in execute
67. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\backends\utils.py" in _execute_with_wrappers
76. return executor(sql, params, many, context)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\backends\utils.py" in _execute
84. return self.cursor.execute(sql, params)
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\utils.py" in __exit__
89. raise dj_exc_value.with_traceback(traceback) from exc_value
File "C:\Users\Zeph\.virtualenvs\SK8M8_API-LRdA6z3-\lib\site-packages\django\db\backends\utils.py" in _execute
84. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /videos/
Exception Value: column "user_id" of relation "trickspot_video" does not exist
LINE 1: INSERT INTO "trickspot_video" ("user_id", "map_marker_id", "...
^
The entry should be saved with the key of the user I selected on the API view.
Something got broken along the way and dropping the DB and starting again fixed the problem.
Thanks

Django::OperationalError at /admin/login/ unable to open database file

I know there's already a same question, i too tried the solutions given their but it dint work for me hence i am writing my own question.
Hii all, i am deploying django server using apache2 server and when i tried my host Ip address it works fine as it displays it Worked page, it works for IPADRESS/admin also but after filling in the credentials and hit on enter will produce this error
***OperationalError at /admin/login/
unable to open database file***
and my error looks like
Environment:
Request Method: POST
Request URL: http://192.168.1.105/admin/login/?next=/admin/
Django Version: 1.7.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'managementdashboard')
Installed Middleware:
('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 "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
111. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/admin/sites.py" in login
361. return login(request, **defaults)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/views/decorators/debug.py" in sensitive_post_parameters_wrapper
76. return view(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
105. response = view_func(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/auth/views.py" in login
44. auth_login(request, form.get_user())
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in login
96. request.session.cycle_key()
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/sessions/backends/base.py" in cycle_key
279. self.create()
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in create
41. self.save(must_create=True)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/contrib/sessions/backends/db.py" in save
64. obj.save(force_insert=must_create, using=using)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in save
589. force_update=force_update, update_fields=update_fields)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in save_base
617. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in _save_table
698. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/base.py" in _do_insert
731. using=using, raw=raw)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/manager.py" in manager_method
92. return getattr(self.get_queryset(), name)(*args, **kwargs)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/query.py" in _insert
921. return query.get_compiler(using=using).execute_sql(return_id)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
920. cursor.execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
81. return super(CursorDebugWrapper, self).execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/utils.py" in __exit__
94. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
65. return self.cursor.execute(sql, params)
File "/var/www/dashboardapp/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
485. return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /admin/login/
Exception Value: unable to open database file
Need help as son as possible, thank you in advance.
Your Apache user does not have the rights needed to write to your database.
Modify your settings.py so that it shows an absolute path for your database, for example:
DATABASE_NAME = '/var/www/dashboardapp/whatever/path/db.sqlite3'
Then type the following commands at the Linux prompt to set the correct privileges:
chown www-data /var/www/dashboardapp/whatever/path/
chown www-data /var/www/dashboardapp/whatever/path/db.sqlite3
go to your project directory, just share permission with IIS user and that should do the job - if you have deployed on IIS windows server