from django.db import models
from users.models import User
from taggit.managers import TaggableManager
from django.db.models import Q
# Create your models here.

LANGUAGE_CHOICES = (
    ('HTML', 'HTML'),
    ('CSS', 'CSS'),
    ('JAVASCRIPT', 'JavaScript'),
    ('PYTHON', 'Python'),
)    



    
class CodeSnippet(models.Model):
    user = models.ForeignKey(to=User, on_delete=models.CASCADE, related_name='code_snippets', null=True)
    title = models.CharField(max_length=255)
    language = models.CharField(max_length=255, choices=LANGUAGE_CHOICES, default='')
    body = models.TextField(max_length=2000)
    tags = TaggableManager()
    def __str__(self):
        return self.title

def search_snippet_for_user(user, query):
    return user.code_snippet.filter(Q(title__icontains=query))


    


bfd072ececf18f62ba74b1131c27a0970700c238
<mask token>


class CodeSnippet(models.Model):
    <mask token>
    <mask token>
    <mask token>
    <mask token>
    <mask token>

    def __str__(self):
        return self.title


<mask token>

<mask token>


class CodeSnippet(models.Model):
    user = models.ForeignKey(to=User, on_delete=models.CASCADE,
        related_name='code_snippets', null=True)
    title = models.CharField(max_length=255)
    language = models.CharField(max_length=255, choices=LANGUAGE_CHOICES,
        default='')
    body = models.TextField(max_length=2000)
    tags = TaggableManager()

    def __str__(self):
        return self.title


<mask token>

<mask token>


class CodeSnippet(models.Model):
    user = models.ForeignKey(to=User, on_delete=models.CASCADE,
        related_name='code_snippets', null=True)
    title = models.CharField(max_length=255)
    language = models.CharField(max_length=255, choices=LANGUAGE_CHOICES,
        default='')
    body = models.TextField(max_length=2000)
    tags = TaggableManager()

    def __str__(self):
        return self.title


def search_snippet_for_user(user, query):
    return user.code_snippet.filter(Q(title__icontains=query))

<mask token>
LANGUAGE_CHOICES = ('HTML', 'HTML'), ('CSS', 'CSS'), ('JAVASCRIPT',
    'JavaScript'), ('PYTHON', 'Python')


class CodeSnippet(models.Model):
    user = models.ForeignKey(to=User, on_delete=models.CASCADE,
        related_name='code_snippets', null=True)
    title = models.CharField(max_length=255)
    language = models.CharField(max_length=255, choices=LANGUAGE_CHOICES,
        default='')
    body = models.TextField(max_length=2000)
    tags = TaggableManager()

    def __str__(self):
        return self.title


def search_snippet_for_user(user, query):
    return user.code_snippet.filter(Q(title__icontains=query))

from django.db import models
from users.models import User
from taggit.managers import TaggableManager
from django.db.models import Q
# Create your models here.

LANGUAGE_CHOICES = (
    ('HTML', 'HTML'),
    ('CSS', 'CSS'),
    ('JAVASCRIPT', 'JavaScript'),
    ('PYTHON', 'Python'),
)    



    
class CodeSnippet(models.Model):
    user = models.ForeignKey(to=User, on_delete=models.CASCADE, related_name='code_snippets', null=True)
    title = models.CharField(max_length=255)
    language = models.CharField(max_length=255, choices=LANGUAGE_CHOICES, default='')
    body = models.TextField(max_length=2000)
    tags = TaggableManager()
    def __str__(self):
        return self.title

def search_snippet_for_user(user, query):
    return user.code_snippet.filter(Q(title__icontains=query))


    

