Hi Ken,
Thanks for the response.
- There was no
re_path
in my urls.py
. The urlpatterns
in my urls.py
were as follows:
urlpatterns += i18n_patterns(
path("admin/", admin.site.urls),
path("", include("cms.urls"))
)
After section 3.1.1., the urlpatterns
in my ‘urls.py’ looked like this:
urlpatterns += i18n_patterns(
path("admin/", admin.site.urls),
path("polls/", include("polls.urls")),
path("", include("cms.urls"))
)
- Whenever I try using
re_path
instead of path
, I get the NameError: name 're_path' is not defined
as follows:
(venv) D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\mysite>python manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Performing system checks...
Exception in thread django-main-thread:
Traceback (most recent call last):
File "c:\program files\python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "c:\program files\python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\core\management\base.py", line 392, in check
all_issues = checks.run_checks(
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\core\checks\registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\urls\resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\urls\resolvers.py", line 593, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\venv\lib\site-packages\django\urls\resolvers.py", line 586, in urlconf_module
return import_module(self.urlconf_name)
File "c:\program files\python38\lib\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 "D:\Tutorials\Python\Projects\djangoCMS-tutorial-project\mysite\mysite\urls.py", line 19, in <module>
re_path("", include("cms.urls"))
NameError: name 're_path' is not defined
-
Here’s the directory structure to verify the location of cms_apps.py
:
-
The contents of cms_apps.py
are as follows:
from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
@apphook_pool.register # register the application
class PollsApphook(CMSApp):
app_name = "polls"
name = "Polls Application"
def get_urls(self, page=None, language=None, **kwargs):
return ["polls.urls"]