Other articles

  1. Django Sessions to cache

    Django sessions works great since the begining, you can do a site with them and never really understand how sessions works, but you can't scale to thousands of simultaneous users writing all your sessions to database. The database can be a huge bottleneck here and you should remove all unnecessary …

    read more

    There are comments.

  2. My Django contributions

    I started contributing to Django core after a failure in our project.

    I had to rename a model attribute without touching our database. The solution was simple.

    # Simple attribute to rename.
    author = models.ForeignKey('Author')
    # 1. Add db_column param.
    author = models.ForeignKey('Author', db_column='author')
    # 2. Change the attribute name …
    read more

    There are comments.

  3. Faster parallel pytest-django

    We at Buser recently migrated from Django unittests to pytest. It is amazing how much you can improve your tests with pytest.

    Unfortunately our CI/CD was really slow after this change.

    I discovered parallel pytest-django do their setup different than Django unittests. Django create a template database and copy …

    read more

    There are comments.

  4. Bottle wsgilog

    Python has awesome tools for logging, including standard logging module. Also, through WSGI protocol we have the wsgilog middleware. Using it is easy with any Python web framework.

    You can easily integrate it in bottle environment.

    import bottle
    from wsgilog import log
    app = bottle.Bottle(catchall=False)
    logger_middleware = log(tohtml …
    read more

    There are comments.

  5. Cracking Captchas

    During PythonBrasil[6], we discussed about cracking captchas. I already worked on it to automate some tasks with a stupid captcha. A lot of internet voting systems and forms security are based on captcha.


    It is really easy to clean the image with some Python tools.

    Captcha cleaned
    def convert_image(image, threshold …
    read more

    There are comments.