why does my exception give a syntax error - django

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

Related

ModuleNotFoundError: No module named 'blog.models'

I was experimenting with my database and made some errors and messed up the whole database. I deleted the database and created a new blank db. When I go to makemigrations i get the error
ModuleNotFoundError: No module named 'blog.models' refering to the line in my views.py where i import my models. I tried creating a a new project and moving the files over same error. Everything was working fine before I messed up the DB. Sorry for not a ton of information I dont know what the issue really is
error
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 419, in check
all_issues = checks.run_checks(
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\usera\djangoproject\django_coreyYT\urls.py", line 37, in <module>
path('', include('blog.urls')),
File "C:\Users\usera\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\usera\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\usera\djangoproject\blog\urls.py", line 3, in <module>
from .views import PostDeleteView, ....... (all the models)
File "C:\Users\usera\djangoproject\blog\views.py", line 5, in <module>
from .forms import PostForm, .... (all the models)
File "C:\Users\usera\djangoproject\blog\forms.py", line 3, in <module>
from blog.models import Post ... (all the models)
ModuleNotFoundError: No module named 'blog.models'
update
I tried switching to my production DB and i am still getting the same error

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,)

How to address the following error on a Django Project: "django.contrib.auth.models.DoesNotExist: Group matching query does not exist."

I am trying to run migrations on my django project and I'm getting this really bizarre error that I haven't been able to address for a while now, and I don't understand it.
here's the error I'm getting:
Anaconda3\envs\mbt\lib\site-packages\django\db\models\query.py", line 415, in get
raise self.model.DoesNotExist(
django.contrib.auth.models.DoesNotExist: Group matching query does not exist.
I've tried to run python manage.py makemigrations
python manage.py migrate auth
python manage.py migrate my_app_name
I've also inserted the group names directly into my postgresql database just in case they're not posting. This error is preventing me from running the server locally.
I thought that the Group model was generated automatically and there wasn't much I needed to do to get started using it. It's definitely visible in my database.
any help would be greatly appreciated! thank you!!
here's the full traceback:
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\management\base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\management\base.py", line 366, in execute
self.check()
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\management\base.py", line 395, in check
include_deployment_checks=include_deployment_checks,
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "C:\Users\nance\Anaconda3\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\nance\Anaconda3\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\nance\repo\project\app1\urls.py", line 28, in <module>
+ static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\nance\Anaconda3\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\nance\repo\project\app1\urls.py", line 5, in <module>
from app1 import views
File "C:\Users\nance\repo\project\app1\views.py", line 188, in <module>
class AllMentorsView(TemplateView):
File "C:\Users\nance\repo\project\app1\views.py", line 192, in AllMentorsView
mentor_group = Group.objects.get(name="Mentor")
File "C:\Users\nance\Anaconda3\lib\site-packages\django\db\models\manager.py", line 82, in manager_method
return getattr(self.get_queryset(), name)(*args, **kwargs)
File "C:\Users\nance\Anaconda3\lib\site-packages\django\db\models\query.py", line 417, in get
self.model._meta.object_name
django.contrib.auth.models.DoesNotExist: Group matching query does not exist.

Syntax error ,I have tried to load my django project on a production server

I have tried to load my project on a production server,I have the below syntax error for something that was working fine in test environment,any help here?
I cant see why I have the error
f'accounts/emails/{template}.html', context) ^ SyntaxError: invalid syntax
here is the code
def send_mail(to, template, context):
html_content = render_to_string(f'accounts/emails/{template}.html', context)
text_content = render_to_string(f'accounts/emails/{template}.txt', context)
Error Traceback
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f00e7044158>
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 396, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/grouped/teroexamplecom/teroexamplecom/urls.py", line 21, in <module>
url(r'^', include('toys.urls')),
File "/usr/local/lib/python3.5/dist-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/grouped/teroexamplecom/toys/urls.py", line 4, in <module>
from toys import views as toysviews
File "/home//grouped/toys/views.py", line 100, in <module>
from .utils import (
File "/home//toys/utils.py", line 9
html_content = render_to_string(f'accounts/emails/{template}.html', context)
^
SyntaxError: invalid syntax
The f-string notation has introduced in Python 3.6. It won't be available for below Python3.6
Soluation-1
Upgrade your python version to Python3.6 or higher
Solution-2
use format() method
def send_mail(to, template, context):
html_content = render_to_string('accounts/emails/{template}.html'.format(template=template), context)
text_content = render_to_string('accounts/emails/{template}.txt'.format(template=template), context)

LiveServerTestCase - Internal server error contact administrator

I have spent all day, trying to figure out why LiveServerTestCase keeps failing to run to no avail.... google searched, dived intro django docs yet found nothing... Looking at this stack trace what can one make from it and how to fix it.
It throws and ImportError at the end with no information whatsoever where the error occured. Am I missing something? With a whole chunk of importlib bootstrap confusions.... These are my first suites with LiveServerTestCase, for the record I am trying to configure LiveServerTestCase with selenium and I have managed to get selenium to work with remote urs this far.
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/locale.py", line 24, in process_request
i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
for url_pattern in get_resolver(urlconf).url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 157, in __call__
response = self.get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in get_response
response = self._middleware_chain(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 43, in inner
response = response_for_exception(request, exc)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 142, in handle_uncaught_exception
callback, param_dict = resolver.resolve_error_handler(500)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 418, in resolve_error_handler
callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 62, in process_request
if self.should_redirect_with_slash(request):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 80, in should_redirect_with_slash
not is_valid_path(request.path_info, urlconf) and
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 158, in is_valid_path
resolve(path, urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 27, in resolve
return get_resolver(urlconf).resolve(path)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 362, in resolve
for pattern in self.url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/wsgiref/handlers.py", line 137, in run
self.result = application(self.environ, self.start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/test/testcases.py", line 1225, in __call__
return self.application(environ, start_response)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/wsgi.py", line 157, in __call__
response = self.get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 124, in get_response
response = self._middleware_chain(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 43, in inner
response = response_for_exception(request, exc)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 93, in response_for_exception
response = handle_uncaught_exception(request, get_resolver(get_urlconf()), sys.exc_info())
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 142, in handle_uncaught_exception
callback, param_dict = resolver.resolve_error_handler(500)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 418, in resolve_error_handler
callback = getattr(self.urlconf_module, 'handler%s' % view_type, None)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
------------------------------ Captured log call -------------------------------
exception.py 135 ERROR Internal Server Error: /
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/locale.py", line 24, in process_request
i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
for url_pattern in get_resolver(urlconf).url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'
exception.py 135 ERROR Internal Server Error: /favicon.ico
Traceback (most recent call last):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/exception.py", line 41, in inner
response = get_response(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
response = middleware_method(request)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 62, in process_request
if self.should_redirect_with_slash(request):
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/middleware/common.py", line 80, in should_redirect_with_slash
not is_valid_path(request.path_info, urlconf) and
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 158, in is_valid_path
resolve(path, urlconf)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/base.py", line 27, in resolve
return get_resolver(urlconf).resolve(path)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 362, in resolve
for pattern in self.url_patterns:
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/fenn/projects/portal/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/home/fenn/projects/portal/venv/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 944, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 956, in _find_and_load_unlocked
ImportError: No module named 'my_portal.my_portal'