Skip to content
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

Update project layout to match Django #1250

Closed
AlexHill opened this issue Apr 7, 2015 · 31 comments
Closed

Update project layout to match Django #1250

AlexHill opened this issue Apr 7, 2015 · 31 comments

Comments

@AlexHill
Copy link
Collaborator

AlexHill commented Apr 7, 2015

In the spirit of "Mezzanine is just Django" I think we should update the project layout to match Django's default, and go through the project template's settings.py to see if any of the Django defaults need updating.

I'm volunteering to do the work; just opening the issue here to get consensus.

@stephenmcd
Copy link
Owner

Thanks Alex - please go right ahead!

@jerivas
Copy link
Collaborator

jerivas commented Apr 7, 2015

+1 on this one! Remember the fabfile, wsgi.py, and the files inside deploy/ (because they make assumptions regarding the project layout). I can help you out with that once you're done with the general refactoring if you like :)

@AlexHill
Copy link
Collaborator Author

AlexHill commented Apr 7, 2015

Great, I'll try to get to this tonight.

@AlexHill
Copy link
Collaborator Author

AlexHill commented Apr 9, 2015

That didn't happen - but I'll put aside some time over the weekend to do this. I think it would be good to get it in before the 1.8 release.

@stephenmcd
Copy link
Owner

No worries, thanks a lot! I'll be travelling back to AU over the next couple of days, so at this stage the release probably wouldn't be until early next week at the absolute earliest anyway, so no rush.

@AlexHill
Copy link
Collaborator Author

OK, I'm in the middle of working on this now.

The new project layout requires replacing placeholders in path names: settings.py, urls.py etc live in project_directory/<project_name>/.

Since version 1.4, Django has built in project template functionality which we can work on top of, and in doing so replace most of mezzanine_project.py with calls to the Django code.

Django's startproject source and the superclass TemplateCommand are worth reading.

Two problems that I can see with this:

  • Django doesn't support overlaying multiple templates as we do when creating Cartridge projects. A couple of ways around this:
    • Use Django to generate project directories for the Mezzanine and Cartridge project templates in turn, then manually merge them.
    • Just ship a complete project template with Cartridge.
  • Running mezzanine tests from the project template directory won't work without making some changes.

The other alternative is to add code to mezzanine_project.py to support placeholders in paths, instead of using Django's machinery. But I really feel the better option would be to change what we need to in order to standardise and make use of what Django provides.

@AlexHill
Copy link
Collaborator Author

For now, I'm just going to update mezzanine_project.py so that we can at least get the basic directory structure updated, and look at making the other changes later.

@stephenmcd
Copy link
Owner

Thanks for the update Alex - I'd the same plan of one day replacing mezzanine-project with Django's new (now old) project template support, but like you said baby steps would be fine too.

Not too attached to Mezzanine's multi-project-template thing either, I think Cartridge is the only thing that ever leveraged that, and like you said things would be less complex if it just had its own entire project template.

@AlexHill
Copy link
Collaborator Author

Cool that makes things easier. It actually looks like it will be easier to update to use the Django stuff than change mezzanine_project.py anyway: since so much lives in the project app, all that stuff needs to be templated, and that's all provided for in the default Django project template.

@stephenmcd
Copy link
Owner

Awesome! Another thing we'll need to at least verify still works is the built-in fabfile. Hopefully it just works out of the box, but might need some minor tweaks for the new layout. It's a bit involved if you haven't used it before (setting up a virtual machine etc) so I'll take a look at that - just wanted to make note of it.

@AlexHill
Copy link
Collaborator Author

Yep - some of the paths will need to be changed at the very least.

This is the default Django project template. I'm planning to put the fabfile into the project root, and the deploy directory inside the project_name directory (which gets be renamed to the actual project name). Does that sound reasonable?

@stephenmcd
Copy link
Owner

I wonder if the deploy directory should go in the project root too? Not sure.

@stephenmcd
Copy link
Owner

Like technically manage.py, fabfile.py and "deploy" dir don't get "deployed".

@stephenmcd
Copy link
Owner

Eg they're tools, not part of the Python package that gets created inside the project root.

@AlexHill
Copy link
Collaborator Author

Sounds good to me, I'll go with that.

@AlexHill
Copy link
Collaborator Author

See patch in #1265.

@stephenmcd
Copy link
Owner

Closed by #1256

@yltang52
Copy link

I really look forward to this to happen. Is there any eta?

@AlexHill
Copy link
Collaborator Author

As soon as we have time to put out a release which should be soon (I need to merge TinyMCE4).

That said, the new project layout patch has been merged so if you are comfortable using this repository's master branch, you can use it today.

@yltang52
Copy link

Great, where should I download the hottest versions?

@yltang52
Copy link

Sorry, that was a dumb question. I mean how do I install the particular version into the virtual environment?

@AlexHill
Copy link
Collaborator Author

Probably the simplest way is to do:

pip install https://github.com/stephenmcd/mezzanine/archive/master.zip

I think you can also add an URL to a zip file to your requirements.txt and it will work out.

Alternative you can install directly from git: pip install git+https://github.com/stephenmcd/mezzanine.git#egg=Mezzanine

Bear in mind that the latest version requires at least Django 1.7. Good luck!

@yltang52
Copy link

Many thanks. I'll give it a try.

@yltang52
Copy link

I used to deploy Mezzanine on Heroku. In that case, how do I specify the version in the "requirements.txt"?

@AlexHill
Copy link
Collaborator Author

I think simply putting https://github.com/stephenmcd/mezzanine/archive/master.zip in your requirements.txt will work. You won't be able to specify the version – every time you install requirements pip will just download the latest master.

Alternatively you can pin to a specific commit with a requirements line like this:

-e git+https://github.com/stephenmcd/mezzanine.git@1dd34e4336c4d66c37d3a5922e9d4f64c6312d98#egg=Mezzanine

(That's the most recent commit as of now)

@yltang52
Copy link

Tried to deploy the newest version of Mezzanine on Heroku, and it worked!
Thanks a million, Alex.

@AlexHill
Copy link
Collaborator Author

My pleasure. Keep an eye out for the official release.

@yltang52
Copy link

Uhhhhh, tinymce seems not ready yet.

@yltang52
Copy link

Is there any version already having TinyMCE 4? It's kind of urgent. My customer's site is unable to edit anything in the admin page :-(

@yltang52
Copy link

TinyMCE really isn't there. Any update?

@Kniyl
Copy link
Collaborator

Kniyl commented Jun 22, 2015

You probably missed the answer from #1336

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants