Should I use Wagtail for all models in a Django app?

Viewed 668

I’m in the process of building a new webapp which uses Wagtail. This is an architecture question.

There will be the standard About, Terms of Service, and Blog pages. All of which fit in with the Wagtail paradigm very nicely. The rest of the site content is location-based information about specific types of businesses. Think of a FourSquare type app. The data for these pages will be very structured, be updated via user-facing webpages and a mobile app, and be JavaScript heavy.

For the regular Wagtail pages, there may be hundreds over time. For the location page types there will be (hopefully) tens of thousands of pages that will be nested to a max of four levels.

From a site-wide feature perspective, I’m looking to leverage Wagtail features like sitemaps and Elastic Search.

My question is, should I use the wagtail Page class for my location based pages?

Pros:

  • Easy integration with Elastic Search and Wagtail sitemaps
  • Leverage Wagtail editor on the admin side.
  • Consistent model and api structure throughout.

Cons:

  • Potentially more overhead for location pages.
  • Need to utilize more hooks to manipulate the view output (Lots of JS, so will be inserting non-model info into the template).
  • Potentially limits the use of some third-party modules.

If I went the non-wagtail route, is it possible to add non-wagtail models to the search index?

Are there other issues I should consider in this choice?

1 Answers

Any Django model can be indexed and searched by inherit from index.Indexed and defining search_fields onto the model.

As for using pages or not, as always it depends on many things. However, it looks like it would make sense to keep your location model as such, not make it a page and expose in in the admin (either Django Admin if you need some extensions that already exists there, or Wagtail's modeladmin otherwise). Then you would create a LocationIndexPage which implements the RoutablePageMixin to dynamically serve the LocationPages. The page won't exists in the admin tree but will be reachable anyway.

Related