SHARE
TWEET

Untitled

a guest Jul 19th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from django.contrib.postgres.indexes import GinIndex
  2. from django.contrib.auth import get_user_model
  3. from django.db import models
  4.  
  5.  
  6. User = get_user_model()
  7.  
  8.  
  9. class Blog(models.Model):
  10.     author = models.ForeignKey(
  11.         User,
  12.         on_delete=models.CASCADE
  13.     )
  14.     title = models.CharField(
  15.         verbose_name='Título',
  16.         max_length=255,
  17.         db_index=True,
  18.     )
  19.     content = models.TextField(
  20.         verbose_name='Contenido',
  21.         null=True,
  22.         blank=True
  23.     )
  24.     created_at = models.DateTimeField(
  25.         auto_now_add=True
  26.     )
  27.     updated_at = models.DateTimeField(
  28.         auto_now=True
  29.     )
  30.  
  31.     class Meta:
  32.         indexes = [
  33.             GinIndex(
  34.                 name='title_index',
  35.                 fields=['title'],
  36.                 opclasses=['varchar_pattern_ops']
  37.             )
  38.         ]
  39.         db_table = 'blog'
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top