adding fields to User model
This code adds new field to Django user model. It must be executed early as much as possible, so put this code to __init__.py of some application.
- fields
- model
- user
- auth
- field
This code adds new field to Django user model. It must be executed early as much as possible, so put this code to __init__.py of some application.
If you have a model with foreign key to User, you can use this manager to show (i.e. in admin interface) only objects, that are related to currently logged-in user. Superuser sees all objects, not only his. Requires: [ThreadlocalsMiddleware](http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser)
Use this, if you want to "activate" menu items by URL. Typical usage is with CSS class 'active'.
FieldStack simplifies forms template rendering. This is enhanced version of snippet [1786](http://djangosnippets.org/snippets/1786/)
This snippet was inspired by [1783](http://www.djangosnippets.org/snippets/1783/). It allows simply create groups of fields for template rendering.
This is another foreign key to User model. User is automatically associated before save. Requires: [ThreadlocalsMiddleware](http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser) Inspired by: [snippet 509](http://www.djangosnippets.org/snippets/509/)
With these models, you can use your Django's database directly as backend for PowerDNS server (tested with MySQL). License: GNU GPL. More info: http://downloads.powerdns.com/documentation/html/configuring-db-connection.html#CONFIGURING-MYSQL
Tuned IPAddressField with IPv4 & IPv6 support
This is a XML-RPC server, that uses arguments in URLs and every dispatcher instance is prepared in memory during webserver run. It's good, for example, for securing XML-RPC server with hashed strings and there are a lot of similar use cases. Usage: from xmlrpclib import ServerProxy server = ServerProxy('http://example.com/xmlr-rpc/%s/' % something, allow_none=True) server.do_something(*args)
This templatetag evaluates Python expressions including built-in functions, lambda functions etc... Use with caution.
This is my first snipplet. With this, you can manage your models in console using ncurses Dialog or Whiptail or XDialog. Models are auto-discovered. You can browse, edit, add and delete models. Bugreports very welcome.
This class emulates query lookups to behave as numeric operators. Inspired by SQLAlchemy. User.objects.filter( X('username') == 'diverman' ) User.objects.filter( X('username') != 'diverman' ) User.objects.filter( X('pk') > 10 ) User.objects.filter( X('pk') >= 10 ) User.objects.filter( X('pk') < 10 ) User.objects.filter( X('pk') <= 10 ) User.objects.filter( X('username') % 'iverma' ) User.objects.filter( X('username') << 'diver' ) User.objects.filter( X('username') >> 'man' ) User.objects.filter( X('pk') | (1, 2, 3) )
Sometime may be useful to disable the HTML output from formfield to template.
You can use `UrlModel` to provide URL functionality to any instance of any model and any language (language support can be removed from this). Each model must have own view method, that returns HttpResponse. I was inspired by Flatpages. It is useful for small sites and static pages. `class Page(UrlModel): text = models.TextField() def view(self, request) # do something here return HttpResponse(...)`
This example shows, how to use database views with django models. NewestArticle models contains 100 newest Articles. Remember, that NewestArticle model is read-only. Tested with mysql.