Archives
Trending
Support
Login
clear text
XML
Django
JavaScript
MATLAB
C
C++
C#
Python
SQL
Shell
Bash
Markdown
YAML
JSON
HTML
CSS
PHP
Java
Ruby
Go
Rust
Swift
Kotlin
Arduino
TypeScript
Perl
Autohotkey
Lua
SQF
R
Scala
Haskell
Groovy
Dart
Clojure
VB.NET
Objective-C
PowerShell
Bash
CoffeeScript
Verilog
from django.core.validators import MinLengthValidator, MinValueValidator, MaxValueValidator, MaxLengthValidator from django.db import models class Author(models.Model): full_name = models.CharField(max_length=100, validators=[MinLengthValidator(3)]) email = models.EmailField(unique=True) is_banned = models.BooleanField(default=False) birth_year = models.PositiveIntegerField(validators=[MinValueValidator(1900), MaxValueValidator(2005)]) website = models.URLField(null=True) class Article(models.Model): CATEGORY_CHOICES = ( ("Technology", "Technology"), ("Science", "Science"), ("Education", "Education") ) title = models.CharField(max_length=200, validators=[MinLengthValidator(5)]) content = models.TextField(validators=[MinLengthValidator(10)]) category = models.CharField(max_length=10, choices=CATEGORY_CHOICES, default="Technology",) authors = models.ManyToManyField("Author") published_on = models.DateTimeField(auto_now_add=True, editable=False,) # auto_now_add !!! class Review(models.Model): content = models.TextField(validators=[MinLengthValidator(10)]) rating = models.FloatField(validators=[MinValueValidator(1.0), MaxValueValidator(5.0)]) author = models.ForeignKey('Author', on_delete=models.CASCADE) article = models.ForeignKey('Article', on_delete=models.CASCADE) published_on = models.DateTimeField(auto_now_add=True, editable=False)
Mark as private (unlisted)
for 30 minutes
for 6 hours
for 1 day
for 1 week
for 1 month
for 1 year
everlasting (like CCCP)