updated models

This commit is contained in:
ClF3 2024-04-30 09:05:28 +08:00
parent e69bb3fce2
commit 70fafd3ed6
3 changed files with 6 additions and 2 deletions

View File

@ -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
return self.name

View File

@ -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:

View File

@ -31,6 +31,7 @@ ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'randpic.apps.RandpicConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',