For your form, it’s a warning, not an error, telling you that in django 1.8, you will need to change your form to
from django import forms
from models import Article
class ArticleForm(forms.ModelForm):
class Meta:
model = Article
fields="__all__" # Or a list of the fields that you want to include in your form
Or add an exclude
to list fields to exclude instead
Which wasn’t required up till 1.8
https://docs.djangoproject.com/en/1.8/topics/forms/modelforms/#selecting-the-fields-to-use
As for the error with your views, your return is inside of an if
statement: if request.POST:
so when it receives a get request, nothing is returned.
def create(request):
if request.POST:
form = ArticleForm(request.POST)
if form.is_valid():
form.save()
return HttpResponseRedirect('/articles/all')
else:
form = ArticleForm()
args = {}
args.update(csrf(request))
args['form'] = form
return render_to_response('create_article.html', args)
Just dedent the else
block so that it’s applying to the correct if
statement.