Skip to content

Instantly share code, notes, and snippets.

@amigrave
Last active November 23, 2017 16:10
Show Gist options
  • Save amigrave/eed4050cf5e54d457b77 to your computer and use it in GitHub Desktop.
Save amigrave/eed4050cf5e54d457b77 to your computer and use it in GitHub Desktop.
What I don't like in Django

What I don't like in Django

Note: this was written for Django 1.6

ORM

  • South <-> Django troubles with oracle 30char limit (truncate hash not computed the same way due to upper/lower case mismatch)
  • The ORM prefetching on relations is not usefull in many cases because prefetch_related() do not support custom filters. It seems there's a Prefetch class in django 1.7 that finally support the feature but I must say this is quite late to the party compared to the other ORMs considering Django 1.6 is an 8 years old project.
  • When you have a model instance, there's no way to update it using a dict except by iterating the keys and setattr on the object. Can't think of another ORM lacking this feature.
  • Reverse relations should always be explicit. Those automatic/implicit foobar_set makes it hard to follow. AND I MEAN IT !
  • Tuple matrix for choices instead of an OrderedDict !!!

Views

  • Can't raise Http error, can just return them. It's far easier and pythonic being able to use exception flow for http errors.
  • The price you have to pay for html abstraction (which is a fail btw) is insane !!! Just saw some custom Radio choice widgets for a so small requirement, ... it's insane !!!

Routing

Templates

  • Can't call a function that is in the rendering context ? Are you kidding me ? https://code.djangoproject.com/ticket/16146
  • forloop's !!! Ok now I have nested loops how can I get the outmost counter ? Have to set a variable, ... yeah whatever.
    • Oh and by the way ! forloop is so specific and odd|even usage is so common in loops, why not add odd and even to forloop attributes ?
  • All this TEMPLATE_CONTEXT_PROCESSORS stuff just to expose variables makes me sick
  • if, ifequal, ifnotequal, ifchanged -- endif, endifequal, endifnotequal, endifchanged !!! W T F ???

Forms

  • Form validation is not optimal. When you have fields dependencies you're forced to overload clean() which does not allows you to specify a validation error for a specific field.
  • You can't easily overload simple javascript behaviour on the widgets. Eg: try to overload the "Now" link on a datetime widget...

Dev server

  • Ok I got the code reloading (which is cool) but in order to see tracebacks in the console I have to setup a middleware as the --traceback switch seems to be cosmetic. WTF ?

Admin

  • As superuser you can't even see all your data !!! Eg, user actions (a log of who did what) is only displayed by model, per user. If, as an administrator you want to consult all logs, you have to write some code yourself !!!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment