Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to import a Django app from Git into a project

Tags:

git

django

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?

like image 518
askvictor Avatar asked Oct 07 '22 15:10

askvictor


2 Answers

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.

like image 107
miki725 Avatar answered Oct 13 '22 12:10

miki725


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
like image 32
djd Avatar answered Oct 13 '22 11:10

djd