Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

June 13 2019

Dry basic-auth middleware using Django's AUTHENTICATION_BACKENDS and "basicauth" lib

Requires to install "basicauth" package, which does basic-auth header encoding/decoding cleanly according to RFCs.

Could be improved to return a "realm" in case of http401, like in https://djangosnippets.org/snippets/1720/, although I'm not sure it's really useful in django usecases.

June 01 2019

How to recover lose quicken data file 2019

As the Quicken Software deals with your financial transactions, if it faces any error, you can face various issues. Therefore, our team of qualified technicians and advisors at Quicken Assist will help you at any hour in fixing the issues of your Quicken software. If you are using Quicken, accounting ...

May 16 2019

updated django-mptt enabled FilteredSelectMultiple m2m widget, Django 1.11 compatible

Small fix to make https://www.djangosnippets.org/snippets/1779/ compatible with Django 1.11 To use this you'll also need the javascript from https://www.djangosnippets.org/snippets/1780/

I added an overridden optgroups method that can handle the additional tuple and a couple minor things I gathered ...

May 08 2019



May 05 2019

StringField: CharField with no max_length for Postgres

Django's CharField requires a max_length, and TextField displays a multi- line widget, but in Postgres there's no reason to add an arbitrary max thanks to the varlena storage format. So this is a TextField that displays as a single line instead of a multiline TextArea.

April 30 2019

April 18 2019

Calculating Maintainability Index for a whole project

With this command you can calculate the maintainability index for your whole project.

In your settings you have to add a dictionary called RADON_MI_SETTINGS. It could be like this:

python RADON_MI_SETTINGS = { 'paths': ['projectname'], 'exclude': 'projectname/some_app/some_file.py', 'ignore': 'migrations,tests', }

I had to add following packages: radon==3.0 ...

April 17 2019

Django nginx sendfile example

Use nginx sendfile (X-Accel-Redirect) function to serve files but pass traffic through django. Can be used to serve media files only to logged-in users.

April 06 2019





this will help any url under panel/ require login.

March 28 2019

ChoiceField's choices from model

I have a product table but don't have a brand table. brands in product.brand as denormalized and I want to choose brands from a select tag.

March 04 2019


Now you can format and compress json-data in django template

February 14 2019

Tweet embed template tag

Takes a tweet url, requests the json from Twitter oEmbed, parses the json for the html element and returns it to your template. The html returned is ready to go and will be shown as a tweet on your web page. This uses the Requests library for Python. A full ...

February 05 2019

Adding Object name in Success Message

Success Message has object properties

Success Message can have an object name or the properties of the object model to collide with the message see code below

January 05 2019

Bootstrap Accordian

This is an example of Leamug web development, you can find how to add start templates designer

Collapsible accordion are useful when you want to hide and show large amount of content. If you are looking for a modern, flat and professionally designed Bootstrap accordion, then we have a best ...

December 12 2018

Different Response Data/Serializer for DRF Views/Viewsets

Mixin for Django Rest Framework View/Viewsets to use different response data/serializers without unnecessary hacks.

Just extend your DRFs view/viewset with this mixin after the DRF's APIView (sub)classes.

October 12 2018

Hand over model instance relations to another instance of the same model

If you have a model instance you want to merge into another, it's handy to hand over all the relations into the model you want to merge into, so the deletion won't trigger cascading deletions from other tables.

You can pass an Iterable of the same objects (a ...

September 11 2018

create custom permissions

create custom permissions

July 19 2018


this is a test

July 09 2018

generic 12factor manage.py for containers

Base manage.main hack which supports being an entry point.

In your project setup.py, add::

    'console_scripts': [
        'yourproject = yourproject.manage:main',

Replace your manage.py content with::

#!/usr/bin/env python
from crudlfap.manage import main

if __name__ == '__main__':

Note that it will enable DEBUG env ...

Older posts are this way If this message doesn't go away, click anywhere on the page to continue loading posts.
Could not load more posts
Maybe Soup is currently being updated? I'll try again automatically in a few seconds...
Just a second, loading more posts...
You've reached the end.

Don't be the product, buy the product!