DatabaseError: no such table - django

Going insane here.
So here it goes, the traceback:
Traceback (most recent call last):
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, *callback_args, **callback_kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/contrib/admin/options.py", line 366, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/views/decorators/cache.py", line 89, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/contrib/admin/sites.py", line 196, in inner
return view(request, *args, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/utils/decorators.py", line 25, in _wrapper
return bound_func(*args, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/utils/decorators.py", line 21, in bound_func
return func(self, *args2, **kwargs2)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/transaction.py", line 224, in inner
return func(*args, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/contrib/admin/options.py", line 1274, in delete_view
[obj], opts, request.user, self.admin_site, using)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/contrib/admin/util.py", line 104, in get_deleted_objects
collector.collect(objs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/contrib/admin/util.py", line 155, in collect
return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/models/deletion.py", line 175, in collect
if not sub_objs:
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/models/query.py", line 130, in __nonzero__
iter(self).next()
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/models/query.py", line 118, in _result_iter
self._fill_cache()
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/models/query.py", line 892, in _fill_cache
self._result_cache.append(self._iter.next())
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/models/query.py", line 291, in iterator
for row in compiler.results_iter():
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 763, in results_iter
for rows in self.execute_sql(MULTI):
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 818, in execute_sql
cursor.execute(sql, params)
File "/var/www/phaethon/virtualenvs/my_random_website/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 344, in execute
return Database.Cursor.execute(self, query, params)
DatabaseError: no such table: orders_orderline
The strange thing is that this only get shown on admin view, ie:
http://www.myrandomsite.gr/admin/store/product/138/delete/
If I fire up the shell from ./manage.py shell I can call .delete() on the object just fine.
Another strange thing is, that it works fine on my local machine just fine. It only happens on the apache deployment. I have a couple of more websites that use the same stuff and work just fine.
I am mirroring apps, python version and db. I tried recreating everything, virtualenv, db, etc.
Tried ack'ing everywhere to see where that orders_orderline is defined. It's just another app in my project, that is not set in INSTALLED_APPS or anywhere. I only use it in a specific view (the model OrderLine) that is only imported if the app is installed.
edit: I sqlite3 mydb and I also can't find any reference to that table, 'cause it shouldn't exist in the first place, where is admin picking it up?
edit2: This only happens if I set DEBUG, TEMPLATE_DEBUG = FALSE

Related

django - overriding save method with super returns unique contraint error when creating object

Overriding save method with super returns unique contraint error when creating object. How to solve it?
Adding context to the code. I need to create an object1 and I need to assign some value dependent on a related foreign object. I need to assign the value after creating an instance of object1, otherwise an error pops up that the object does not exist and there is no relationship.
def save(self, *args, **kwargs):
if self.pk is None:
super(IntoDocumentProduct, self).save(*args, **kwargs)
# some logic
# more logic
super(IntoDocumentProduct, self).save(*args, **kwargs)
self.full_clean()
I am also posting the error that shows up when I test the api in insomnia.
IntegrityError at /api/wms/intodocuments/products/create/
duplicate key value violates unique constraint "wms_dokumentprzyjeciaprodukt_pkey"
DETAIL: Key (id)=(151) already exists.
Below is the error that appears in the console. It directs specifically to the save() method in the model. I don't know what is wrong with it. After all, I can't use self.save(), because there will be a recursive loop.
Traceback (most recent call last):
File "W:\projects\foodgast\venv\Lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\views\decorators\csrf.py", line 54, in wrapped_view
return view_func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\views\generic\base.py", line 103, in view
return self.dispatch(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 509, in dispatch
response = self.handle_exception(exc)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 469, in handle_exception
self.raise_uncaught_exception(exc)
File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 480, in raise_uncaught_exception
raise exc
File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\views.py", line 506, in dispatch
response = handler(request, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Sebastian\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 81, in inner
return func(*args, **kwds)
^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\src\wms\api\views.py", line 183, in post
serializer.save()
File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\serializers.py", line 212, in save
self.instance = self.create(validated_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\rest_framework\serializers.py", line 962, in create
instance = ModelClass._default_manager.create(**validated_data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\query.py", line 671, in create
obj.save(force_insert=True, using=self.db)
File "W:\projects\foodgast\src\wms\models.py", line 621, in save
super(IntoDocumentProduct, self).save(*args, **kwargs)
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\base.py", line 812, in save
self.save_base(
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\base.py", line 863, in save_base
updated = self._save_table(
^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\base.py", line 1006, in _save_table
results = self._do_insert(
^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\base.py", line 1047, in _do_insert
return manager._insert(
^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\manager.py", line 85, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\query.py", line 1791, in _insert
return query.get_compiler(using=using).execute_sql(returning_fields)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\models\sql\compiler.py", line 1660, in execute_sql
cursor.execute(sql, params)
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\backends\utils.py", line 103, in execute
return super().execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\backends\utils.py", line 67, in execute
return self._execute_with_wrappers(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\backends\utils.py", line 80, in _execute_with_wrappers
return executor(sql, params, many, context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\backends\utils.py", line 84, in _execute
with self.db.wrap_database_errors:
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "W:\projects\foodgast\venv\Lib\site-packages\django\db\backends\utils.py", line 89, in _execute
return self.cursor.execute(sql, params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
django.db.utils.IntegrityError: duplicate key value violates unique constraint "wms_dokumentprzyjeciaprodukt_pkey"
DETAIL: Key (id)=(150) already exists.
I'm like 90% sure you have to define your super properly. I tried what you have and didn't get a compile error, but it's definitely not best practices. Particularly, if you're not defining a return within your if statement. That would cause super to be called twice which could be throwing the exception due to the save function running twice. I typically set it right after my function declaration (my prefered method) or as my last line.
def save(self, *args, **kwargs):
super(IntoDocumentProduct, self).save(*args, **kwargs)
# your overwrite code
or
def save(self, *args, **kwargs):
# your overwrite code
super(IntoDocumentProduct, self).save(*args, **kwargs)

Wagtail / Django - Animated GIFs not working with many frames in the GIF

Issue Summary
Install Wagtail with all required dependencies. In order to use a GIF, WAND and imagemagick must be installed.
All steps have been implemented as specified in the documentation. (https://docs.wagtail.org/en/stable/advanced_topics/images/animated_gifs.html)
It seems like too much frames in the GIF will cause the error. I tried it with a GIF with less frames and it worked.
Unfortunately, the GIF handling with Wagtail currently does not work must be set more, which is not documented?
When uploading a GIF file I now get the following error message:
Error Message
2022-08-23 10:29:53,630 ERROR [django.request:241] log 73 140094513477440 Internal Server Error: /admin/images/multiple/add/
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "/usr/local/lib/python3.8/site-packages/django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python3.8/site-packages/django/views/decorators/cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/wagtail/admin/urls/__init__.py", line 161, in wrapper
return view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/wagtail/admin/auth.py", line 182, in decorated_view
response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 84, in view
return self.dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/django/views/decorators/vary.py", line 21, in inner_func
response = func(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/wagtail/admin/views/generic/multiple_upload.py", line 44, in dispatch
return super().dispatch(request)
File "/usr/local/lib/python3.8/site-packages/wagtail/admin/views/generic/permissions.py", line 36, in dispatch
return super().dispatch(request, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/django/views/generic/base.py", line 119, in dispatch
return handler(request, *args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/wagtail/admin/views/generic/multiple_upload.py", line 144, in post
if form.is_valid():
File "/usr/local/lib/python3.8/site-packages/django/forms/forms.py", line 205, in is_valid
return self.is_bound and not self.errors
File "/usr/local/lib/python3.8/site-packages/django/forms/forms.py", line 200, in errors
self.full_clean()
File "/usr/local/lib/python3.8/site-packages/django/forms/forms.py", line 433, in full_clean
self._clean_fields()
File "/usr/local/lib/python3.8/site-packages/django/forms/forms.py", line 443, in _clean_fields
value = field.clean(value, bf.initial)
File "/usr/local/lib/python3.8/site-packages/django/forms/fields.py", line 670, in clean
return super().clean(data)
File "/usr/local/lib/python3.8/site-packages/django/forms/fields.py", line 198, in clean
value = self.to_python(value)
File "/usr/local/lib/python3.8/site-packages/wagtail/images/fields.py", line 122, in to_python
self.check_image_pixel_size(f)
File "/usr/local/lib/python3.8/site-packages/wagtail/images/fields.py", line 112, in check_image_pixel_size
self.error_messages["file_too_many_pixels"] % (num_pixels),
ValueError: unsupported format character ')' (0x29) at index 33
Steps to Reproduce
Install Wagtail with all the libraries in techincal details
I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: yes
Technical details
Django>=4.0,<4.1
wagtail>3
wagtail_localize==1.2.1
django-extensions==3.2.0
psycopg2==2.9.3
loglevel==0.1.2
Wand==0.6.10
Ubunutu Server: sudo apt-get install libmagickwand-dev
Local MacOS: brew install imagemagick
Thank you very much in advance.
I look forward to your feedback.
I found the problem: WAGTAILIMAGES_MAX_IMAGE_PIXELS = 128000000.
I had to set the WAGTAILIMAGES_MAX_IMAGE_PIXELS higher than the default.

django.db.utils.InterfaceError: connection already closed

Stack:
Ubuntu (20.04 LTS)
Nginx
Postgresql (v13.3)
An AWS load balancer sends traffic to the Ubuntu instance(k8s cluster), which is handled by Nginx, which forwards on to Django (4.0.3) running in gunicorn (19.9.0). Django connects to the database using psycopg2 (2.8.6).
The issue I have is that the database connection seems to shut down randomly.
Django reports errors like this:
`InterfaceError: connection already closed
File "django/core/handlers/exception.py", line 55, in inner
response = get_response(request)
File "django/core/handlers/base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "contextlib.py", line 79, in inner
return func(*args, **kwds)
File "django/views/generic/base.py", line 84, in view
return self.dispatch(request, *args, **kwargs)
File "django/utils/decorators.py", line 46, in _wrapper
return bound_method(*args, **kwargs)
File "django/views/decorators/cache.py", line 62, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "django/views/generic/base.py", line 119, in dispatch
return handler(request, *args, **kwargs)
File "django/views/generic/detail.py", line 108, in get
self.object = self.get_object()
File "django/views/generic/detail.py", line 53, in get_object
obj = queryset.get()
File "django/db/models/query.py", line 492, in get
num = len(clone)
File "django/db/models/query.py", line 302, in __len__
self._fetch_all()
File "django/db/models/query.py", line 1507, in _fetch_all
self._result_cache = list(self._iterable_class(self))
File "django/db/models/query.py", line 57, in __iter__
results = compiler.execute_sql(
File "django/db/models/sql/compiler.py", line 1359, in execute_sql
cursor = self.connection.cursor()
File "django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "django/db/backends/base/base.py", line 284, in cursor
return self._cursor()
File "django/db/backends/base/base.py", line 262, in _cursor
return self._prepare_cursor(self.create_cursor(name))
File "django/db/utils.py", line 91, in __exit__
raise dj_exc_value.with_traceback(traceback) from exc_value
File "django/db/backends/base/base.py", line 262, in _cursor
return self._prepare_cursor(self.create_cursor(name))
File "django/utils/asyncio.py", line 26, in inner
return func(*args, **kwargs)
File "django/db/backends/postgresql/base.py", line 256, in create_cursor
cursor = self.connection.cursor()`
Postgresql does not report any major errors: I can only assume that the connection was closed correctly and Django was not expecting it.
This happens quite rarely, but enough to be a concern: once every 3 days.
Any suggestions of how to investigate this further would be gratefully accepted. Thanks in advance!
I'm using django-service-objects and Django-Q for a distributed data mining code. I ran into a error "django.db.utils.InterfaceError: connection already closed" when I was running Django-Q cluster async_task(..., sync=True) to debug and attempted to query the Django PostgreSQL 13 DB using Model.object.get(pk=...).
I resolved the issue by setting db_transaction = False within the Service class.
class dataMining(Service):
db_transaction = False
https://django-service-objects.readthedocs.io/en/stable/pages/usage.html#database-transactions
The effect of db_transaction=True (enabled by default) is to "...process method on services ... inside a transaction". Meaning changes to the Django PostgreSQL DB are not actually saved until the def process(self) method of the Service class completes successfully. https://django-service-objects.readthedocs.io/en/stable/pages/usage.html#service
I suspect the self.object = self.get_object() call in your code sample is experiencing the same problem of being 'locked out' during a process method within a DB transaction.

openEdx server error on exchange_access_token with azuread-oauth2

I'm now working on deploying openEdx system and encounter an error while logging in via Azure AD from the mobile device.
The web Azure AD login is working fine and I can also get access_token from azure ad.
But, when I try to exchange azure token with openEdx token via /oauth2/exchange_access_token/azuread-oauth2/ url, I'm getting the following error due to the empty response.
AttributeError: 'NoneType' object has no attribute 'get'
Hence I'm fairly new to the openEdx, I have a hard time figuring out to fix the issue. Please help to direct me into the right path to fixing this issue. Following is the detail error log.
Thanks in advance
Apr 1 12:38:45 edxapp [service_variant=lms][django.request][env:sandbox] ERROR [edxapp 24509] [exception.py:135] - Internal Server Error: /oauth2/exchange_access_token/azuread-oauth2/
Traceback (most recent call last):
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
response = self._get_response(request)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
return func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/oauth_dispatch/views.py", line 57, in dispatch
return view(request, *args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/views/generic/base.py", line 68, in view
return self.dispatch(request, *args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
return bound_func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
return view_func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 67, in _wrapper
return bound_func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/social_django/utils.py", line 49, in wrapper
return func(request, backend, *args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/utils/decorators.py", line 63, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/auth_exchange/views.py", line 44, in dispatch
return super(AccessTokenExchangeBase, self).dispatch(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/rest_framework/views.py", line 489, in dispatch
response = self.handle_exception(exc)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/rest_framework/views.py", line 449, in handle_exception
self.raise_uncaught_exception(exc)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/rest_framework/views.py", line 486, in dispatch
response = handler(request, *args, **kwargs)
File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/auth_exchange/views.py", line 57, in post
if not form.is_valid():
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/forms/forms.py", line 183, in is_valid
return self.is_bound and not self.errors
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/forms/forms.py", line 175, in errors
self.full_clean()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/forms/forms.py", line 385, in full_clean
self._clean_form()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/provider/forms.py", line 63, in _clean_form
super(OAuthForm, self)._clean_form()
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/django/forms/forms.py", line 412, in _clean_form
cleaned_data = self.clean()
File "/edx/app/edxapp/edx-platform/openedx/core/djangoapps/auth_exchange/forms.py", line 95, in clean
user = backend.do_auth(access_token, allow_inactive_user=True)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/social_core/utils.py", line 252, in wrapper
return func(*args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/social_core/backends/oauth.py", line 410, in do_auth
data = self.user_data(access_token, *args, **kwargs)
File "/edx/app/edxapp/venvs/edxapp/local/lib/python2.7/site-packages/social_core/backends/azuread.py", line 80, in user_data
id_token = response.get('id_token')
AttributeError: 'NoneType' object has no attribute 'get'
social-core is throwing the error because the response is NoneType. It makes sense that social-core is responsible here as you are aiming for 3rd party oAuth2.
If it works on web, then the None response is explainable only if the configuration is wrong.
Now, steps to troubleshoot:
Check edx.properties to ensure that the config directory is properly set.
Check your config and local yamls to ensure that oauth config is proper. [instead of simply configuring ios.yaml]
Make sure you followed additional instructions provided here.
If nothing else works, check the config for social-auth as stated here.
Hope that helps! Cheers!

Content Types Error

I am using Django 1.8 and I has an app runing on this perfectly fine. But now I migrated the whole database and whenever I try to access a record in the admin I get this error:
Internal Server Error: /admin/mitglieder/mitglied/22/
Traceback (most recent call last):
File "/home/franzritt/django-club41/django/core/handlers/base.py", line 111, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 583, in wrapper
return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/franzritt/django-club41/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/franzritt/django-club41/django/views/decorators/cache.py", line 52, in _wrapped_view_func
response = view_func(request, *args, **kwargs)
File "/home/franzritt/django-club41/django/contrib/admin/sites.py", line 206, in inner
return view(request, *args, **kwargs)
File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 1456, in change_view
return self.changeform_view(request, object_id, form_url, extra_context)
File "/home/franzritt/django-club41/django/utils/decorators.py", line 29, in _wrapper
return bound_func(*args, **kwargs)
File "/home/franzritt/django-club41/django/utils/decorators.py", line 105, in _wrapped_view
response = view_func(request, *args, **kwargs)
File "/home/franzritt/django-club41/django/utils/decorators.py", line 25, in bound_func
return func.__get__(self, type(self))(*args2, **kwargs2)
File "/home/franzritt/django-club41/django/db/transaction.py", line 394, in inner
return func(*args, **kwargs)
File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 1450, in changeform_view
return self.render_change_form(request, context, add=add, change=not add, obj=obj, form_url=form_url)
File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 1088, in render_change_form
'content_type_id': get_content_type_for_model(self.model).pk,
File "/home/franzritt/django-club41/django/contrib/admin/options.py", line 63, in get_content_type_for_model
return ContentType.objects.get_for_model(obj, for_concrete_model=False)
File "/home/franzritt/django-club41/django/contrib/contenttypes/models.py", line 58, in get_for_model
" is migrated before trying to migrate apps individually."
RuntimeError: Error creating new content types. Please make sure contenttypes is migrated before trying to migrate apps individually.
I had started the project with 1.7 but I had moved to 1.8 and the one app was running without problems. However, I had not migrated the whole project before. What I can see from the migration history is that this migration did a migration on the auth app. But even if I migrate back before this I get the same error.
I had this or a similar error before when switching to 1.8 but it is not the issue with the name field. And I am not able to delete the django_content_types table in the database because auth is linked to this table. Can I somehow solve this?
So after making sure that the dev-server and the production server were running at Django 1.8 everything worked well. I had some confusion in the environment paths of the start scripts.