Please offer guidance in setting up a Wagtail site from an existing, fairly large database.
At its core, the site will be very conventional, consisting of two basic page types: an 'index' page type that lists multiple items in the database, and a 'details' page type that displays information about an individual item.
Let's say that I'm working from a database of living things. In this scenario, each record in the main database table corresponds to a particular species.
In the planned Wagtail site, a given index page would present a list of species (likely filtered by categories such as 'plant,' 'extinct,' or 'imaginary'). The user would be able to click on any listed species to display the detail page for that species, which would give a full description and a photo of the insect, fern, or dinosaur. The detail page would also show other information such as the species' full taxonomic classification, its geographic range, and so on.
My existing database is incomplete but already contains hundreds of thousands of 'species,' so I need to import that data into Wagtail (creating a Wagtail page from scratch for each existing database record would not be at all practical, of course).
What would be the best way to import the database and access the data in Wagtail? I could:
instantiate programmatically (per the technique given here) a Wagtail page for each species in the current database, so that each species has its own 'permanent' page;
— or —
import the data into the site's Wagtail database, independent of the page structure. I would then have to create snippet models to access the data, and add code to render a page dynamically for any chosen species, based on data provided by an appropriate query run on those snippets.
I'm a complete novice at all of this, but method 1 may have two advantages: the predefined pages created during the import will already have slugs that I can easily convert to clickable links on the index pages; and the predefined pages will be discoverable by search engines.
Method 2 seems cleaner to me—keeping the core, "data data" separate from the "page data" (such as the title and slug) is logical and would simplify import/export procedures. But am I correct that it would reduce visibility of the individual pages to search engines? Aside from the programming required to render the pages dynamically, would it have other advantages or disadvantages compared to method 1?
(Regarding method 2: In Wagtail, how can pages be rendered dynamically from snippet-based query results? I know about RoutablePageMixin, but the examples I've found use it to access already-defined Wagtail pages. I would instead want to put data from snippet queries into a template, with a slug created during the page rendering process. A recipe or example would be appreciated.)
No one has responded to this question so far, but I did receive very helpful guidance from an experienced Wagtail developer I contacted on my own. Based on that input I decided to use method #1 (a Wagtail page for each individual item/'species'), for reasons I'll state at the end of this post.
First, here's an edited version of the input I got over a couple of emails:
With the above in mind, I decided that the advantages of tying our core data into the Wagtail page structure outweigh those of keeping the data in independent models/tables. One big factor is simply that things will go faster at a time when I'm just trying to get a first version of the site running. Another is that translated/internationalized versions of the site are indeed planned, so I want the benefits of Wagtail's support in that area.
As far as the inefficiency of editing large amounts of data in Wagtail goes, the solution there is to use database tools and then upload the changes to the Wagtail db. Access to those core content fields will probably have to be restricted in the Wagtail admin so that content editors don't make changes that get overwritten with the next upload.
Going with the Page model method will mean some loss of flexibility and I'll just have to endure the idea of the core data being "contaminated" with (display-related) Wagtail page items in the same tables.
But I have since come across an impressive open-source Wagtail project that uses snippet-style configuration for its core data: https://github.com/okfn/rtei / https://www.rtei.org/en/