Home » Odeon Blogs » Michelle Chan »

Setting Up Dev Repo

Setting Up Dev Repo

These are the steps how Odeon Developers usually get started with the Django Projects. 

1. Firstly, we have to add the ssh public key to server and git clone into local machine.

2. There is local_settings.sample file in /proj/ directory, copy the contents and save as local_settings.py

Once we have created local_settings.py, it overrode the settings in the settings.py. The local instance of Django will read the database settings in local_settings.py and the remote server will use settings.py

  • Need DEBUG=True for the local Django development server to serve static/media files.
  • Copy the DATABASE from settings.py or
  1. DATABASES = {
  2. 'default': {
  3. 'ENGINE': 'django.db.backends.postgresql_psycopg2',
  4. 'NAME': 'db_name',
  5. 'USER': 'username',
  6. 'PASSWORD': 'password',
  7. 'HOST': '',
  8. }
  9. }
As we are using PostgreSQL, we need to install psycopg2 for the interface between Python and PostgreSQL database.
If we don't have psycopg2, we will have errors such as "No module named Psycopy2" or "Cannot import name utils", etc.


3. Create a local database with the same database name and username from settings.pyHow? Password doesn't matter. =)


4. Run the shell scripts ./fetch_server_db.sh and ./fetch_server_files.sh in the main directory.

fetch_server_db.sh will download all the content from the remote postgresql database, dumps into your local machine and updates all the contents in your local postgresql database.

fetch_server_files.sh will grab all the "media" files from the remote website and sync them to your local "public/media" directory.


5. Lastly, run ./manage.py collectstatic to move all the static files from the django apps to the public folder indicated in settings.py


Finally, we are done!

Enjoy...


Categories: Django git postgresql


Tagged as: django



Leave a Comment :

(required)


(required)




(required)








Page generated in: 0.30s