[[PageOutline(1-2,Table of contents)]] = Newbie mistakes = Please feel free to share the things that tripped you up when you started with Django. We'll try to improve Django's error handling to catch such mistakes in the future. == POST to views loses POST data == ==== Symptom ==== You've got a form that does a POST to some view, and the view doesn't get the POST data from the form. ==== Probable cause ==== You might be missing the / at the end of the form {{{action}}}. If that's the case, the {{{CommonMiddleware}}} (check your {{{MIDDLEWARE_CLASSES}}}) redirects to the exact name of the view - and that always includes a trailing slash. Because it does so by using the standard HTTP redirection through Location header, it can't pass on the POST data - and that's why it gets lost. ==== Solution ==== Always make sure that your form actions end with a slash, like this: {{{
}}} Note that Django now attempts to catch this problem, as of [3109]. == Your forms do not upload files == ==== Symptom ==== You have {{{FileField()}}} and {{{ImageField()}}} fields in your form and the files are not uploaded when you submit this form ==== Probable cause ==== You might be missing the {{{request.FILES}}} argument when instantiate your {{{Form}}} object. ==== Solution ==== Always make sure that you are passing {{{request.FILES}}} when intantiate your {{{Form}}} object: {{{ form = MyForm(request.POST, request.FILES) }}} ==== Another cause ==== You might be missing {{{enctype}}} attribute on your form. ==== Solution ==== Make sure you have the {{{enctype}}} attribute on your form as follows: {{{