Monday, May 2, 2016

Re: Help with moving a development project to production

On Mon, May 02, 2016 at 03:07:57PM -0700, Bruce Whealton wrote:
> I have been developing a django project and app on a Ubuntu
> system. My production system is Centos 6 based ( I think, not Centos 7).
> First off, what should I commit to the repo? I setup a virtualenv using
> virtualenvwrapper. This included a bin directory, include directory and
> lib directory -
> do I need these in the repo? Or should they be created on the production
> server using virtualenv?

No, typically virtualenv stuff(bin/lib) are unique per OS variant(Ubuntu
12.04, CentOS 6, etc). You won't check that stuff into the repo.
However you do want a list of all your python dependencies and their
versions. You can do that in your development repo by running:

pip freeze -l > requirements.txt

> What if the production environment didn't have a virtualenv? I guess that
> is somewhat of a hypothetical question.

virtualenv is just a python package so you should be able to install it.

> If during development, I created various migrations and even added data to
> the database. I am using Postgresql for both
> development and production. If I exported the database, with statements to
> create all the tables and then populate them with
> data and then I import this to the database server used for production,
> does this create a problem? I was told to commit
> the migrations and then run/make them on the production server. Is that
> only necessary if I did not export
> everything and then import it all? Or should I avoid importing the
> database with structure and data,
> instead just running the migrations?
>
> If I were moving from one server to another (both production servers ) I
> wouldn't want to lose my data. It seems
> like I would lose it all if I ran all the migrations.

The migrations that get applied are recorded in a table in your database
so if you are exporting the database in dev and importing in production,
all the migrations will already be there along with the record of them
being applied.

> Lastly, I heard that django likes to be in the top level folder for a
> domain - this was in a shared python hosting
> environment that had a one click installer from the control panel. I also
> have access to a vps server with root shell access.

Nah, you can serve Django from just about anywhere. The code can live
anywhere in your filesystem and it can be served from any URL root
path(not just '/'). It's just a matter of configuring things in
settings.py.

> It is Centos based with support for python and php. How do I setup
> wsgi with apache? Do I need to create a
> vhost file? In that case, I'd use a subdomain for one of my domains.
> Thanks in advance for any help,

Here's the Django documentation for Apache/wsgi. It's pretty good.

https://docs.djangoproject.com/en/1.9/howto/deployment/wsgi/modwsgi/

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/20160502225515.GB32217%40fattuba.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment