askvictor
askvictor

Reputation: 3819

How to import a Django app from Git into a project

I want to include a Django app into the project I'm working on. The app is hosted on Github ( https://github.com/lmorchard/django-badger ). As well as the app's directory containing the goodies, there are some files in the root - README, LICENCE, TODO and setup.py. If I clone the app into my project's root directory, the app folder will be in the correct place, but those root files will be in my project's root. How can I add the app while still tracking the upstream code in Github?

Upvotes: 6

Views: 7150

Answers (3)

arulmr
arulmr

Reputation: 8836

Clone the repository from github using git://github.com/lmorchard/django-badger.git. Then open the cloned folder in terminal. Install the app using the command sudo python setup.py install. This will work good. If you want to have the app included in your project, create a folder named badger(or anything you wish) and copy the installed app from dist-packages to created folder.

Upvotes: 0

djd
djd

Reputation: 1001

U can install it by running

python setup.py 

or through pip

sudo pip install -e git+https://github.com/lmorchard/django-badger#egg=django-badger

Upvotes: 1

miki725
miki725

Reputation: 27861

I had a similar issue where I was working on two independent projects where both were in a repo, and one of them used the other as an app:

  • Create a virtualenv and install all dependencies for both projects. I usually like to have a virtualenv for each project/repo but in this case you need one env which can execute Python from both repos.
  • Clone both repos to independent location. Do not clone the depending app inside the other project. Your file-structure then might look like this (assuming Django 1.3 project layout):

    project/
      manage.py
      project/
        __init__.py
        settings.py
        ...
      ...
    
    app/
      README
      ...
      app/
        __init__.py
        models.py
        ...
    
  • And final step is to create a symlink (or shortcut on Windows) from the app directory which has __init__.py in it to the project path.

    $ ln -s /abs/path/to/app/app /abs/path/to/project/
    
  • Now you can use the virtualenv to run the project!

The final result is that you have two independent repos however one of projects is using the other project without directly copying the code, hence allowing you to maintain two repos.

Upvotes: 5

Related Questions