I'm getting a syntax error even though I've checked the code many times.
I'm new with Django so I'm not sure if I'm missing something else.
So this is my code in my urls.py:
# Django
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
# media
from django.conf.urls.static import static
urlpatterns = [
# Admin url path
path('admin/', admin.site.urls, name='admin'),
# Posts url paths
path('', include(('posts.urls', 'posts'), namespace='posts')),
# User url paths
path('users/', include(('users.urls', 'users'), namespace='users')),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
I'm following a tutorial and I've literally copy-pasted what was working for the tutor and it throws the same error as shown below.
File "/home/juandev/apps/platzigram/platzigram/urls.py", line 15, in <module>
path('users/', include(('users.urls', 'users'), namespace='users')),
File "/home/juandev/ENTER/envs/djangoenv/lib/python3.9/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/home/juandev/ENTER/envs/djangoenv/lib/python3.9/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 786, in exec_module
File "<frozen importlib._bootstrap_external>", line 923, in get_code
File "<frozen importlib._bootstrap_external>", line 853, in source_to_code
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/home/juandev/apps/platzigram/users/urls.py", line 19
path(
^
SyntaxError: invalid syntax
Any ideas what this might be?
Edit:
My users/urls.py looked like this:
# Django
from django.urls import path
from django.views.generic import TemplateView
# Views
from users import views
urlpatterns = [
# Posts
path(
route='profile/<str:username>/',
view= TemplateView.as_view(template_name='users/detail.html'),
name='detail'
)
# User management
path(
route='login/',
view=views.login_view,
name='login'
),
path(
route='logout/',
view=views.logout_view,
name='logout'
),
path(
route='signup/',
view=views.signup,
name='signup'
),
path(
route='me/profile',
view=views.update_profile,
name='update_profile'
),
]
Thansk to Chris for pointing out the error wasn't in my main urls.py file, i was missing a , in this other file.