1

I am using Django as development framework for my current Project (say Project A).

I want to create a new application (say Project B) that has different views as Project A. But this new Project B is going to use most of the existing backend modules and models from current Project A.

Such that my Current Project (Project A) is hosted on URL http://www.site-one.com and and New Project B will be hosted on http://www.site-two.com. With respect to this, I have one doubt and a question that I want to ask:

Doubt: Is my choice of using "Django sites framework" for this is correct?

Question: Is there any way to keep two Django sites (A and B) in different Git Repo and still access the models and other modules from Current Site A?

lalit
  • 3,283
  • 2
  • 19
  • 26

1 Answers1

1

I would suggest for shared functionality create separate django apps with a structure resembling something like the following. (I'm assuming you've got your projects in virtualenvs)

appname/
  __init__.py
  models.py
  views.py
  templates/
    base.html

Store this app in a git repository of it's own.

then inside the requirements.txt for each of your projects this functionality is needed in add a line like the following, assuming you're using bitbucket:

-e git+https://yourusername@bitbucket.org/appname/appname.git#egg=appname

install

pip install -r requirements.txt

then in your settings.py add myappname to your INSTALLED_APPLICATIONS

jmoggee
  • 143
  • 1
  • 9
  • Unfortunately repo URLs are NOT exposed and even if we go with approach of cloning one repo in other. I need to put stuff into .gitignore to avoid problem and which will be essentially a hack. Is there any way out in Django, which let us maintain both separately? – lalit Dec 11 '12 at 10:10
  • 1
    You could also symlink the module directory into `lib/python2.x/site-packages` of your virtualenv. – jmoggee Dec 11 '12 at 11:50
  • Yeah, This looks relatively better approach. Only down-side is, I won't be able to run both using same manage.py script, which I was hoping to happen with use of django sites framework. But Thanks a lot for this, I'll try It. – lalit Dec 11 '12 at 13:57