当前位置: 首页 > 工具软件 > Pinax > 使用案例 >

pinax建项目

端木夕
2023-12-01

一、 Prerequisites
To get started with Pinax you must have the following installed:
• Python 2.4+ — many OSes come with an adequate version of Python. If you are on Windows you will need to
install it from python.org. Do not install Python 3+. Pinax is not compatible with Python 3 yet.
• virtualenv 1.4.7+
• pysqlite — this is only required if you are running Python 2.4. Later versions of Python have this bundled.

• PIL — this is only required if you are using a project which requires imaging capabilites (includes projects which support avatars and/or photos). It is likely the best idea to install it anyways.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

二、 Installation


Pinax highly encourges the use of virtual environments. We will use a tool called virtualenv which provides a way to create isolated Python environments.
Create yourself a virtual environment and activate it:
$ virtualenv mysite-env
$ source mysite-env/bin/activate
(mysite-env)$

If you use Windows this will become:
$ virtualenv mysite-env
$ mysite-env\Scripts\activate.bat

(mysite-env)$


The directory mysite-env is the environment for your project. It is recommended you do not edit or create new files/directories within it. The reason this is important is that this directory should remain reproducible at all times.Reproducible environments is a good idea.Notice the (mysite-env) bit? This is done for you by the activate script to help you identify which en-vironment is currently activated. Under the hood your PATH has been modified to use the Python binary for thisenvironment.

Go ahead and install Pinax:


(mysite-env)$ pip install Pinax


不过有可能会出现以下错误:

Could not find a version that satisfies the requirement pinax (from versions: 0.9a2)

因为pip使用新的 pip call 法(pip.util.call_subprocess), 故你只能使用新版的方法安装,

所以这里只要换成指定版本的方法安裝即可:$pip install  产品名称==版本pip install pinax==0.9a2

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

三、Creating a project

Now that Pinax is installed the next step is to create a project. A project is not much more than a Django project. Pinax
provides many more defaults for you out of the box.

(mysite-env)$ pinax-admin setup_project mysite

This will create a new project named mysite. By default it will install dependencies for you. You can turn that behavior off by giving setup_project the --no-reqs option.
Pinax comes with many different project bases. The default project based is what we call layer zero. It is simply a Django project with some extra integrated dependencies that will make getting started faster.Specifying a different project base
To see what Pinax has to offer run:

(mysite-env)$ pinax-admin setup_project -l

This will list all available project bases and a short description about each. To base your project off of any of these


you’d run:

(mysite-env)$ pinax-admin setup_project -b basic mysite

In many cases the default (zero) is enough to get you going, but others may provide a better starting point for your
project.



创建工程时有可能会出现AttributeError: 'module' object has no attribute 'call_subprocess'错误

出现该问题是因为使用了新版本的pip,而在新版本的pip中,原pip.call_subprocess已经移到了pip.util.call_subprocess

因而引发异常。解决方法很简单,进入pinax目录下的core\management\commands子目录,修改setup_project.py

将其中的pip.call_subprocess改为pip.util.call_subprocess即可。

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

四、 Running a project
At this point you are now working with Django. Pinax has helped you bootstrap your project into life. Inside your
project you should run:
(mysite-env)$ python manage.py syncdb
(mysite-env)$ python manage.py runserver

 



 类似资料: