Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django 1.8: How do I use my first 3rd Party Fork with my current project?

I'm still very new to development...

I would like to simplify django-friendship and add some different functionality. I've forked it on GitHub. I'm not sure what to do next.

Where should the local copy of my django-friendship repo go? Should I integrate it into my current Django project as an app, or set it up as a separate project? In which case, how do I set my main Django project to use it as an app while developing it?

Any guidance or other resources I can learn from here would be much appreciated.

Thanks!

like image 965
StringsOnFire Avatar asked Aug 10 '15 10:08

StringsOnFire


People also ask

How will you import views in Django?

from django.shortcuts import render # Create your views here. Find it and open it, and replace the content with this: members/views.py : from django.shortcuts import render from django.http import HttpResponse def index(request): return HttpResponse("Hello world!")

What is difference between project and app in Django?

A project refers to the entire application and all its parts. An app refers to a submodule of the project. It's self-sufficient and not intertwined with the other apps in the project such that, in theory, you could pick it up and plop it down into another project without any modification.


1 Answers

There's a few options open to you:

Install directly from Github

Add the following (replace with your forked repository) to a requirements.txt file or install directly with pip install:

git+git://github.com/revsys/django-friendship.git#egg=django-friendship

This will download a copy of your repository into your python environment. If you make changes to the repository however, you'll need to reinstall this every time you push changes.

Download a local copy and install

This method is much cleaner:

// Clone the repository locally
git clone https://github.com/revsys/django-friendship.git

// cd into the project folder
cd django-friendship

// Install the package into your python environment
// The `-e` tells pip this package is editable
pip install -e .

The project is now linked directly. You can now work on the forked repository locally and the changes will be available to your app straight away.

In your requirements.txt file you'll want to add the following for deployment later:

git+git://github.com/revsys/django-friendship.git#egg=django-friendship

Take a look at the docs for pip for more information on dependency management.

like image 123
Ashley 'CptLemming' Wilson Avatar answered Oct 09 '22 03:10

Ashley 'CptLemming' Wilson