-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
disable automatic installation of demonstration content #222
Comments
I implemented a slightly different solution after some testing. This version obeys the setting, else asks if interactive, else does not do the install on non-interactive. https://github.com/nimbis/mezzanine/commit/1e552df6fea74c536fd76a2d7684a4e064e675a4
|
Yeah this has never been quite right. Thanks for bring it up. The problem is that there's two types of data, pure demo stuff, and stuff that's required for everything to work. For example there's no way to get to the blog without a blog page set up. What we'd need to first do is split these apart, so that if we're not installing the demo data, the blog page still gets install. Maybe this isn't quite right, and we need a way to basically install NO data, like you're saying, but I think the most common use case here would be - don't install demo data, but give me the minimum I need for things to work. Rather than a setting, I was thinking it might be more appropriate to have an arg for the management commands, something like --nodata, so: python manage.py --noinput --nodata The question remains would it still install the blog page, even with --nodata. If --nodata is absolute and doesn't install the blog page, we need a way to allow for this, that is, don't install demo data, but install the blog page and anything else that might be required for everything to function. |
I'll take a look at it. I think I was saved by the fact that the .json templates I'm auto importing myself has the blog page. The real issue was Cartridge. One of our team deleted the initial products, created new ones, and I got SKU unique constraint conflicts. If there is mandatory initial data, then it should probably be in the initial_data.json fixture in the blog app rather than a named fixture. I can try to break that out, but I'm still figuring my way around your schema. If we do that, the optional demo stuff can be loaded only interactively. Agree that the setting is overkill. I only think you want the demo content for a test project, so I suspect you turn it on by default to make your demo site work right. Brian Schott On May 10, 2012, at 4:59 PM, Stephen McDonald wrote:
|
Love the idea of splitting the fixtures out. Let's not use initial_data as the name though, as we then lose control over installing it since Django will do so by default. Maybe mezzanine_required.json, mezzanine_optional.json, and same for Cartridge. So required will include the blog page for Mezzanine, and the shop page for Cartridge, and everything else can go in optional (other pages, demo product, etc). Then we just need a --nodata arg for the createdb command that when specified will not load the optional fixtures (and not prompt the user for them if --noinput isn't specified). |
Looking at the code now. Unfortunately, the management/init.py looks to be catching a post syncdb migrate signal, so I don't think there is an easy way to pass down a --noinput flag without changing this behavior? Settings is much easier to implement unless I'm missing something obvious. Also, what's the reason to create a blog page even if mezzanine.blog app isn't installed? I'm trying to find how blog is connected. It should either have its own page at /blog and add itself to the menu or be its own Page subclass and let folks create multiple top-level blogs. We really want a /news and a /blog at the top level to both be blogs, for example. |
What we can do is remove the functionality from the syncdb signals and put it directly into the createdb command, that way we can add the new --nodata option and make use of it there. |
OK, I'll take a look at it but probably not this sprint (few weeks). I've merged a quick hack into my own master branch because it was holding up a user story but will back it out when we work out a more permanent solution. I know you are slammed with things for 1.1. |
Wow github is smart, check out the commit, I have some minor cleanup to do and there is a bit of redundant code surrounding the galleries creation, but what do you think? I tested it seems to work. |
Thanks Sean - I'll go over it tomorrow hopefully. |
Sean I've had a look over it and it looks good. I didn't test it yet, I'll do that once a final pull request is set up. Only thing I noticed is that you've added code for this in both the blog importers as well as the collecttemplates command - is that necessary? I can't see why it would be, but I may be missing something. |
I cleaned up the extra code, the last question I have is on the ammended commit mezzanine/core/management/init.py Have some duplicate code that they do need to run, starting with "call_command" + 5 lines, would you like to place that somewhere where they can both access it, so it only needs to be written once? If so, where is appropriate? |
I guess creating a function inside the init module would suffice. |
Pull request is open. |
Awesome Sean, thanks soooo much for working on this. I'll go over it tomorrow hopefully and merge it in. |
Cool, assuming all goes well, let me know if you want me to port over to Cartridge or if you got it. Cheers, Sean |
Well if there are any problems we'll sort them out (I glanced over it and it looks fine). So once it's all in Mezz it would be great to fix up Cartridge too. But let's wait for it to go into Mezz first in case anything does change. |
Closed by f2933d5 |
I'm running into a problem when doing automated deployments where your demonstration initial content (About page, Blog, Contact, Gallery) reappears on a fresh database installation. There is no way to suppress this behavior currently.
Two solutions:
or, 2) Change the default non-interactive --noinput behavior to NOT install demo content.
The text was updated successfully, but these errors were encountered: