· 7 years ago · Oct 15, 2018, 01:32 PM
1from django.db import models
2from django.conf import settings
3from .helper import secret
4# Create your models here.
5
6
7class Pizza(models.Model):
8 name = models.CharField(max_length=12)
9 price = models.IntegerField()
10 description = models.TextField(null=True)
11 secretKey = models.CharField(max_length=10, default=secret, editable=False)
12
13
14
15
16
17
18
19import random
20
21def secret():
22 hash = random.sample('123456789qwertyuiopasdfghjklzxcvbnm', 10)
23 str = ''.join(hash)
24 return str