Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## forms.py ##
- class IndexForm(forms.Form):
- def __init__(self, *args, **kwargs):
- short = kwargs.pop('short')
- super(IndexForm, self).__init__(*args, **kwargs)
- origin = forms.CharField(label='Url', required=True)
- type = forms.ChoiceField(choices=(('Simple', 'simple'), ('Extra', 'extra')),
- label='Type for your shortcut')
- ## views.py ##
- class IndexView(FormView):
- template_name = 'cutter/index.html'
- form_class = IndexForm
- success_url = '/'
- def form_valid(self, form):
- short = self.create_link(form.cleaned_data)
- redirect('cutter:index', args=(short,))
- ## index.html ##
- ...
- <div>{{ short }}</div>
Add Comment
Please, Sign In to add comment