ok this is a little bit complex problem (at least for me) let's supose that I've a model like this one:
class News(models.Model): name = CharField(max_length=200, unique=True) body = TextField() usually I put a slug field like this one slug = CharField(max_length=200, unique=True, blank=True) and instead of using models.Model as parent class I use this one: class UniqueSlugFromName(models.Model): class Meta: abstract = True def save(self): """Auto-populate an empty slug field from the MyModel name and if it conflicts with an existing slug then append a number and try saving again. name = original slug = the slug """ if not self.slug: self.slug = slugify(self.name) # Where self.name is the field used for 'pre-populate from' while True: try: super(UniqueSlugFromName, self).save() # Assuming the IntegrityError is due to a slug fight except IntegrityError: match_obj = re.match(r'^(.*)-(\d+)$', self.slug) if match_obj: next_int = int(match_obj.group(2)) + 1 self.slug = match_obj.group(1) + '-' + str(next_int) else: self.slug += '-2' else: break so the Model class is now something like this: class News(models.Model): name = CharField(max_length=200, unique=True) body = TextField() slug = CharField(max_length=200, unique=True, blank=True) in this way every slug field is populated with the slugify version of the name field. now I need to translate the 2 fields name and body so instead of the above class I change this like this one class News(models.Model): slug = CharField(max_length=200, unique=True, blank=True) class Translation(multilingual.Translation): name = CharField(max_length=200) body = TextField() but now the slug field is populated with the value of "none" I think because the value of the fields is not yet in the database moreover I should need translatable slug too so I can request the page with all its urls for example /news/hello-I-am-a-news/ -> content in english /news/sono-una-news/ -> content in italian is there a way to solve this problem ? cheers Marco --~--~---------~--~----~------------~-------~--~----~ 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---