Example App¶

The example app demonstrates how you can use django-generic-m2m to create “tags” between different types of models.

It uses several apps from django basic apps to provide some various content models. Then it uses django-completion to allow users to “autocomplete” various objects in the database, making it easy for users to tag one piece of content with other content from the database.

Below is a screen-shot of a user creating a new blog post. The “relationships” text input does autocompletion making it easy to add “tags” to various models. When the form is submitted, those “tags” become stored using the generic-m2m API.

How to run the example app¶ The example app is bundled with django-generic-m2m, but running it requires several external dependencies. For this reason, I’d recommend running it in its own dedicated virtualenv: virtualenv --no-site-packages genericm2m-example cd genericm2m-example source bin/activate Now install the latest version of django-generic-m2m from github: pip install -e git+git://github.com/coleifer/django-generic-m2m.git#egg=genericm2m You should see a few lines of text followed by “Successfully installed genericm2m”. Now you’ll need to install the example app dependencies: pip install -r src/genericm2m/example/requirements.txt This will install the 1.3.X branch of django, django-basic-apps, and django-completion. Once these are installed you are ready to run the example: cd src/genericm2m/example ./manage.py runserver Now navigate to http://127.0.0.1:8000/ in your browser and you will see the example app’s homepage: If you want to see examples of “model tagging”, browse the photos or blogs. There is a section titled “Related to” with links to whatever the object was tagged with: I’d encourage you to click around, create a few posts or photos and try tagging them with various models.