willhardy/django-seo — Issue #30: Using dajngo-seo with Model
Author: nuno-iglesias
Created: 2012-01-24 16:39:58+00:00
State: open

I'm trying to add some automatic seo tags to model instances.
I have managed to add seo tag as inlines to my model instances, so i can edit the individual data for each instance of my model.

What i really need is that seo tags ar automátically generated from the infor of my model.
Let's say my model is this:

class Promotion(models.Model):
name = models.CharField("Nombre", max_length=200)
content = models.TextField("Contenido", max_length=2000,blank=False)

And this is my Seo class

class MyMetadata(seo.Metadata):
title =	seo.Tag(head = True, max_length = 68, populate_from = populate_title)
description = seo.MetaTag(head=True,max_length=155)
keywords = seo.KeywordTag()
heading = seo.Tag(name="h1")

class Meta:
verbose_name = "Metadata general"
seo_models =('web.Promotion',)

and i have defined a the method 'populate_title' as :

def populate_title(metadata, model_instance = None, **kwargs):
if model_instance:
return "PROMOCION ACUTOCREADO EL TITLE "
else:
return '321'

Now when i create a new "promotion" object and access the view , what i have in the title is

"123"

I suppouse that "model_instance" should give me access to the instance i'm wroking with.
can anybody show me what should i do.
Thanks in advance.