Skip to content

Instantly share code, notes, and snippets.

@eduardo-matos
Last active August 29, 2015 13:56
Show Gist options
  • Save eduardo-matos/8810337 to your computer and use it in GitHub Desktop.
Save eduardo-matos/8810337 to your computer and use it in GitHub Desktop.
Gerar valor aleatório para campos
# coding: utf-8
from django.db import models
from django.utils.crypto import get_random_string
from django.utils.translation import ugettext_lazy as _
class Discount(models.Model):
discount = models.FloatField(_('Discount Value'))
code = models.CharField(_("Discount code"), max_length=255, unique=True, default=get_random_string)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment