mirror of
https://github.com/Hopiu/django-select2.git
synced 2026-04-15 10:51:00 +00:00
Issue 76 testing
This commit is contained in:
parent
7d66164e65
commit
4bfcdc6ef5
5 changed files with 28 additions and 2 deletions
BIN
testapp/test.db
BIN
testapp/test.db
Binary file not shown.
|
|
@ -14,5 +14,6 @@
|
|||
<li><a href="{% url 'test_auto_multivalue_field' %}">Test multi value auto model field.</a></li>
|
||||
<li><a href="{% url 'test_auto_heavy_perf' %}">Test performance. Issue#54.</a></li>
|
||||
<li><a href="{% url 'test_get_search_form' %}">Test a search form using GET. Issue#66.</a></li>
|
||||
<li><a href="{% url 'test_issue_73' %}">Test issue#73.</a></li>
|
||||
</ul>
|
||||
</body>
|
||||
|
|
|
|||
|
|
@ -176,4 +176,11 @@ class WordsForm(forms.ModelForm):
|
|||
|
||||
class GetSearchTestForm(forms.Form):
|
||||
name = GetSearchTestField(required=False, label='Name')
|
||||
dept = GetModelSearchTestField(required=False, label='Department')
|
||||
dept = GetModelSearchTestField(required=False, label='Department')
|
||||
|
||||
class AnotherWordForm(forms.ModelForm):
|
||||
word = WordChoices(widget=AutoHeavySelect2Widget())
|
||||
|
||||
class Meta:
|
||||
model = WordList
|
||||
exclude = ['kind', 'words']
|
||||
|
|
|
|||
|
|
@ -20,4 +20,6 @@ urlpatterns = patterns('testapp.testmain.views',
|
|||
url(r'auto_heavy/perf_test/$', 'test_auto_heavy_perf', name='test_auto_heavy_perf'),
|
||||
|
||||
url(r'get_search/get_search_test/$', 'test_get_search_form', name='test_get_search_form'),
|
||||
|
||||
url(r'issue76/$', 'test_issue_73', name='test_issue_73'),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ from django.core.urlresolvers import reverse
|
|||
from django.http import HttpResponseRedirect
|
||||
from django.shortcuts import render, get_object_or_404
|
||||
|
||||
from .forms import EmployeeForm, DeptForm, MixedForm, InitialValueForm, QuestionForm, WordsForm, SchoolForm, GetSearchTestForm
|
||||
from .forms import EmployeeForm, DeptForm, MixedForm, InitialValueForm, QuestionForm, WordsForm, SchoolForm, GetSearchTestForm, \
|
||||
AnotherWordForm
|
||||
from .models import Employee, Dept, Question, WordList, School
|
||||
|
||||
def test_single_value_model_field(request):
|
||||
|
|
@ -126,3 +127,18 @@ def test_get_search_form(request):
|
|||
form = GetSearchTestForm()
|
||||
results = Employee.objects.none()
|
||||
return render(request, 'formget.html', {'form': form, 'results' : results})
|
||||
|
||||
def test_issue_73(request):
|
||||
try:
|
||||
word = WordList.objects.get(kind='Word_Of_Day')
|
||||
except WordList.DoesNotExist:
|
||||
word = WordList(kind='Word_Of_Day')
|
||||
|
||||
if request.POST:
|
||||
form = AnotherWordForm(request.POST)
|
||||
if form.is_valid():
|
||||
form.save()
|
||||
return HttpResponseRedirect(reverse('home'))
|
||||
else:
|
||||
form = AnotherWordForm(instance=word)
|
||||
return render(request, 'form.html', {'form': form})
|
||||
|
|
|
|||
Loading…
Reference in a new issue