djangosnippets.org: Latest snippets tagged with 'errors'https://djangosnippets.org/tags/errors/2012-09-21T09:06:57.894399-05:00List all errors in a form +bootstrap highlighting
2012-09-21T09:06:57.894399-05:00ibrahimlawalhttps://djangosnippets.org/snippets/2823/<p>Use this snippet to list all errors in a form. The message will be shown in a boostrap-type alert which can be 'closed' using a dismiss button.</p>
<p>The <strong>field label</strong> and the <strong>error</strong> will be listed.</p>
<p>e.g.</p>
<blockquote>
<ul>
<li>Name: This field is required</li>
<li>Email: Please enter a valid email</li>
</ul>
</blockquote>
Freely redistributableShow all form errors
2012-06-15T09:09:43.064698-05:00timbroderhttps://djangosnippets.org/snippets/2769/<p>showing all the errors at the top of the page</p>
Freely redistributableload m2m fields objects
2010-06-11T06:13:35.605956-05:00dirolhttps://djangosnippets.org/snippets/2060/<p>I have a ModelForm which includes m2m field to images. User can upload images and crop them with my cool jquery cropper, then areas are saved as images and their IDs and thumbnail URLs are passed back to page and included as thumbnails with hidden inputs. I have no problem …</p>
Freely redistributableNice form errors
2009-10-18T17:19:37.078611-05:00SmileyChrishttps://djangosnippets.org/snippets/1764/<p>Nicely output all form errors in one block, using field labels rather than the field attribute names.</p>
Freely redistributableView decorator to convert DoesNotExist (ObjectDoesNotExist) exceptions into Http404 exceptions
2009-09-26T03:58:57.691763-05:00jammycakeshttps://djangosnippets.org/snippets/1743/<p>A decorator that can be applied to your views to turn ObjectDoesNotExist exceptions into Http404 exceptions. This means people will see a "Page not found" error rather than an "Internal Server Error" when they are request something that does not exist in the database.
</p>
<p>Example:
</p>
<pre><code>@raise_404
def show_event(request, id):
event …</code></pre>
Freely redistributableLog Django exceptions to Apache error log in mod_wsgi
2009-09-17T02:36:32.983831-05:00simonhttps://djangosnippets.org/snippets/1731/<p>Add this to your middleware to log errors to the Apache error log when running under mod_wsgi.</p>
Freely redistributabletypo_comparison
2009-08-23T06:03:13.613111-05:00rogushttps://djangosnippets.org/snippets/1696/<p>This is simple validation weather a string is close enough to what we want. First param is keyword we are comparing to Second is user's input and third is tolerance level. Its very rudimentary. I have my mind fixed upon some imperfections. I am trying to make it good for …</p>
Freely redistributableAjax form with jQuery
2008-08-18T23:40:09.027719-05:00Donnhttps://djangosnippets.org/snippets/992/<p>I recently got a form working via jQuery and Django. This was not easy for me to do and I thought I'd record my finding here.</p>
<p>The form submits via jQuery and the "form" plugin. Please visit jQuery's home page to find all those links.</p>
<p>This code handles:
* urls.py …</p>
Freely redistributable