1

I'm trying to add the module to urls.py. Here's the code:

"""
Definition of urls for learning_log.
"""

from datetime import datetime
from django.urls import path
from django.contrib import admin
from django.contrib.auth.views import LoginView, LogoutView
from app import forms, views
#added
from django.conf.urls import include, url
import learning_logs.views
from django.urls import path,re_path

app_name='learning_logs'
urlpatterns =[
    #added
    path('', include('learning_logs/urls',namespace='learning_logs'),

    path('contact/', views.contact, name='contact'),
    path('about/', views.about, name='about'),
    path('login/',
         LoginView.as_view
         (
             template_name='app/login.html',
             authentication_form=forms.BootstrapAuthenticationForm,
             extra_context=
             {
                 'title': 'Log in',
                 'year' : datetime.now().year,
             }
         ),
         name='login'),
    path('logout/', LogoutView.as_view(next_page='/'), name='logout'),
    path('admin/', admin.site.urls)]

The code seems alright,but Visual Studio keeps reporting error:

unexpected token ']'

It says the last ']' has some problem.But it is part of the grammar. How to solve this problem?

1 Answer 1

2

You are missing a closing parenthesis on the include learning_logs line:

path('', include('learning_logs/urls',namespace='learning_logs'),

should be:

path('', include('learning_logs/urls',namespace='learning_logs')),

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.