general

General utilities for django.

functions

bits.general.get_or_none(klass, *args, **kwargs)[source]

Uses get() to return an object or None if the object does not exist.

klass may be a Model, Manager, or QuerySet object. All other passed arguments and keyword arguments are used in the get() query.

Note: Like with get(), a MultipleObjectsReturned will be raised if more than one object is found.

From django-annoying: https://bitbucket.org/offline/django-annoying

bits.general.get_profile_model()[source]

Return the model class for the currently-active user profile model, as defined by the AUTH_PROFILE_MODULE setting.

Returns:The model that is used as profile.

commands

after_syncdb

Sends the after_syncdb signal.

class bits.management.commands.after_syncdb.Command[source]
handle(*args, **options)[source]
help = 'sends after_syncdb signal'

This can be useful in a deploy script scenario where you want to run certain django operations after syncdb or migrate have completed. post_syncdb and post_migrate get triggered after every app and it’s difficult to check if a few apps have been synced already. In such cases you can just set your app run certain operations on recieving after_syncdb and then do thid in your deploy script:

$ python manage.py syncdb
$ python manage.py after_syncdb

Project Versions

Table Of Contents

Previous topic

django-bits

Next topic

models

This Page