• Stars
    star
    141
  • Rank 259,971 (Top 6 %)
  • Language
    Python
  • License
    BSD 3-Clause "New...
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

An app to make it safer, faster and more fun to develop in Django

django-fastdev

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).

By default, django-fastdev only checks templates that exist within your project directory. If you want it to check ALL templates, including stock django templates and templates from third party libraries, add FASTDEV_STRICT_TEMPLATE_CHECKING = True to your project settings.py.

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

More Repositories

1

mutmut

Mutation testing system
Python
906
star
2

instar

Simpler and more powerful assoc/dissoc/update-in for both Clojure and ClojureScript
Clojure
171
star
3

hammett

Fast python test runner, compatible with a subset of pytest
Python
77
star
4

CMi

Replacement for XBMC with Django+VLC+WebKit
Python
36
star
5

elm-cog

Code generation for Elm, using Ned Batchelder's Cog
Python
32
star
6

indent-clj

A little experiment into how Clojure with inferred paren might look like
Clojure
31
star
7

iso8601

Python library to parse dates in the formats in the ISO 8601 standard.
Python
27
star
8

urd

A scheduler for Django projects
Python
21
star
9

pytest-readme

Make sure your README doesn't contain broken code
Python
14
star
10

DevBar

Take control over your workflow by putting it in your macOS menu bar
Swift
11
star
11

midje-readme

A Leiningen plugin to pull tests from your README.md into midje.
Clojure
10
star
12

okrand

Okrand is an internationalization/translation tool for Django
Python
9
star
13

clojure-validate-indent

Check that the indents in your code align with the parenthesis
Clojure
9
star
14

pytest-test-this

Plugin for pytest to run relevant tests, by naively checking if a test contains a reference to the symbol you supply
Python
7
star
15

test-benchmarks

Python
6
star
16

Waker

Waker is the alarm program that knows what you're up to and sets the time intelligently, based on your calendar.
Objective-C
6
star
17

atpshowbot

An irc bot for the Accidental Tech Podcast
Clojure
6
star
18

Frej

Swift
5
star
19

BoxedDock

A fast app switcher for macOS
Swift
5
star
20

relatedhow

A website to quickly find out how species are related
Python
4
star
21

PythonMate

Debugger GUI interface for Python and TextMate
Python
4
star
22

git-stats2

Statistics for git repos
Python
4
star
23

cheap-ruler-swift

Swift port of MapBox's cheap-ruler, between 13% and 10471% faster
Swift
3
star
24

defk

Compact keyword arguments for clojure
Clojure
3
star
25

mammon

Get control over your finances
Python
3
star
26

LineOps-intellij-plugin

Line operations based on bookmarks
Java
2
star
27

p

Python
2
star
28

Misc

Random small pieces of code that don't justify their own repositories
Python
2
star
29

scientist

Python
2
star
30

readable_lisp

Readable Lisp
Python
2
star
31

forum

Reimplementation of the best ideas of SKForum in python
Python
2
star
32

Knitting

Parsing and manipulating knitting instructions
Python
2
star
33

instar-py

Simpler transformations for pyrsistent data structures
Python
1
star
34

WCS-Hub

Implementation of World Swing Dance Council event code
Python
1
star
35

analytics

Super simple web analytics app
Python
1
star
36

sentry-ratelimit

Plugin to sentry for rate limiting low volume errors you don't care about
Python
1
star
37

python-terminal-menu

Simple little lib for terminal menus
Python
1
star
38

Supernaut

iommi presentation
Python
1
star
39

curia

Misc django code
Python
1
star
40

pannkakor

Den bästa sidan för pannkaksrecept
JavaScript
1
star
41

RandomPlaceInCode

Jump to a random place in your codebase
Python
1
star
42

cheatsheet-reagent

Reagent version of the Clojure cheatsheet
Clojure
1
star
43

BitPhone

My app Bit (available in the iOS app store). Old and horrible code :P
Objective-C++
1
star
44

CursorHighlight

OS X: Highlight the cursor with a white ring.
Objective-C
1
star
45

ivrit

Generate type stubs for your project based on name->type mapping configuration
Python
1
star