简体   繁体   中英

get the modules locally for django project

Is there a way to import all the modules in the django project itself instead of setting up again and again in all the systems. I would have used gem freeze or something like that in a rails project.

There's a bit of a terminology confusion here: "modules" refers to individual .py files within a Python package. And importing is what you do within code, to bring modules into the current namespace.

I think what you're asking is how to install Python packages on deployment. The answer to that is, use pip with the freeze command, in conjunction with virtualenv .

Instead of

gem freeze

Try to use

pip bundle

I found this solution here: Django equivalent to "rake rails:freeze:gems" and "rake gems:unpack"

First of all you should be using virtualenv . This way the python path of your django app only has stuff relevant to it. This also allows you to run several separate django / python apps on the same server without them bumping heads.

When you have a virtualenv with your django app running in it you need to generate a requirements file.

pip freeze -E virtualenv_path > stable-req.txt

You can then use this file to generate a bundle.

pip bundle mybundle.bundle -r stable-req.txt

This bundle can then be used to deploy with.

Is there a reason you want to import all modules?

It's a good practice to import only those modules, classes etc. which are needed...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM