Skip to main content

Django-fastdev is an app that makes it faster and more fun to develop Django apps

Project description

Django-fastdev is an app that makes it faster and more fun to develop Django apps.

Features

Error on non-existent template variables

Django templates by default hide errors, and when it does show an error it’s often not very helpful. This app will change this so that if you do:

{{ does_not_exist }}

instead of rendering that as an empty string, this app will give you an error message:

does_not_exist does not exist in context. Available top level variables:

    DEFAULT_MESSAGE_LEVELS
    False
    None
    True
    bar
    csrf_token
    foo
    messages
    perms
    request
    user

There are more specialized error messages for when you try to access the contents of a dict, and attributes of an object a few levels deep like foo.bar.baz (where baz doesn’t exist).

NoReverseMatch errors

Have you ever gotten this error?

django.urls.exceptions.NoReverseMatch: Reverse for 'view-name' with arguments '('',)' not found. 1 pattern(s) tried:

it’s because you have {% url ‘view-name’ does_not_exist %}. Django sees does_not_exist and evaluates it to the empty string because it doesn’t exist. So that’s why you get an error message that makes no sense. Django-fastdev will make your code crash on the actual error: does_not_exist doesn’t exist.

Error if you have non-space text outside a block when extending

A common mistake for beginners that can be hard to spot is when they do:

<html>
    {% extends "something.html" %}
    stuff here
</html>

Django silently throws away stuff here and </html>. Django-fastdev makes this an error.

Error on invalid block names when using {% extends “…” %}

If you have a base template:

<html>
    <body>
        {% block content %}{% endblock %}
    </body>
</html>

and then write a template like this:

{% extends "base.html" %}

{% block contents %}
    hello!
{% endblock %}

Django will silently throw away hello! because you wrote contents instead of content. Django-fastdev will turn this into an error which lists the invalid and valid block names in alphabetical order.

Better error messages for reverse

The standard error message for a bad reverse()/{% url %} are rather sparse. Django-fastdev improves them by listing valid patterns so you can easily see the problem.

Better error messages for QuerySet.get()

The error message for QuerySet.get() is improved to give you the query parameters that resulted in the exception.

Validate clean_* methods

A common mistake is to make a form clean method and make a spelling error. By default Django just won’t call the function. With django-fastdev you will get an error message telling you that your clean method doesn’t match anything.

This is also very useful during refactoring. Renaming a field is a lot safer as if you forget to rename the clean method django-fastdev will tell you!

Faster startup

The initial model checks can be quite slow on big projects. Django-fastdev will move these checks to a separate thread, so the runserver startup time is lowered, so you don’t have to wait for the runserver restart as long.

Usage

First install: pip install django-fastdev

In settings.py add django_fastdev to INSTALLED_APPS:

 INSTALLED_APPS = [
     # ...
     'django_fastdev',
]

Enjoy a nicer Django experience!

License

BSD

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-fastdev-1.7.4.tar.gz (12.7 kB view details)

Uploaded Source

File details

Details for the file django-fastdev-1.7.4.tar.gz.

File metadata

  • Download URL: django-fastdev-1.7.4.tar.gz
  • Upload date:
  • Size: 12.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for django-fastdev-1.7.4.tar.gz
Algorithm Hash digest
SHA256 d4f1f39ffc0304cb17a33a042393f697d0f0bff70419d260934188cd7acf45fa
MD5 09a075558033e7d16fe61c9fc1dfaad0
BLAKE2b-256 271f2951db884578c2399ee5ab7f4bc6726a036e0c35d1fd774d8d55b20cc5f1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page