diff --git a/backend/randpic/models.py b/backend/randpic/models.py index 9132bfe..d78ec7d 100644 --- a/backend/randpic/models.py +++ b/backend/randpic/models.py @@ -5,7 +5,7 @@ class Picture(models.Model): name = models.CharField(max_length=100) description = models.TextField() author = models.CharField(max_length=100) + author_url=models.URLField() original_url = models.URLField() - def __str__(self): - return self.title \ No newline at end of file + return self.name \ No newline at end of file diff --git a/backend/randpic/random_picture.py b/backend/randpic/random_picture.py index 84955ef..fd45586 100644 --- a/backend/randpic/random_picture.py +++ b/backend/randpic/random_picture.py @@ -1,5 +1,8 @@ import json import random +from .models import Picture + +pics=Picture.objects.order_by("?") def get_random_picture(): with open("./jsons/pics.json") as f: diff --git a/backend/tianyi/settings.py b/backend/tianyi/settings.py index dad57ff..448271d 100644 --- a/backend/tianyi/settings.py +++ b/backend/tianyi/settings.py @@ -31,6 +31,7 @@ ALLOWED_HOSTS = [] # Application definition INSTALLED_APPS = [ + 'randpic.apps.RandpicConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes',