not able to start the start the server djano - django

updated version
# Create your models here.
class PlacedOrder(models.Model):
restraunt = models.ForeignKey(Restraunts, on_delete=models.CASCADE)
order_time = models.TimeField(
auto_now_add=True)
estimated_delivery_time = models.TimeField()
actual_delivery_time = models.TimeField()
food_ready_time = models.TimeField()
total_price = models.DecimalField(9, 2)
I am getting this error for no reason, not knowing where the problem lies, it's not allowing me to run migrations as well, I have posted by trace below, need help with this
"C:\Users\atif\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\apps\config.py", line 301, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\atif\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\atif\PycharmProjects\my_proj_basic\food_deliveryapp\orders\models.py", line 9, in <module>
class PlacedOrder(models.Model):
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\db\models\base.py", line 161, in __new__
new_class.add_to_class(obj_name, obj)
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\db\models\base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Users\atif\PycharmProjects\my_proj_basic\virtual-env\lib\site-packages\django\db\models\fields\__init__.py", line 788, in contribute_to_class
if not getattr(cls, self.attname, None):
TypeError: getattr(): attribute name must be string

May be you are missing the attribute name.
price = models.DecimalField(15, 2,)
Try This:
price = models.DecimalField(max_digits=15, decimal_places=2,)

Related

graphene_django DjangoFilterConnectionField - The type * doesn't have a connection

I have a problem with graphene_django. When I create a DjangoObjectType and pass this to DjangoFilterConnectionField in my Query, I get an AssertionError that The type {my DjangoObjectType class} doesn't have a connection.
Here is part of my code:
class TradeType(DjangoObjectType):
class Meta:
model = Trade
filter_fields = {
'id': ['exact', 'range', 'in', 'gte', 'lt'],
'updated': ['gte', 'lt'],
'created': ['gte', 'lt']
}
interface = (graphene.relay.Node,)
class Query(graphene.ObjectType):
trades = DjangoFilterConnectionField(TradeType)
I did all of this based on this page.
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/threading.py", line 932, in
_bootstrap_inner
self.run()
File "/usr/local/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.8/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/channels/management/commands/runserver.py", line 69, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python3.8/site-packages/django/core/management/base.py", line 419, in check
all_issues = checks.run_checks(
File "/usr/local/lib/python3.8/site-packages/django/core/checks/registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/usr/local/lib/python3.8/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.8/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.8/site-packages/django/urls/resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.8/site-packages/django/urls/resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.8/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.8/site-packages/django/urls/resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
File "/app/tabdeal/urls.py", line 45, in <module>
path('utils/', include('utils.urls')),
File "/usr/local/lib/python3.8/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/local/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in
_find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
File "/app/utils/urls.py", line 6, in <module>
from utils.schema import schema
File "/app/utils/schema.py", line 200, in <module>
schema = graphene.Schema(query=Query)
File "/usr/local/lib/python3.8/site-packages/graphene/types/schema.py", line 78, in __init__
self.build_typemap()
File "/usr/local/lib/python3.8/site-packages/graphene/types/schema.py", line 167, in build_typemap
self._type_map = TypeMap(
File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 80, in __init__
super(TypeMap, self).__init__(types)
File "/usr/local/lib/python3.8/site-packages/graphql/type/typemap.py", line 31, in __init__
self.update(reduce(self.reducer, types, OrderedDict())) # type: ignore
File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 88, in reducer
return self.graphene_reducer(map, type)
File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 117, in graphene_reducer
return GraphQLTypeMap.reducer(map, internal_type)
File "/usr/local/lib/python3.8/site-packages/graphql/type/typemap.py", line 109, in reducer
field_map = type_.fields
File "/usr/local/lib/python3.8/site-packages/graphql/pyutils/cached_property.py", line 22, in __get__
value = obj.__dict__[self.func.__name__] = self.func(obj)
File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 198, in fields
return define_field_map(self, self._fields)
File "/usr/local/lib/python3.8/site-packages/graphql/type/definition.py", line 212, in define_field_map
field_map = field_map()
File "/usr/local/lib/python3.8/site-packages/graphene/types/typemap.py", line 275, in construct_fields_for_type
map = self.reducer(map, field.type)
File "/usr/local/lib/python3.8/site-packages/graphene_django/fields.py", line 98, in type
assert _type._meta.connection, "The type {} doesn't have a connection".format(
AssertionError: The type TradeType doesn't have a connection
graphene==2.1.9, graphene_django==2.15, django-filter==2.4
I think the issue is it can't find what interface to use because you mistype interfaces in the Meta class as interface.
class TradeType(DjangoObjectType):
class Meta:
...
interfaces = (graphene.relay.Node,)

Django - set a model CharField value to the name of a field from another model

I have a model when I want to field_name to be the name of any field from another model.
I wrote this code:
from providers.models import Organisation
FIELD_CHOICES = [(x.name,x.verbose_name) for x in Organisation._meta.get_fields() ]
class Score (models.Model):
field_name = models.CharField(max_length=101, choices=FIELD_CHOICES)
When I run makemigrations I get django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.
This is the complete traceback:
Traceback (most recent call last):
File "./src/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
django.setup()
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/apps/registry.py", line 112, in populate
app_config.import_models()
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/apps/config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/henry/Documents/Sites/Development/autumna-dev/autumna/src/scoring/models.py", line 7, in <module>
FIELD_CHOICES = [(x.name,x.verbose_name) for x in Organisation._meta.get_fields() ]
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/db/models/options.py", line 733, in get_fields
return self._get_fields(include_parents=include_parents, include_hidden=include_hidden)
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/db/models/options.py", line 793, in _get_fields
all_fields = self._relation_tree
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/db/models/options.py", line 706, in _relation_tree
return self._populate_directed_relation_graph()
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/db/models/options.py", line 677, in _populate_directed_relation_graph
all_models = self.apps.get_models(include_auto_created=True)
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/apps/registry.py", line 175, in get_models
self.check_models_ready()
File "/home/henry/Documents/Sites/Development/autumna-dev/env/lib/python3.6/site-packages/django/apps/registry.py", line 137, in check_models_ready
raise AppRegistryNotReady("Models aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Models aren't loaded yet.

Django can not see any of the installed apps

After a minor migration I keep receiving the following error from Django's runserver command:
RuntimeError: Model class captcha.models.CaptchaStore doesn't declare an explicit app_label and isn't in an application in INSTALLED
_APPS.
This is caused by django-simple-captcha
which has been working for quite a while (a month). I haven't changed something in this exact app.
I have uninstalled it and now Django can't find ADMIN app, so that it has something to do with integrity.
My settings are like this:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
# custom
"boats.apps.BoatsConfig",
"articles.apps.ArticlesConfig",
#3rd party
"captcha",
"bootstrap4",
"django_cleanup",
"easy_thumbnails",
"social_django",
"crispy_forms",
"extra_views",
"debug_toolbar",
"reversion",
"dynamic_validator",
"django.forms", # new for a custom widgets
How I can fix this problem? It seems weird… Or alternativelly how to roll back the last migration?
full trace-back is below:
(myproject) C:\Users\hardcase1\PycharmProjects\myproject>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\python\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "C:\python\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\commands\runserver.py", line 109
, in inner_run
autoreload.raise_last_exception()
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exc
eption
raise _exception[0](_exception[1]).with_traceback(_exception[2])
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\hardcase1\PycharmProjects\myproject\boats\models.py", line 9, in <module>
from articles.models import SubHeading
File "C:\Users\hardcase1\PycharmProjects\myproject\articles\models.py", line 4, in <module>
from boats.models import ExtraUser
ImportError: cannot import name 'ExtraUser' from 'boats.models' (C:\Users\hardcase1\PycharmProjects\myproject\boats\models.py)
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\__init__.py", line 381, in execu
te_from_command_line
utility.execute()
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\__init__.py", line 375, in execu
te
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\base.py", line 323, in run_from_
argv
self.execute(*args, **cmd_options)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\commands\runserver.py", line 60,
in execute
super().execute(*args, **options)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\commands\runserver.py", line 95,
in handle
self.run(**options)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\core\management\commands\runserver.py", line 102
, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_relo
ader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\hardcase1\PycharmProjects\myproject\myproject\urls.py", line 14, in <module>
path("captcha/", include("captcha.urls")),
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\captcha\urls.py", line 2, in <module>
from captcha import views
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\captcha\views.py", line 3, in <module>
from captcha.models import CaptchaStore
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\captcha\models.py", line 25, in <module>
class CaptchaStore(models.Model):
File "C:\Users\hardcase1\.virtualenvs\myproject-N1oU6R8w\lib\site-packages\django\db\models\base.py", line 111, in __new__
"INSTALLED_APPS." % (module, name)
RuntimeError: Model class captcha.models.CaptchaStore doesn't declare an explicit app_label and isn't in an application in INSTALLED
_APPS.
Final migration
class Migration(migrations.Migration):
dependencies = [
('boats', '0014_auto_20190419_1429'),
]
operations = [
migrations.AlterField(
model_name='boatimage',
name='boat_photo',
field=models.ImageField(blank=True, upload_to=boats.utilities.get_timestamp_path, verbose_name='Boat photo'),
), # i removed help_text here
migrations.AlterField(
model_name='boatmodel',
name='boat_mast_type',
field=models.CharField(choices=[(None, 'Please choose rigging type'), ('SL', 'Sloop'), ('KE', 'Ketch'), ('YA', 'Yawl'), ('CK', 'Cat Ketch')], help_text='Please input boat rigging type', max_length=10, verbose_name='Boat rigging type'), # i added (None, 'Please choose rigging type') here
),
]
I presume you just uninstalled django-simple-captcha? Remove "captcha" from INSTALLED_APPS as well, or Django will still look for the app.
And of course delete all CaptchaFields from your models.
It was a circular import. Solution has been found, thanks to Alasdair.
I hid 2 imports inside the method...
def save(self, force_insert=False, force_update=False, using=None,
update_fields=None):
from articles.models import SubHeading, UpperHeading
SubHeading.objects.update_or_create(name=self.boat_name, order=0,
foreignkey_id=93)
models.Model.save(self, force_insert=False, force_update=False, using=None,
update_fields=None)

Problem while executing "python manage.py runserver" in django

I have been using django (2.1.5) with mysql-connector(2.1.6). Suddenly it has stopped working and giving below error when i do "python manage.py runserver". I have been trying to understand the solution through other question on same issue but it doesn't seem to help.Can somebody please help.
(ApiEnv) E:\Aabha\ApiEnv\adventureworks>python manage.py runserver
Unhandled exception in thread started by <function check_errors.<locals>.wrapper
at 0x000000F2445DE9D8>
Traceback (most recent call last):
File "E:\Aabha\ApiEnv\lib\site-packages\django\utils\autoreload.py", line 225,
in wrapper
fn(*args, **kwargs)
File "E:\Aabha\ApiEnv\lib\site-packages\django\core\management\commands\runser
ver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "E:\Aabha\ApiEnv\lib\site-packages\django\utils\autoreload.py", line 248,
in raise_last_exception
raise _exception[1]
File "E:\Aabha\ApiEnv\lib\site-packages\django\core\management\__init__.py", l
ine 337, in execute
autoreload.check_errors(django.setup)()
File "E:\Aabha\ApiEnv\lib\site-packages\django\utils\autoreload.py", line 225,
in wrapper
fn(*args, **kwargs)
File "E:\Aabha\ApiEnv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "E:\Aabha\ApiEnv\lib\site-packages\django\apps\registry.py", line 112, in
populate
app_config.import_models()
File "E:\Aabha\ApiEnv\lib\site-packages\django\apps\config.py", line 198, in i
mport_models
self.models_module = import_module(models_module_name)
File "E:\Aabha\ApiEnv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "E:\Aabha\ApiEnv\lib\site-packages\django\contrib\auth\models.py", line 2
, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "E:\Aabha\ApiEnv\lib\site-packages\django\contrib\auth\base_user.py", lin
e 47, in <module>
class AbstractBaseUser(models.Model):
File "E:\Aabha\ApiEnv\lib\site-packages\django\db\models\base.py", line 101, i
n __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "E:\Aabha\ApiEnv\lib\site-packages\django\db\models\base.py", line 305, i
n add_to_class
value.contribute_to_class(cls, name)
File "E:\Aabha\ApiEnv\lib\site-packages\django\db\models\options.py", line 203
, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length(
))
File "E:\Aabha\ApiEnv\lib\site-packages\django\db\__init__.py", line 33, in __
getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "E:\Aabha\ApiEnv\lib\site-packages\django\db\utils.py", line 203, in __ge
titem__
conn = backend.DatabaseWrapper(db, alias)
File "e:\anaconda\lib\site-packages\mysql\connector\django\base.py", line 336,
in __init__
super(DatabaseWrapper, self).__init__(*args, **kwargs)
File "E:\Aabha\ApiEnv\lib\site-packages\django\db\backends\base\base.py", line
101, in __init__
self.client = self.client_class(self)
TypeError: 'NoneType' object is not callable

why does my exception give a syntax error

well new to django and python the website i'm making is an ecommerce website and it has a carts app which deals with the shopping cart in the views.py file i have this function :
def get(self, request):
try:
item_id = request.GET.get('item')
quantity = request.GET.get('qty', 1)
delete = request.GET.get('delete', 'n')
cart, is_deleted, cart_item = self._process_cart(item_id, int(quantity), delete, request)
cart_count = cart.total_count
request.session['cart_count'] = cart_count
return Response({'success': True,
'deleted': is_deleted,
'count': cart.count,
'item_total': cart_item.item_total,
'cart_price': cart.cart_price,
'cart_count': cart_count}, status=status.HTTP_200_OK)
except Exception as error:
print error
it always gives an invalid syntax error
Traceback (most recent call last):
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\commands\runserver.py", line 117, in
inner_run
self.check(display_num_errors=True)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\management\base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\checks\registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\urls\resolvers.py", line 396, in check
for pattern in self.url_patterns:
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\urls\resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\utils\functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\urls\resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-
32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
File "C:\ecommerce-django-master\src\ecommerce\urls.py", line 15, in
<module>
url(r'^cart/', include('carts.urls')),
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-32\lib\site-
packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\ADMIN\AppData\Local\Programs\Python\Python37-
32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in
_call_with_frames_removed
File "C:\ecommerce-django-master\src\carts\urls.py", line 4, in <module>
from . import views
File "C:\ecommerce-django-master\src\carts\views.py", line 56
return Response({'success': True, 'deleted': is_deleted, 'count':
cart.count, 'item_total': cart_item.item_total, 'cart_price':
cart.cart_price, 'cart_count':cart_count}, status = status.HTTP_200_OK)
^
SyntaxError: invalid syntax
so i tried using an if instead of try but the result was my shopping cart didn't work properly afterwards it never updated it's badge and never got anything in it even after an order