Commit 9aa64644 authored by Jean Michel Rouly's avatar Jean Michel Rouly
Browse files

Added form for url registration.

parent d3252305
from django import forms
from django.forms import ModelForm, TextInput, RadioSelect, URLInput
from go.models import URL
from django.core.validators import MinLengthValidator, MinValueValidator
class URLForm( ModelForm ):
DAY = '1 Day'
WEEK = '1 Week'
MONTH = '1 Month'
NEVER = 'Never'
EXPIRATION_CHOICES = (
(DAY, DAY),
(WEEK, WEEK),
(MONTH, MONTH),
(NEVER, NEVER),
)
# Add a custom expiration choice field.
expires = forms.ChoiceField(
required = True,
label = 'Expiration',
choices = EXPIRATION_CHOICES,
initial = NEVER,
widget = RadioSelect(),
)
class Meta:
model = URL
fields = ('target', 'short')
exclude = ('owner', 'date_created', 'clicks', 'expires')
labels = {
'target': 'Long URL',
'short': 'Short URL (Optional)',
}
widgets = {
'target': URLInput(attrs={
'placeholder': 'http://',
}),
'short': TextInput(attrs={
}),
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment