I deployed my Django project to Heroku. Now, I want to add another app to my existing project. How can I do it in a way that a new database is not created- I mean my existing database should not get deleted?
2 Answers
You can just run heroku run python manage.py syncdb after pushing your new app with model definitions. This won't delete your database. Consider installing South though.
-
sorry I am little confused here. So if I push my app from git to heroku won't it override the existing files? Jul 30, 2013 at 16:16
-
No. It won't, in the same way that pushing to github doesn't override your files.– user1428660Jul 30, 2013 at 16:18
-
Ok. Which one would you suggest? Downloading the existing source code and adding the extra files and pushing it to heroku again or just do the way you told me to? Sorry, if I these are basic questions. I fairly new to django deployment :) Jul 30, 2013 at 16:20
-
So do you not have the original repository on your computer? What have you made changes to? Are you not editing the original codebase? This will all be pointless if you don't know how to use git. You need to understand how git works before you can use Heroku.– user1428660Jul 30, 2013 at 17:51
-
Yes, I do not have the original repository. That is the problem. I was wondering if I could do git clone? Jul 30, 2013 at 18:18
Using PyPI
If the app you want to install is available on the Python Package Index, you can add the name of the add and the version you want to use in your requirements.txt file like:
app_name==1.2.3
Then, in your project/settings.py file, add the app_name as a string to the list of INSTALLED_APPS. For instance, if INSTALLED_APPS looks like this:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
then adding the new app will make it:
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'package_name',
)
Using git
You can follow the same steps as above, but instead of adding app_name==1.2.3, you add:
git+git://github.com/owner_name/app_name#egg=app_name
replacing owner_name and app_name appropriately. This clones the repository that you point to, so be sure that it's either public or that you have ssh access if it's private.