I
I
Ilya2015-11-23 15:40:32
Django
Ilya, 2015-11-23 15:40:32

How to display the model correctly?

I'm sitting dumb, I made a model.

class TitleSite(models.Model):
    name = models.CharField(verbose_name = u'Название сайта:',max_length=30)
    def __unicode__(self):
        return self.name

I can't figure out how to correctly display this model in html.
Vyuhu did, but does not work.
class NameSite(DetailView):
    name = TitleSite.objects.all()

and url
url(r'^$', NameSite.as_view(), name='index'),
in html I insert only this.
{{ NameSite }}
It seems like an elementary thing, but I'm dumb. Please tell me how to get it right.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2015-11-23
@sim3x

https://docs.djangoproject.com/en/1.8/ref/class-ba...

class NameSite(DetailView):
    model = TitleSite

Z
zigen, 2015-11-23
@zigen

{{ object.name }}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question