before save data handling

2009-02-11 Thread danfreak
Hey guys, I'm quite new to Django and python ;o) My problem is the following: I have the following many to many relations Example DB schema class Country(models.Model): name = models.CharField(max_length=200)

Generic foreignKey model: Category

2009-02-11 Thread danfreak
Hey guys, I was wondering how to create a let's call it "GenericCategory" model. Given that News, Products, etc, often belongs to a Category, why have tons of tables (news_categories, products_categories) etc The "GenericCategory" model table structure should be like: - id - foreign_model_name

Re: Generic foreignKey model: Category

2009-02-11 Thread danfreak
Cheers Jake, given the code: -- from django.db import models from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic class CategoryItem(models.Model): name = models.CharField(max_length=200) content_type = models.ForeignKey(C

Re: before save data handling

2009-02-11 Thread danfreak
any idea ;o) sorry if I ask again! Dan --~--~-~--~~~---~--~~ 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 em

Re: Generic foreignKey model: Category

2009-02-11 Thread danfreak
Yep, I'm a bginner with Django, but translating it into CakePHP (based on Rails) I would like to define a kind of relation where, given the: - Foreign key of let's say the News.id - the Foreign_model_name (i.e News) I get the News.category of a specific item While just retriving the News Categ

beforeSave callback: implementation suggestion

2009-02-11 Thread danfreak
Hey guys does anybody can drive me to a code example of a kinda beforeSave callback, to perform logic before saving Model data, or Related Models data? dan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django user

Re: beforeSave callback: implementation suggestion

2009-02-12 Thread danfreak
I think I got the answer: read here: http://www.martin-geber.com/thought/2007/10/29/django-signals-vs-custom-save-method/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group,

Re: Generic foreignKey model: Category

2009-02-12 Thread danfreak
Right, I created my Genric Category model using : - from django.db import models from django.contrib.auth.models import User from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes import generic from django import forms