Hi Issuer Follow to part 3 - 4 and check docs for some thing else around you need
https://docs.djangoproject.com/en/2.2/ref/templates/language/ https://docs.djangoproject.com/en/2.2/intro/tutorial04/ On Sat, Nov 16, 2019, 16:40 'Amitesh Sahay' via Django users < [email protected]> wrote: > Hello All, > > I have created the two models to create post on desired topic, as well as > to get the comments from the visitors. But, I am not able to figure out, > how to connect that model to my HTML page. > > I know how to create a static HTML pages for each topic,and write page > content in <p></p> tags. which I have been thinking to do until now, but it > seems to be a time taking and non-productive way. So, now I would like to > write posts in my database model which I have registered in admin.py. > > Any idea, how can I achieve this, as this would be a like generating > dynamic HTML pages based on models. > > I am not sure if I was able to explain my requirements. May be as I am not > getting right words to express them. Please ask me questions if any > confusion, I will try to answer them. > > Below is my models.py > > from django.db import models > from django.utils import timezone > from django.contrib.auth.models import User > > > class Post(models.Model): > STATUS_CHOICES = ( > ('draft', 'Draft'), > ('published', 'Published'), > ) > title = models.CharField(max_length=250) > slug = models.SlugField(max_length=250, unique_for_date='publish') > author = models.ForeignKey(User, related_name='blog_posts', > on_delete=models.CASCADE) > body = models.TextField() > publish = models.DateTimeField(default=timezone.now) > created = models.DateTimeField(auto_now_add=True) > updated = models.DateTimeField(auto_now=True) > status = models.CharField(max_length=10, choices=STATUS_CHOICES, > default='draft') > > class Meta: > ordering = ('-publish',) > > def __str__(self): > return self.title > > > class Comment(models.Model): > post = models.ForeignKey(Post, related_name='comments', > on_delete=models.CASCADE) > name = models.CharField(max_length=80) > email = models.EmailField() > body = models.TextField() > created = models.DateTimeField(auto_now_add=True) > updated = models.DateTimeField(auto_now=True) > active = models.BooleanField(default=True) > > class Meta: > ordering = ('created',) > > def __str__(self): > return self.email > > Regards, > Amitesh > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/1799372727.1057468.1573897086523%40mail.yahoo.com > <https://groups.google.com/d/msgid/django-users/1799372727.1057468.1573897086523%40mail.yahoo.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAP5HUWr7Tt14R-o8Jz0_mAZYV2KeDm5CkwBfqQBm9T8PkjaC%3Dw%40mail.gmail.com.

