Jonathan Sumner
Jonathan Sumner

Reputation: 21

Wagtail Pages from Django Model/AdminModel

I can't seem to find any info on this, everything points to adding models to admin. I don't need that.

What I am trying to do is probably pretty simple. I have a django model AdminModel called Location. I have 23 locations plugged into the model. I would like a page for each location, with data from the model used to populate each page, and a listing page.

The locations make individual use of an inventory API and google places API. The keys are stored per location in the model, so if I can just get the pages stood up on my URL I have enough to populate them.

If it is possible, I would like to generate them as wagtail pages, so I can make use of some fields for content not stored in the model per location page. I'd be happy if I could just get the pages generated from the model data though.

I'll take a search term or a doc link. Like I said, my search terms are only finding AdminModel instructions. Any help is appreciated.

Upvotes: 0

Views: 261

Answers (1)

Dan Swain
Dan Swain

Reputation: 3098

I think you want RoutablePageMixin. You would create a single LocationPage model and include RoutablePageMixin in the definition of the model. Pay particular attention to this part of the example on this section of the page:

# Multiple routes!
@route(r'^year/(\d+)/$')
...

Note how year in this case is a parameter in the url. That parameter could be your location ID which you would use to look up the Location before rendering the page.

Upvotes: 1

Related Questions