0

I am new to Wagtail and intended to learn by practice.

Django=3.0.5 | Wagtail=2.13.1 | Python=3.7.10

I have existing Django project with below file structure: |- manage.py
|- static/
|- templates/
|- IoTSite/
___|- urls.py
___|- settings.py
___|- ...

I was strictly following Wagtail official guide: Integrating Wagtail into a Django project for this integration. However, after I finish the root urls.py config,

//  IoTSite/urls.py
urlpatterns = [
    path('',TemplateView.as_view(template_name='homepage.html'),name='home'), 
    path('admin/', admin.site.urls),
    path('article/',ArticleListView.as_view(template_name='TL_ArticleList.html'),name='article-list'),
    path('article/<int:pk>/',ArticleDetailView.as_view(template_name='TL_ArticleDetail.html'),name='article-detail'),
    path('archive/<int:year>/<int:month>/', ArticleMonthArchieveView.as_view(month_format='%m',template_name='TL_ArticleList.html'),name='archive_mmonth'),
    path('cms/', include(wagtailadmin_urls)),
    path('documents/', include(wagtaildocs_urls)),
    path('pages/', include(wagtail_urls)),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

when I try to access Wagtail admin site; http://127.0.0.1/cms/ I encountered 404 not found error with below debug details.

Using the URLconf defined in IoTSite.urls, Django tried these URL patterns, in this order:

1. [name='home']
2. admin/
3. article/ [name='article-list']
4. article/<int:pk>/ [name='article-detail']
5. archive/<int:year>/<int:month>/ [name='archive_mmonth']

The current path, cms/, didn't match any of these.

Q1: Why 127.0.0.1/cms was not matched when it was clearly configured in urls.py? are there any required configs not mentioned in the official guide ?

Q2: Behind the scene, how Django and Wagtail interacts with each other? I did not see a Watgail app folder within the Django project directory, it seems that Django interacts with Wagtail purely via import command and then use wagtail's pre-built components.

Yan Tian
  • 377
  • 3
  • 11
  • Did you restart the Django webserver after updating urls.py? Normally that would happen automatically if you're using `./manage.py runserver`, but the fact that the error message is only showing the 5 previously-existing URL routes makes me suspect that it hasn't picked up the changes yet. – gasman Jun 11 '21 at 12:55
  • thanks for reply. I restarted the whole docker container (which include Gunicorn as a Web server as well as Django as backend). After restart some DB error pops up, `CommandError: Error: That username is already taken`, I guess that implies existing User Models conflicts with Wagtail's one. After I made some change to avoid conflicting, it throws `Did you rename user.UserID to user.UID (a CharField)? [y/N]` during restarting. I was not able to key in `Y` as container already exists and I was not able to access via `docker exec -it container_name /bin/sh`. I am stuck here. – Yan Tian Jun 11 '21 at 13:52
  • Wagtail uses the same user model as Django, so if you already have a superuser account for Django you can just log in with that. I don't know what sort of changes you would have made to get those migration errors, sorry. – gasman Jun 11 '21 at 14:33

0 Answers0