{"id":177243,"date":"2013-04-19T00:49:02","date_gmt":"2013-04-18T20:49:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=177243"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=177243","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 django \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430 OpenShift \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0435 \u043e\u0442 Red Hat<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0430 \u0432 \u043d\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f, \u0430 Red Hat \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0435\u0449\u0451 \u0438 \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043a\u0443\u0441\u043d\u043e\u0441\u0442\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e (\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438). <br \/>  \u0412\u044b \u043d\u0435 \u043f\u043b\u0430\u0442\u0438\u0442\u0435 \u0437\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435?<\/p>\n<ul>\n<li>1 Gb \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/li>\n<li>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c 3 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 php 5.3, Ruby 1.9, Node.js 0.6, Perl 5.10, python 2.6 (3.3), Zend Server 5.6 \u0438 \u044d\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. <\/li>\n<\/ul>\n<p>  \u041d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c Do-It-Yourself \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0434\u0443\u0448\u0435 \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<p>  \u041c\u044b \u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 Django \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<a name=\"habracut\"><\/a><br \/>  \u041c\u0430\u043d\u0443\u0430\u043b\u043e\u0432 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043c\u043d\u043e\u0439 \u0431\u044b\u043b\u043e \u043d\u0430\u0439\u0434\u0435\u043d\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u043d\u043e \u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438 \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u043b\u0438 \u043f\u043e\u0432\u043e\u0437\u0438\u0442\u044c\u0441\u044f. \u041e\u043f\u0438\u0448\u0443 \u043d\u0438\u0436\u0435.<\/p>\n<p>  \u0418\u0442\u0430\u043a \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 <a href=\"https:\/\/www.openshift.com\/\">openshift.com<\/a> \u043b\u0443\u0447\u0448\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c rhc \u2014 \u0442\u0443\u043b\u0437\u0443 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043d\u0430\u0441 \u0440\u0435\u0441\u0443\u0440\u0441\u0430\u043c\u0438. \u041f\u043e\u0447\u0435\u043c\u0443 \u043b\u0443\u0447\u0448\u0435? \u0414\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0442\u044c \u0432\u0441\u0451 \u0438 \u0438\u0437 \u0432\u0435\u0431 \u0431\u0440\u0430\u0443\u0437\u0435\u0440\u0430, \u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u043c\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0449\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0432 linux.<\/p>\n<p>  \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c rhc \u0432 ubuntu \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"bash\">$ sudo yum install rubygems git $ sudo gem install rhc <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0435 \u043b\u043e\u0433\u0438\u043d \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0441\u043e\u043b\u044c:<\/p>\n<pre><code class=\"bash\">$ rhc setup <\/code><\/pre>\n<p>  \u0413\u043e\u0442\u043e\u0432\u043e. \u041c\u044b \u0432 \u0441\u0435\u0442\u0438. <br \/>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c python \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">$ rhc app create habr python-2.6 <\/code><\/pre>\n<p>  habr \u2014 \u044d\u0442\u043e \u043a\u043e\u043d\u0435\u0447\u043d\u043e \u0436\u0435 \u0438\u043c\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u0423\u0442\u0438\u043b\u0438\u0442\u0430 \u0441\u043e\u043e\u0431\u0449\u0430\u0435\u0442, \u0447\u0442\u043e \u043d\u0430\u0448\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <a href=\"http:\/\/habr-lamazavr.rhcloud.com\/\">http:\/\/habr-lamazavr.rhcloud.com\/<br \/>  <\/a>, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0430\u0434\u0440\u0435\u0441 git \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f (\u0441\u043a\u043e\u043f\u0438\u0440\u0443\u0439\u0442\u0435 \u0435\u0433\u043e \u043a\u0443\u0434\u0430\u043d\u0438\u0431\u0443\u0442\u044c).<br \/>  \u0412\u0438\u0434\u0438\u043c \u0442\u0430\u043a\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/bb3\/eae\/da0\/bb3eaeda08d19be84e5f03380b40e7db.png\"\/><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 django. \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 wsgi \u0438 \u0441\u043e\u0437\u0434\u0430\u0451\u043c django \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code class=\"bash\">$ cd habr\/wsgi\/ $ django-admin startproject habr <\/code><\/pre>\n<p>  \u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b application \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 wsgi:<\/p>\n<pre><code class=\"python\">#!\/usr\/bin\/env python   # some original codes we need import os   virtenv = os.environ['APPDIR'] + '\/virtenv\/' os.environ['PYTHON_EGG_CACHE'] = os.path.join(virtenv, 'lib\/python2.6\/site-packages') virtualenv = os.path.join(virtenv, 'bin\/activate_this.py') try:     execfile(virtualenv, dict(__file__=virtualenv)) except:     pass   # new codes we adding for Django import sys import django.core.handlers.wsgi   os.environ['DJANGO_SETTINGS_MODULE'] = os.environ['OPENSHIFT_APP_NAME']+'.settings' sys.path.append(os.path.join(os.environ['OPENSHIFT_REPO_DIR'], 'wsgi', os.environ['OPENSHIFT_APP_NAME'])) application = django.core.handlers.wsgi.WSGIHandler() <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 django \u0440\u0430\u0441\u043a\u043e\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435 \u0441\u0442\u0440\u043e\u043a\u0443<\/p>\n<pre><code class=\"python\">install_requires=['Django&gt;=1.3'], <\/code><\/pre>\n<p>  \u0432 \u0444\u0430\u0439\u043b\u0435 setup.py \u0432 \u043a\u043e\u0440\u043d\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f openshift.<br \/>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0432\u0441\u0451 \u044d\u0442\u043e \u0437\u0430\u043b\u0438\u0442\u044c \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. <br \/>  \u0412\u043e\u0439\u0434\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 wsgi \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043f\u0430\u043f\u043a\u0443 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0432 git:<\/p>\n<pre><code class=\"bash\">$ git add habr $ git commit -a -m &quot;Initialization&quot; $ git push <\/code><\/pre>\n<p>  \u0412 \u0445\u043e\u0434\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0441\u044f \u0438 django (\u0432 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 1.5.1, \u0442.\u0435. \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043d\u0430 \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u0432\u0435\u0440\u0441\u0438\u044f).<br \/>  \u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0438 \u0432\u0438\u0434\u0438\u043c \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443 django:<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/9a9\/be5\/89a\/9a9be589a677d18680be2d74d428ea12.png\"\/><\/p>\n<p>  \u041d\u043e \u043a\u0430\u043a\u043e\u0435\u0436\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0431\u0435\u0437 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445. <br \/>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 mysql, phpmyadmin \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c django \u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043d\u0435\u0439.<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a\u0430\u0442\u0440\u0438\u0434\u0436 mysql \u043a \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044e habr:<\/p>\n<pre><code class=\"bash\">$ rhc cartridge add mysql-5.1 -a habr <\/code><\/pre>\n<p>  C\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0438\u043c\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043f\u0430\u0440\u043e\u043b\u044c \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u0432\u044b\u0432\u043e\u0434\u0430 rhc:<\/p>\n<pre><code class=\"bash\">Added mysql-5.1 to application habr  MySQL 5.1 database added.  Please make note of these credentials:         Root User: \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c    Root Password: \u043f\u0430\u0440\u043e\u043b\u044c    Database Name: habr  Connection URL: mysql:\/\/$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT\/  You can manage your new MySQL database by also embedding phpmyadmin-3.4. The phpmyadmin username and password will be the same as the MySQL credentials above. <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c phpmyadmin:<\/p>\n<pre><code class=\"bash\">$ rhc cartridge add phpmyadmin-3.4 -a habr <\/code><\/pre>\n<p>  \u0411\u0443\u0434\u0435\u0442 \u043e\u043f\u044f\u0442\u044c \u0432\u044b\u0432\u0435\u0434\u0435\u043d \u043f\u0430\u0440\u043e\u043b\u044c \u0438 \u0438\u043c\u044f \u0434\u043b\u044f \u0432\u043e\u0445\u043e\u0434\u0430 phpmyadmin, \u0445\u043e\u0442\u044f \u044d\u0442\u043e \u0434\u0443\u0431\u043b\u044c \u043f\u0430\u0440\u043e\u043b\u044f \u0438 \u0438\u043c\u0435\u043d\u0438 \u043a \u0431\u0430\u0437\u0435.<br \/>  \u0412\u0430\u0436\u043d\u0430 \u0442\u0443\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u0434\u043b\u044f \u0432\u0445\u043e\u0434\u0430 \u0432 \u0430\u0434\u043c\u0438\u043d\u0430. <a href=\"https:\/\/habr-lamazavr.rhcloud.com\/phpmyadmin\/\">habr-lamazavr.rhcloud.com\/phpmyadmin\/<\/a><\/p>\n<p>  Phpmyadmin \u044f \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u044e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0433\u043e\u0442\u043e\u0432\u0443\u044e \u0431\u0430\u0437\u0443 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440. \u0412\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c syncdb \u0442\u0430\u043c \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e.<br \/>  \u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c django \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0430\u0437\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0444\u0430\u0439\u043b\u0435 settings.py \u043d\u0430\u0448\u0435\u0433\u043e django \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<pre><code class=\"python\">      'ENGINE': 'django.db.backends.mysql', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.         'NAME': os.environ['OPENSHIFT_APP_NAME'],                      # Or path to database file if using sqlite3.         'USER': os.environ['OPENSHIFT_MYSQL_DB_USERNAME'],                      # Not used with sqlite3.         'PASSWORD': os.environ['OPENSHIFT_MYSQL_DB_PASSWORD'],                  # Not used with sqlite3.         'HOST': os.environ['OPENSHIFT_MYSQL_DB_HOST'],                      # Set to empty string for localhost. Not used with sqlite3.         'PORT': os.environ['OPENSHIFT_MYSQL_DB_PORT'],                      # Set to empty string for default. Not used with sqlite3. <\/code><\/pre>\n<p>  \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c os \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u0430\u0439\u043b\u0430.<\/p>\n<p>  \u041a\u043e\u043c\u043c\u0438\u0442\u0438\u043c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438 \u0437\u0430\u043b\u0438\u0432\u0430\u0435\u043c:<\/p>\n<pre><code class=\"bash\">$ git commit -a -m &quot;db init&quot; $ git push <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0437\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0447\u043a\u0443 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f. \u0412\u0441\u0451 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e. \u0417\u043d\u0430\u0447\u0438\u0442 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0430, \u0438\u043d\u0430\u0447\u0435 \u0432\u0438\u0434\u0438\u043c 501 \u043e\u0448\u0438\u0431\u043a\u0443. \u0422\u043e\u0433\u0434\u0430 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043b\u043e\u0433\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">$ rhc tail habr <\/code><\/pre>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0442\u0430\u043a\u0436\u0435 django-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"bash\">$ django-admin startapp habrapp <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0440\u043e\u0447\u043a\u0443:<\/p>\n<pre><code class=\"python\">    'habrapp', <\/code><\/pre>\n<p>  \u0432 INSTALLED_APPS \u0432 \u0444\u0430\u0439\u043b\u0435 settiongs.py \u043f\u0440\u043e\u0435\u043a\u0442\u0430 django.<br \/>  \u0421\u0434\u0435\u043b\u0430\u0435\u043c view \u0441 css \u0438 media \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e.<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 habr\/habr (\u0440\u044f\u0434\u043e\u043c \u0441 \u0444\u0430\u0439\u043b\u043e\u043c settings.py) \u043f\u0430\u043f\u043a\u0443 templates \u0438 \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b index.html:<\/p>\n<pre><code class=\"html\">&lt;!DOCTYPE html&gt; &lt;html lang=&quot;ru&quot;&gt; &lt;head&gt; \t&lt;meta charset=&quot;utf-8&quot;&gt; \t&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text\/html; charset=utf-8&quot; \/&gt; \t&lt;link rel=&quot;stylesheet&quot; href=&quot;\/media\/css\/style.css&quot; type=&quot;text\/css&quot; \/&gt; \t&lt;title&gt;{{title}}&lt;\/title&gt; &lt;\/head&gt; &lt;body&gt;     &lt;h3&gt;{{text}}&lt;\/h3&gt; &lt;\/body&gt; &lt;\/html&gt; <\/code><\/pre>\n<p>  \u0412\u044c\u044e\u0445\u0443 \u043f\u0438\u0448\u0435\u043c \u0432\u043e views.py:<\/p>\n<pre><code class=\"python\">from django.shortcuts import render_to_response  def index(request):     c = { 'title': 'Habratitle', 'text': 'Hello habrahabr from OpenShift!',}     return render_to_response('index.html',c) <\/code><\/pre>\n<p>  \u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c url \u0432 urls.py:<\/p>\n<pre><code class=\"python\">    (r'^$','habrapp.views.index'), <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u0430\u043c\u0438 \u043d\u0430\u0448\u0435\u043c\u0443 \u043f\u0440\u043e\u0435\u043a\u0443 \u0432 \u0444\u0430\u0439\u043b\u0435 settings.py:<\/p>\n<pre><code class=\"python\">TEMPLATE_DIRS = (     os.path.join(os.path.dirname(__file__),'templates').replace('\\\\','\/'), ) <\/code><\/pre>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 git \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u0443\u044e \u043d\u0430\u043c\u0438 \u043f\u0430\u043f\u043a\u0443 \u0441 \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u043c \u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 django:<\/p>\n<pre><code class=\"bash\">$ git add templates\/ $ git add habrapp\/ <\/code><\/pre>\n<p>  \u0421 \u043f\u0443\u0442\u044f\u043c\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0436\u0443, \u043d\u0438\u0436\u0435 \u0430\u0440\u0445\u0438\u0432 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c.<br \/>  \u041a\u043e\u043c\u043c\u0438\u0442\u0438\u043c \u0438 \u0437\u0430\u043b\u0438\u0432\u0430\u0435\u043c<\/p>\n<pre><code class=\"bash\">$ git commit -a -m 'views add' $ git push <\/code><\/pre>\n<p>  \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u0438\u0434\u0438\u043c \u043d\u0430\u0448\u0443 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443.<br \/>  \u041d\u0443 \u0430 \u0442\u0435\u043f\u0435\u0440\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u043a\u0443\u0441\u043d\u043e\u0441\u0442\u0438 \u0441 media \u0444\u0430\u0439\u0434\u0430\u043c\u0438.<br \/>  \u0412\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u043a \u0444\u0430\u0439\u043b\u044b \u0430\u0434\u043c\u0438\u043d\u043a\u0438. \u0421\u043e\u0431\u0438\u0440\u0430\u0435\u043c \u0438\u0445:<\/p>\n<pre><code class=\"bash\">$ python manage.py collectstatic <\/code><\/pre>\n<p>  \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0430\u043f\u043a\u0443 admin, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043b\u043e\u0436\u0438\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 static \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 wsgi.<br \/>  \u0412 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 wsgi \u0441\u043e\u0437\u0434\u0430\u0451\u043c \u0444\u0430\u0439\u043b .htaccess:<\/p>\n<p>  <code>RewriteEngine On RewriteRule ^application\/media\/(.+)$ \/static\/media\/$1 [L]<\/code><\/p>\n<p>  \u041f\u0440\u0438\u0447\u0451\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a! application \u043d\u0443\u0436\u0435\u043d, \u0430 \u043d\u0435 \u043e\u0448\u0438\u0431\u043a\u0430.<br \/>  \u0421\u043e\u0437\u0434\u0430\u0451\u043c \u043f\u0430\u043f\u043a\u0443 media\/css\/ \u0432 \u043d\u0435\u0439 \u0444\u0430\u0439\u043b style.css \u0438 \u0432\u043d\u043e\u0441\u0438\u043c \u0432 \u043d\u0435\u0433\u043e \u0446\u0432\u0435\u0442 \u043d\u0430\u0448\u0435\u0433\u043e \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u044f.<\/p>\n<pre><code class=\"css\">h3 {     color: #6DA3BD; } <\/code><\/pre>\n<p>  \u041d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u0432 git:<\/p>\n<pre><code class=\"bash\">$ git add .  $ git add . $ git add .htaccess $ git commit -a -m 'media files' $ git push <\/code><\/pre>\n<p>  \u0417\u0430\u0445\u043e\u0434\u0438\u043c \u043d\u0430 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u0443. \u0422\u0435\u043a\u0441\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u043b \u0446\u0432\u0435\u0442.<br \/>  \u041a\u0430\u043a \u043e\u0431\u0435\u0449\u0430\u043b <a href=\"https:\/\/www.dropbox.com\/s\/76yemj21dmgb3ue\/habr.zip\">\u043f\u0440\u043e\u0435\u043a\u0442<\/a>. \t\t\t \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/177243\/\"> http:\/\/habrahabr.ru\/post\/177243\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u041f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0430 \u043e\u0431\u043b\u0430\u0447\u043d\u043e\u0433\u043e \u0445\u043e\u0441\u0442\u0438\u043d\u0433\u0430 \u0432 \u043d\u0430\u0448\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u0442\u044c \u043d\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f, \u0430 Red Hat \u043f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u0435\u0442 \u043d\u0430\u043c \u0435\u0449\u0451 \u0438 \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0432\u043a\u0443\u0441\u043d\u043e\u0441\u0442\u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e (\u0435\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f\u043c\u0438). <br \/>  \u0412\u044b \u043d\u0435 \u043f\u043b\u0430\u0442\u0438\u0442\u0435 \u0437\u0430 \u0445\u043e\u0441\u0442\u0438\u043d\u0433 \u0438 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435?<\/p>\n<ul>\n<li>1 Gb \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430<\/li>\n<li>\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c 3 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/li>\n<li>\u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443 php 5.3, Ruby 1.9, Node.js 0.6, Perl 5.10, python 2.6 (3.3), Zend Server 5.6 \u0438 \u044d\u0442\u043e \u0435\u0449\u0451 \u043d\u0435 \u043f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. <\/li>\n<\/ul>\n<p>  \u041d\u0443 \u0430 \u0435\u0441\u043b\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u044f\u0437\u044b\u043a\u0430 \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c Do-It-Yourself \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0433\u043e \u043a\u0430\u043a \u0434\u0443\u0448\u0435 \u0443\u0433\u043e\u0434\u043d\u043e.<\/p>\n<p>  \u041c\u044b \u0436\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0440\u0430\u0437\u0432\u0451\u0440\u0442\u044b\u0432\u0430\u043d\u0438\u0435 Django \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-177243","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/177243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=177243"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/177243\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=177243"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=177243"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=177243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}