Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Django application that provider the like and ilike lookups for the querysets

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 django_like
Octocat-spinner-32 example
Octocat-spinner-32 patches
Octocat-spinner-32 .coveragerc
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 CHANGES.rst
Octocat-spinner-32 COPYING.LGPLv3
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 setup.py
Octocat-spinner-32 tox.ini
README.rst

django-like

Information

django-like is a Django application that adds other useful fields.

It is distributed under the terms of the GNU Lesser General Public License <http://www.gnu.org/licenses/lgpl.html>

https://travis-ci.org/goinnn/django-like.png?branch=master https://coveralls.io/repos/goinnn/django-like/badge.png?branch=master https://badge.fury.io/py/django-like.png https://pypip.in/d/django-like/badge.png

Requeriments

  • Django (>=1.1). It's possible that works with other versions lower 1.1

Installation

In your settings.py

INSTALLED_APPS = (

    'django_like',

)
Or apply some of the next patches (This is not neccesary, you can only install the app):

Usage

Something that you can to do with like sentence

MyModel.objects.filter(field_name__like='xx%YY%zz')
MyModel.objects.filter(field_name__ilike='xx%yy%zz')
User.objects.filter(username__like='a%in')

It is more quick and more readable that something like this:

MyModel.objects.filter(field_name__regex='^xx.*YY.*zz$')

This app provider two new lookups: like and ilike.

Now you can compare the time it takes to run the same query, many times, with like and with regex

python manage.py benchmark_like

These are a results executing the benchmark_like in my machine:

Type & result \ Database postgres mysql sqllite oracle
like 0:00:50.727005 0:00:14.025656 0:01:36.089407 ?:??:??.??????
regex 0:01:38.410019 0:02:57.255685 0:09:39.527765 ?:??:??.??????
Improvement 254% 600% 503% ???%

Reported

Development

You can get the bleeding edge version of django-like by doing a clone of its repository

git clone git://github.com/goinnn/django-like.git

Example project

In the source tree, you will find a directory called example. It contains a readily setup project that uses django-like. You can run it as usual:

python manage.py syncdb --noinput
python manage.py runserver
Something went wrong with that request. Please try again.