When I try to run server, I get this following error:
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/josephshenouda/anaconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/Users/josephshenouda/anaconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/urls/resolvers.py", line 399, in check
messages.extend(check_resolver(pattern))
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/urls/resolvers.py", line 399, in check
messages.extend(check_resolver(pattern))
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/Users/josephshenouda/anaconda3/lib/python3.7/site-packages/django/urls/resolvers.py", line 325, in check
warnings = self._check_pattern_name()
File "/Users/josephshenouda/anaconda3/lib/python3.7/site- packages/django/urls/resolvers.py", line 333, in _check_pattern_name
if self.pattern.name is not None and ":" in self.pattern.name:
TypeError: argument of type 'function' is not iterable
accounts/urls.py:
app_name = 'accounts'
urlpatterns = [
path('explore/', views.explore, name='explore'),
path('login/', LoginView.as_view(template_name='accounts/login.html'), name='login'),
path('logout/', LogoutView.as_view(template_name='accounts/logout.html'), name='logout'),
path('register/', views.register, name='register'),
path('profile/', views.view_profile, name='profile'),
#path('profile/<int:pk>/', views.view_profile, name='profile_with_pk'),
path('profile/edit/', views.edit_profile, name='profile-edit'),
path('change-password/', views.change_password, name='change-password'),
path('reset-password/', PasswordResetView.as_view(
template_name='accounts/reset_password.html',
success_url=reverse_lazy('accounts:password_reset_done')),
name='reset-password'),
path('reset-password/done/', PasswordResetDoneView.as_view(), name='password_reset_done'),
path('reset-password/confirm/<uidb64>/<token>/', PasswordResetConfirmView.as_view(
success_url=reverse_lazy('accounts:password_reset_complete')),
name='password_reset_confirm'),
path('reset-password/complete/', PasswordResetCompleteView.as_view(), name='password_reset_complete'),
]
home/urls.py:
app_name = 'home'
urlpatterns = [
path('', HomeView.as_view(), name="home"),
re_path(r'^connect/(?P<operation>.+)/(?P<pk>\d+)/$', views.change_friends, name=change_friends)
]
main/urls.py:
urlpatterns = [
path('', views.login_redirect, name='login_redirect'),
path('admin/', admin.site.urls),
path('accounts/', include('accounts.urls', namespace='accounts')),
path('home/', include('home.urls', namespace='home')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
EDIT: I've now uploaded the urls in my project. Thanks again. Im writing this text as my post is mostly code. Ive tried editing urls but that doesn't work so just looking for the solution.
I never had any problems before, I'm wondering if I accidentally changed something. Thanks.
I guess I found the error
re_path(r'^connect/(?P<operation>.+)/(?P<pk>\d+)/$', views.change_friends, name=change_friends)
The name must be a string so it shoud be like this
re_path(r'^connect/(?P<operation>.+)/(?P<pk>\d+)/$', views.change_friends, name='change_friends')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With