0

my model is like:

class Modeloxy(models.Model): ... ... slug = models.slug() class mymodel(models.Model): marca = ... ... modelo = models.ForeignKey(Modeloxy) def get_absolute_url(self): return '/%s/%s/%s' % (self.marca,self.modelo__slug,self.pk) 

So, i can't get the absolute url usin self.modelo__slug.... how i will do that?

thanks guys

1

1 Answer 1

1

It would be self.modelo.slug

The double underscore syntax was created to solve the problem of not being able to use dot syntax as a keyword argument function(keyword_arg=Foo) and unrelated to python: you're literally looking for a variable named modelo__slug in your case.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.