I am following this tutorial to integrate social media login to my django project -
http://www.sarahhagstrom.com/2013/09/the-missing-django-allauth-tutorial/
However after completing all the steps, when I try to login using facebook, I get this error
relation "account_emailaddress" does not exist
I don't understand what has gone wrong as all the DB modifications ran properly without errors.
Thanks in advance for your valuable answers.
Stacktrace
Environment:
Request Method: POST
Request URL: example.com/accounts/facebook/login/token/
Django Version: 1.6.6
Python Version: 2.7.4
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'django.contrib.admin',
'django.contrib.comments',
'south',
'registration',
'endless_pagination',
'links',
'south',
'debug_toolbar',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/providers/facebook/views.py" in login_by_token
76. ret = complete_social_login(request, login)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/helpers.py" in complete_social_login
119. return _complete_social_login(request, sociallogin)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/helpers.py" in _complete_social_login
130. ret = _process_signup(request, sociallogin)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/helpers.py" in _process_signup
26. sociallogin)
File "/usr/local/lib/python2.7/dist-packages/allauth/socialaccount/adapter.py" in is_auto_signup_allowed
121. if email_address_exists(email):
File "/usr/local/lib/python2.7/dist-packages/allauth/utils.py" in email_address_exists
85. ret = emailaddresses.filter(email__iexact=email).exists()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in exists
515. return self.query.has_results(using=self.db)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/query.py" in has_results
409. return bool(compiler.execute_sql(SINGLE))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
786. cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
Exception Type: ProgrammingError at /accounts/facebook/login/token/
Exception Value: relation "account_emailaddress" does not exist
LINE 1: SELECT (1) AS "a" FROM "account_emailaddress" WHERE UPPER("a...
` ^
I figured out what the problem was. the allauth uses account app which doesn't support migrations as yet. Initially I had run
python manage.py migrate allauth.socialaccount
python manage.py migrate allauth.socialaccount.providers.facebook
Along with this we need to run the syncdb to complete the puzzle.
I think you added library providers after performing the first migration, this leaves pending migrations
run
python manage.py makemigrations allauth
and
python manage.py migrate allauth
Related
I haven't touched the code on my app in weeks but i'm suddenly getting this exact same TypeError on every page, including Admin pages.
The last thing to happen was an update on a model to change a ForeignKey field, but I don't feel the two are related
Environment:
Request Method: GET
Request URL: http://10.0.0.161:8001/admin/
Django Version: 1.9.3
Python Version: 2.7.6
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'phones',
'jobs',
'profiles',
'freelancers',
'stock',
'finance']
Installed Middleware:
['django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'profiles.middleware.UpdateLastActivityMiddleware']
Traceback:
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
174. response = self.process_exception_by_middleware(e, request)
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
172. response = response.render()
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/response.py" in render
160. self.content = self.rendered_content
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/response.py" in rendered_content
137. content = template.render(context, self._request)
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/backends/django.py" in render
95. return self.template.render(context)
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/base.py" in render
204. with context.bind_template(self):
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/contextlib.py" in __enter__
17. return self.gen.next()
File "/Users/studioxag/Documents/repos/telephones/lib/python2.7/site-packages/django/template/context.py" in bind_template
260. updates.update(processor(self.request))
Exception Type: TypeError at /admin/
Exception Value: 'NoneType' object is not iterable
Solved it by looking through some of my own context processors. I had one function that was returning None on a request (after changing an entry and having an empty queryset as a result).
I thought i had uploaded my project correctly to a remote server/host at asmallorange, but I keep running into problems.
This is what i did:
Followed all the instructions on this page:
https://help.asmallorange.com/index.php?/Knowledgebase/Article/View/305/0/install-django-using-virtualenv
checked my website (angusrchen.com) and got a default "welcome to django!" page. Okay, so i know that django is installed correctly.
then i used filezilla to upload my project files to the directory path where I had created the project on the remote server.
I ran
$ python manage.py syncdb
no errors, then
$ python manage.py collectstatic
no errors.
Two problems:
Base.html is loading when i go to my webpage, but none of the javascript seems to be working.
and now i'm getting this error when i try to navigate to any of the django pages (like /admin or /blog)
error is below:
OperationalError at /blog/
no such table: django_site
Request Method: GET
Request URL: http://angusrchen.com/blog/
Django Version: 1.6.5
Exception Type: OperationalError
Exception Value: no such table: django_site
Exception Location: /home/angusrch/.env/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 451
Python Executable: /home/angusrch/.env/env/bin/python
Python Version: 2.7.6
Python Path: ['/home/angusrch/.env/env/lib/python2.7/site-packages',
'/home/angusrch/public_html',
'/home/angusrch/.env/env/lib/python27.zip',
'/home/angusrch/.env/env/lib/python2.7',
'/home/angusrch/.env/env/lib/python2.7/plat-linux2',
'/home/angusrch/.env/env/lib/python2.7/lib-tk',
'/home/angusrch/.env/env/lib/python2.7/lib-old',
'/home/angusrch/.env/env/lib/python2.7/lib-dynload',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk']
Server time: Sat, 2 Aug 2014 11:18:06 -0500
Environment:
Request Method: GET
Request URL: http://angusrchen.com/blog/
Django Version: 1.6.5
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.comments',
'django.contrib.sites',
'tagging',
'mptt',
'blog',
'zinnia')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
112. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/views/generic/base.py" in view
69. return self.dispatch(request, *args, **kwargs)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/views/generic/base.py" in dispatch
87. return handler(request, *args, **kwargs)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/views/generic/dates.py" in get
333. self.date_list, self.object_list, extra_context = self.get_dated_items()
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/views/generic/dates.py" in get_dated_items
414. qs = self.get_dated_queryset(ordering='-%s' % self.get_date_field())
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/views/generic/dates.py" in get_dated_queryset
350. qs = self.get_queryset().filter(**lookup)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/zinnia/views/mixins/prefetch_related.py" in get_queryset
25. return super(PrefetchRelatedMixin, self
File "/home/angusrch/.env/env/lib/python2.7/site-packages/zinnia/views/mixins/callable_queryset.py" in get_queryset
20. return self.queryset()
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/manager.py" in all
133. return self.get_queryset()
File "/home/angusrch/.env/env/lib/python2.7/site-packages/zinnia/managers.py" in get_queryset
46. super(EntryPublishedManager, self).get_queryset())
File "/home/angusrch/.env/env/lib/python2.7/site-packages/zinnia/managers.py" in entries_published
33. status=PUBLISHED, sites=Site.objects.get_current())
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/contrib/sites/models.py" in get_current
47. current_site = self.get(pk=sid)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/manager.py" in get
151. return self.get_queryset().get(*args, **kwargs)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/query.py" in get
304. num = len(clone)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/query.py" in __len__
77. self._fetch_all()
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
857. self._result_cache = list(self.iterator())
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/query.py" in iterator
220. for row in compiler.results_iter():
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in results_iter
713. for rows in self.execute_sql(MULTI):
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
786. cursor.execute(sql, params)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/backends/util.py" in execute
69. return super(CursorDebugWrapper, self).execute(sql, params)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/utils.py" in __exit__
99. six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/backends/util.py" in execute
53. return self.cursor.execute(sql, params)
File "/home/angusrch/.env/env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
451. return Database.Cursor.execute(self, query, params)
Exception Type: OperationalError at /blog/
Exception Value: no such table: django_site
Your error simply state that your database does not contain the table django_site.
Try inspecting the database (see if the table is indeed present), check you're accessing the good one in your settings (if you have multiple databases on your server).
Also make sure everything works in development environment, if so you can either copy the database from your development environment to your server, or delete the one on the server and run syncdb again.
PS : I think you would get another error if you couldn't access the database, but check your file permissions, maybe it can cause this as well.
I checked the other questions on here like this one, but couldn't get an accurate answer that would solve my problem. When i run the dev server with python manage.py runserver I get the following `
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.6.4
Python Version: 2.7.6
Installed Applications:
('django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'firstapp')
Installed Middleware:
('django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware')
Traceback:
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/core/handlers/base.py" in get_response
114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/contrib/admin/sites.py" in wrapper
215. return self.admin_view(view, cacheable)(*args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/utils/decorators.py" in _wrapped_view
99. response = view_func(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/views/decorators/cache.py" in _wrapped_view_func
52. response = view_func(request, *args, **kwargs)
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/contrib/admin/sites.py" in inner
194. current_app=self.name):
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/core/urlresolvers.py" in reverse
503. app_list = resolver.app_dict[ns]
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/core/urlresolvers.py" in app_dict
329. self._populate()
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/core/urlresolvers.py" in _populate
303. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args))
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/core/urlresolvers.py" in callback
230. self._callback = get_callable(self._callback_str)
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/utils/functional.py" in wrapper
32. result = func(*args)
File "/Library/Python/2.7/site-packages/Django-1.6.4-py2.7.egg/django/core/urlresolvers.py" in get_callable
118. (lookup_view, mod_name))
Exception Type: ViewDoesNotExist at /admin/
Exception Value: Could not import Chinatown.views. View does not exist in module Chinatown.
`
But when i check my other project with which i follow the official django tut I dont have the mentioned views file in the project directory but I am able to see the admin page. Any suggestions why is the error being raised?
i think it will be more useful if just copy / paste error log . use:
./manage.py runserver --traceback
you need to add function in chinatown/views.py say "food"
and a url pattern in project's urls.py:
from django.conf.urls import url
urlpatterns = [
url(r'^food/$', 'chinatown.views.food'),
]
https://docs.djangoproject.com/en/dev/topics/http/urls/
I've installed transifex - django application. Everything looked ok, but if I run:
./manage runserver 8000
I got error message (below). Since I'm inexpedience django user supposedly it is some easy error/mistake. Unfortunately, I'm unable to discover what the problem is.
Any clue will is appreciated!
Thanks, Tomas
Environment:
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.3.1
Python Version: 2.7.3
Installed Applications:
['django.contrib.admin',
'django.contrib.auth',
'django.contrib.comments',
'django.contrib.contenttypes',
'django.contrib.flatpages',
'django.contrib.humanize',
'django.contrib.markup',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.sites',
'django.contrib.admindocs',
'staticfiles',
'notification',
'django_filters',
'django_sorting',
'south',
'tagging',
'tagging_autocomplete',
'pagination',
'piston',
'contact_form',
'ajax_select',
'threadedcomments',
'authority',
'haystack',
'social_auth',
'userena',
'guardian',
'easy_thumbnails',
'djcelery',
'djkombu',
'compressor',
'transifex.txcommon',
'transifex.languages',
'transifex.projects',
'transifex.releases',
'transifex.actionlog',
'transifex.txpermissions',
'transifex.teams',
'transifex.resources',
'django_addons',
'autofetch',
'charts',
'cla',
'copyright',
'datastores',
'gtranslate',
'helptext',
'jsonmap',
'locks',
'lotte',
'priorities',
'suggestions',
'timeline',
'trans_memory',
'txapps',
'txcron',
'txtestsuite',
'watches',
'webhooks',
'widgets']
Installed Middleware:
['django.middleware.cache.UpdateCacheMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django_sorting.middleware.SortingMiddleware',
'pagination.middleware.PaginationMiddleware',
'userena.middleware.UserenaLocaleMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware']
Traceback:
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/handlers /base.py" in get_response
101. request.path_info)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django /core/urlresolvers.py" in resolve
252. sub_match = pattern.resolve(new_path)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/urlresolvers.py" in resolve
250. for pattern in self.url_patterns:
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/core/urlresolvers.py" in _get_url_patterns
279. patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django /core/urlresolvers.py" in _get_urlconf_module
274. self._urlconf_module = import_module(self.urlconf_name)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/utils/importlib.py" in import_module
35. __import__(name)
File "/usr/lib/python2.7/site-packages/transifex-1.3.0devel-py2.7.egg/transifex/addons/cla/urls.py" in <module>
2. from transifex.projects.urls import PROJECT_URL
File "/usr/lib/python2.7/site-packages/transifex-1.3.0devel-py2.7.egg/transifex/projects/urls/__init__.py" in <module>
6. from transifex.projects.feeds import LatestProjects, ProjectFeed, ProjectTimelineFeed
File "/usr/lib/python2.7/site-packages/transifex-1.3.0devel-py2.7.egg/transifex/projects/feeds.py" in <module>
11. current_site = Site.objects.get_current()
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/contrib/sites/models.py" in get_current
25. current_site = self.get(pk=sid)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/manager.py" in get
132. return self.get_query_set().get(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/Django-1.3.1-py2.7.egg/django/db/models/query.py" in get
349. % self.model._meta.object_name)
Exception Type: DoesNotExist at /
Exception Value: Site matching query does not exist.
First of all run python manage.py syncdb. Then check this query in django shell:
Site.objects.get(id=1)
if DoesNotExist error is raised create Site object manually:
Site.objects.create(name='example.com', domain='example.com')
I have url like this http://gagandeepdesk/2690/ which I am filtering with urls.py file and sending 2690 as one of the parameters to the function.
my urls.py filter looks like this,
url(r'^(\d+)/', 'scango.scanner.views.download'),
And that function looks like this,
def download(request, MediaId):
media = Media.objects.get(id=int(MediaId))
#print media
return HttpResponse(FileIterWrapper(open(media.path)))
I am getting error 'too many values to unpack' on line
media = Media.objects.get(id=int(MediaId))
I also tried running this function standalone without request object and it is running perfectly fine. So, I am confused what I have done wrong here.
Environment:
Request Method: GET
Request URL: http://gagandeepdesk/2690/
Django Version: 1.3
Python Version: 2.7.1
Installed Applications:
['haystack',
'scanner',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Users\gagasing\Desktop\ideas\scango\..\scango\scanner\views.py" in download
21. media = Media.objects.get(id=int(MediaId))
File "C:\Python27\lib\site-packages\django\db\models\manager.py" in get
132. return self.get_query_set().get(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in get
343. clone = self.filter(*args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in filter
552. return self._filter_or_exclude(False, *args, **kwargs)
File "C:\Python27\lib\site-packages\django\db\models\query.py" in _filter_or_exclude
570. clone.query.add_q(Q(*args, **kwargs))
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in add_q
1170. can_reuse=used_aliases, force_having=force_having)
File "C:\Python27\lib\site-packages\django\db\models\sql\query.py" in add_filter
1013. arg, value = filter_expr
Exception Type: ValueError at /2690/
Exception Value: too many values to unpack
(r'^(?P<MediaId>\d+)/$', 'scango.scanner.views.download')
Maybe try this instead?
This is an example of named groups.
In Python regular expressions, the syntax for named regular expression
groups is (?Ppattern), where name is the name of the group and
pattern is some pattern to match.