-
Notifications
You must be signed in to change notification settings - Fork 25
Conversation
from scans.models import Site | ||
|
||
class SitePage(Page): | ||
site_url = models.CharField( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's a good idea to duplicate this value across SitePage and Site, or use sync_site
to keep the state synchronized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you just worried about them getting out of sync? The title doesn't need to be duplicated, it's basically just for the friendliness of the scans output.
The url here is basically a foreign key, and could actually be implemented that way, which would solve the duplication problem, but would lead to issues if a site ever updated its url for some reason.
Alternatively we could duplicate none of this information and just have the scan command pull in the SitePage to get the url. However this approach seems cleaner to me. The scan command shouldn't need to know anything about the web app.
Introductory disclaimer: this is a bit tricky, and neither of us are very experienced with Wagtail or Django, so "best practices" are not obvious here and there is room for debate in how this gets implemented. That being said, I do not think it is a good approach to create a SitePage for each Site. It seems to me that you are trying to accomplish two things here:
Note that 1. is already available through the default Django admin (available at For 2., the only reason I think it would be appropriate to create a SitePage for each Site is if you anticipated wanting to have a lot of custom CMS content for different SitePages. However, I do not think that is necessary here. I imagined each Site Page would be dynamically generated based on a set of info common to each Site (e.g. name, URL, scan results). |
Totally agree that best practices are not obvious. I didn't know about ModelAdmin, that seems really useful. It almost perfectly fits this use case, however I think there are a couple of other considerations.
Also as a side note, I think that we should definitely avoid requiring admins to know about django-admin. Two admin interfaces is bound to be super confusing. |
Actually looking more into wagtail/wagtail#231 we may need to implement a custom workaround for 1. anyway. Need to look into it a bit more. |
This is superseded by #4. |
Very basic setup for site pages.