from django.db import models
from django.urls import reverse
from django.contrib.auth.models import User

# Create your models here.
class Post(models.Model):
    title=models.CharField(max_length=200)
    author=models.ForeignKey('auth.User', on_delete=models.CASCADE,)
    body = models.TextField()

    def __str__(self):
        return self.title
    
    def get_absolute_url(self):
        return reverse('post_detail', args=[str(self.id)])



class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    #Some property
    country = models.CharField(max_length=150)

    def __str__(self):
        return self.user.username
