Merge pull request 'fix_snippets' (#1) from fix_snippets into devel

Reviewed-on: LibertaCasa/webdev#1
This commit is contained in:
Pratyush Desai 2022-01-08 05:31:38 +01:00
commit 7aecc21528
5 changed files with 6 additions and 5 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
venv venv
.vscode .vscode
__pycache__ __pycache__
db.sqlite3 db.sqlite3
website/db.sqlite3

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -21,7 +21,7 @@ class Snippet(models.Model):
language = models.CharField(choices=LANGUAGE_CHOICES, default='python', max_length=100) language = models.CharField(choices=LANGUAGE_CHOICES, default='python', max_length=100)
style = models.CharField(choices=STYLE_CHOICES, default='friendly', max_length=100) style = models.CharField(choices=STYLE_CHOICES, default='friendly', max_length=100)
owner = models.ForeignKey('auth.user', related_name='snippets', on_delete=models.CASCADE) owner = models.ForeignKey('auth.user', related_name='snippets', on_delete=models.CASCADE)
highlighted = models.TextField highlighted = models.TextField()
class Meta: class Meta:
ordering = ['created'] ordering = ['created']

View File

@ -2,14 +2,13 @@ from django.contrib.auth.models import User
from .models import Snippet from .models import Snippet
from .serializers import SnippetSerializer, UserSerializer from .serializers import SnippetSerializer, UserSerializer
from .permissions import IsOwnerOrReadOnly from snippets.permissions import IsOwnerOrReadOnly
from rest_framework import permissions, renderers from rest_framework import permissions, renderers
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework.reverse import reverse from rest_framework.reverse import reverse
from rest_framework import viewsets from rest_framework import viewsets
from rest_framework.decorators import action from rest_framework.decorators import action
from rest_framework.response import Response from rest_framework.response import Response
from rest_framework import permissions
class SnippetViewSet(viewsets.ModelViewSet): class SnippetViewSet(viewsets.ModelViewSet):
""" """