Hi, Michael--
On Sun, Aug 31, 2014 at 10:28 PM, Michael Carey <
mpc.tab4@gmail.com> wrote:
> That is assuming that you just upload the files?
Your doubt is justified. Just uploading the files is a bit of an
oversimplification. It would help if you gave some specifics about the
directory structure you're working with.
However, I can make a few general recommendations ...
1. Are you using version control? If not, you should - and it solves
part of your problem. I know it may seem like overkill to go through
all the steps of setting up a repo for just a little app, but if you
are at all serious about this Django development thing it will save
you a lot of work in the long run. I think these days Git is the most
popular version control system, but Mercurial (AKA hg) and Bazaar (AKA
bzr) are also very good (and both programmed in Python, yay!).
There is a good, concise tutorial online about setting up a Django
project to work with Git. I don't have a link for it, but I found it
very easily by Googling something like "Django version control."
So, assuming you have shell access (e.g., can log in via SSH) on your
web server, you would follow a procedure like this:
git push
DEV MACHINE ------------------> GIT REPOSITORY
git pull
SERVER <------------------ GIT REPOSITORY
That's *very* simplified. In reality, if you are trying to do
professional development, you need to at least have a test environment
online, so that you always test the code in conditions that are as
nearly identical as possible to your production server. But the above
will do if you're just experimenting. And if you don't have shell
access, someone else will have to help you with that.
Now, what files do you put under version control?
Let's say you follow the typical advice, and have a virtual
environment, with any Django projects/sites in separate directories.
For example, I'm using a setup like this (on Linux):
/srv/http/
salixmedia.com/test/
pyenv/
[virtual environment with Django and other
required libraries]
my_site/
admin.py
settings.py
local_settings.py
models.py
wsgi.py
....
my_app/
admin.py
models.py
views.py
....
In this setup, all of 'my_app' would go under version control.
Likewise, all of 'my_site' *except* for local_settings.py - or
whichever file contains your secret keys and database password. You
need to guard that information closely, so it should never go into
version control.
Some people think you should put the virtual env (my 'pyenv'
directory) under version control too; I say no. You do want to ensure
that you have all the same libraries installed everywhere, but there's
another way to do that:
$ pip freeze > requirements.txt # on development box
$ pip install -r requirements.txt # on server
The requirements file lists all your installed packages, including
their versions. 'requirements.txt' should be under version control, so
you will have it on your server when you check out the code there. I'm
sure this approach is not totally foolproof, but I believe it is
fairly reliable, and will save you from cluttering your repo with a
great deal of third-party code that you will probably never modify.
Okay, so that takes care of all your python code and config files. You
also have to deal with your database. And honestly, I'm pretty new at
Django myself, and haven't completed figured out this aspect. When you
are setting up a site, you need to use commands such as
python manage.py syncdb
and
python manage.py migrate <app_name>
If you're not familiar with those, I'd suggest you go through the
online documentation. These commands take care of your schemas (to
oversimplify, those represent your models in the database), but they
don't, by default, handle any site content that you may have created.
That's the part I'm not too sure about, but I'm sure others on this
list will have good advice.
Hope that helps a bit.
--
Matt Gushee
--
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
http://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CABrD0eeQoqMcMAiqmmyMgwxMbvZ01rj%2BC%2BkAzepjX%3D8EYDMZxg%40mail.gmail.com.
For more options, visit
https://groups.google.com/d/optout.