Getting the Django tagging hooked to Basie is easy – just run `easy-install Django-tagging`. After you go through the hassle of adding the .egg to the virtual environment’s various paths, things are pretty straightforward: add ‘tagging’ to INSTALLED_APPS in settings.py, and then run `Django syncdb`.
This will create two tables – TAG and TAGGEDITEM. TAG is a simple table; besides the primary key, it just has a name field. This makes it easy to rename tags. TAGGEDITEM is used to maintain the many-to-many relationship between objects and tags. Its columns hold the foreign key to the TAG table, the tagged object’s primary key, and the type of the tagged object.
What Django tagging brings into Basie?
– Modification of tags associated with objects
If you want, you can add tagging fields – TagField property to a model class. This acts as a CharField in the admin interface but maintains the tag relationships behind the scene. TagField comes with default behavior for splitting a string into tag names (dealing with spaces, commas, quotation marks, etc.).
– Generic views and other things
tagging.views.tagged_object The list is a view for displaying a list of objects that have a particular tag. Django-tagging will manage the list of associated tags, all you need to provide is the template and the model class.
Some handy template tags are also ready for use.
1. tagged_objects performs the same function as the previously mentioned general view – retrieves all objects of a particular type* that have the specified tag.
2. tags_for_object extracts all tags associated with the specified object
3. tags_for_model extracts all the tags related to a specific model class.
Issues everyone faces with Django tagging
This tool sounds great, and it makes you think that nothing can go wrong. Well, it can work as with any other tool or software. But every individual that gets to work with Django tagging and Basie will encounter some obstacles that are quite common.
A huge issue with Django tagging is its inability to retrieve all objects that are found within the tag. This tool only retrieves objects of one type, and that becomes an issue that prevents the ticket system from operating normally. We could create a list of solutions we came up to negate this problem, but none of them are both elegant and efficient. The only reasonable solution to this problem is to write new template tags and queries.
Another obstacle that baffled us is connected to the TAGGEDITEM table that Django introduces. The problem is that it doesn’t have the concept of ticket visibility and separate projects within the Basie. The table pulls all objects connected to the request, and that is an issue as it pulls them from all projects that are located within the Basie. The solution for this one is to write search by tag template and implement it into the software (this move has its disadvantages we will discuss in another article).