মডিউল ১০ : ব্লগ প্রজেক্ট পার্ট ২
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class RegistrationForm(UserCreationForm):
first_name = forms.CharField(widget=forms.TextInput(attrs={'id' : 'required'}))
last_name = forms.CharField(widget=forms.TextInput(attrs={'id' : 'required'}))
class Meta:
model = User
fields = ['username', 'first_name', 'last_name', 'email']from django.db import models
from categories.models import Category
from django.contrib.auth.models import User
# Create your models here.
class Post(models.Model):
title = models.CharField(max_length=50)
content = models.TextField()
category = models.ManyToManyField(Category) # ekta post multiple categorir moddhe thakte pare abar ekta categorir moddhe multiple post thakte pare
author = models.ForeignKey(User, on_delete=models.CASCADE)
def __str__(self):
return self.title Last updated