I'm a newbie on Django my self but maybe this is what you are looking for:
class Category(models.Model): code = models.CharField(maxlength=200, unique=True) products = models.ManyToManyField('Product') class Product(models.Model): parent = models.ForeignKey('Post') code = models.CharField(maxlength=200, unique=True) I've also read that you can specify signals for most operations on a model (Like when a model is inserted, updated or deleted from the database) though I can't find the URL right now. There's some mention of it here: http://www.djangoproject.com/documentation/db-api/ On Sep 16, 9:54 pm, "Paul Dorman" <[EMAIL PROTECTED]> wrote: > Hi all, > > definite newbie here. I'd like to implement a category type system in > Django. I've looked in the cookbook and Googled a bit, but to no avail. What > I'm after should be pretty simple: a directed graph for categories, where > objects and perhaps categories can be a member of one or more categories. > For example, a 'server' is an 'infrastructure component' (for the techies), > as well as an 'asset' (for the financial types). In my grand scheme when an > object is associated with one or more categories (one is the minimum), the > application will execute method calls stored (with optional parameters) in > the database (serialized as JSON or XML). With the 'server' example, it > might be that being in the 'infrastructure component' category triggers an > email to be sent to the system administrator, and the existence in the > 'asset' category would trigger an automated update to the asset register. > The methods are stored according to the standard CRUD set of operations, so > that a user can create a new category in the view, and then specify actions > which occur when an object is created, read, updated, or deleted (provided > by the application itself). Actions are triggered for both objects (the > things that are categorized) and for child categories (so for example it may > be that a parent category can be locked in such a way as to prevent any more > child categories from being added). > > Note that categories are purely containers with generic actions (for crud > operations on objects in the category) and distinct from objects, which I > imagine would have a category_id FK. And note also that my objects are all > using the same model, with the bulk of data serialized as XML. > > Has anyone out there in Djangoland done something like this? The graph's the > thing - I'm happy to deal with the CRUD triggers myself. If there's a model > out there that would be a good starting point that would be great. > > One additional thing I'm wondering about is how Django can work with stored > procedures. For example, it might be more efficient if the application can > ask the database for the methods to run when an object is created, and > have the database return the methods for not only the object's bottom-level > category, but for all parent categories as well. > > P.S. > > Congratulations on the great sprint! > > P.P.S. I hope I haven't just embarrassed myself with my naïveté. > > -- > "Science fiction writers are the only ones who care about the future" > -- Kurt Vonnegut --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---