diff --git a/dpaste/forms.py b/dpaste/forms.py index df5ce08..179890f 100644 --- a/dpaste/forms.py +++ b/dpaste/forms.py @@ -59,6 +59,11 @@ class SnippetForm(forms.ModelForm): if session_lexer and session_lexer in dict(LEXER_LIST).keys(): self.fields['lexer'].initial = session_lexer + # if the lexer is given via GET, set it + if 'l' in request.GET and request.GET['l'] in dict(LEXER_LIST).keys(): + self.fields['lexer'].initial = request.GET['l'] + + def clean_content(self): return self.cleaned_data.get('content', '').strip() @@ -92,4 +97,4 @@ class SnippetForm(forms.ModelForm): # Save the lexer in the session so we can use it later again self.request.session['lexer'] = self.cleaned_data['lexer'] - return self.instance \ No newline at end of file + return self.instance