willhardy / django-seo

Provides a set of tools for managing Search Engine Optimisation (SEO) for Django sites.
BSD 3-Clause "New" or "Revised" License
251 stars 117 forks source link

Using dajngo-seo with Model #30

Closed nuno-iglesias closed 12 years ago

nuno-iglesias commented 12 years ago

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.

nuno-iglesias commented 12 years ago

Ok , it seems another time the problem was related with not having proprely sync my db after a few changes.... This seo framework is awesome.