Full Featured Gravatar Tag
Simply returns a created gravatar url based on input. Creates the url utilizing the full gravatar url inputs as defined at http://en.gravatar.com/site/implement/url.
- tag
- simple_tag
- avatar
- gravatar
Simply returns a created gravatar url based on input. Creates the url utilizing the full gravatar url inputs as defined at http://en.gravatar.com/site/implement/url.
As I was unable to find good examples to render an inlineformset together, I have posted this to Django snippets. The example shows a person's data together with the phonenumbers for that person. You can add, update and delete from this form.
The utility of a login script is self-evident. As I learned about Django's built-in user authentication features, I whipped up this script and figured that I'd post it here. I am by no means an expert and would appreciate any constructive criticism. However, per the rules of this site, this is working code and not work in progress. Thanks Also: I wrote a blog post explaining the script for those who are interested: http://bit.ly/bwIL
Allows to create bigint (mysql), bigserial (psql), or NUMBER(19) (oracle) fields which have auto-increment set by using the AutoField of django, therefore ensuring that the ID gets updated in the instance when calling its 'save()' method. If you would only subclass IntegerField to BigIntegerField and use that as your primary key, your model instance you create would not get the id attribute set when calling 'save()', buy instead you would have to query and load the instance from the DB again to get the ID.
This template tag takes the current GET query, and modifies or adds the value you specify. This is great for GET-query-driven views, where you want to provide URLs which reconfigure the view somehow. **Example Usage:** `{% get_string "sort_by" "date" %}` returns `all=your¤t=get&variables=plus&sort_by=date`
This filter can be used to wrap <span class='highlight'> around anything you want to highlight in a block of text. For example, if you had 'foo bar foo baz' inside the context variable MYTEXT, you could do {{ MYTEXT|highlight:'foo' }}, and "<span class='highlight'>foo</span> bar <span class='highlight'>foo</span> baz" would be returned. How you style the highlight class is up to you.
Jinja2, while a great replacement for Django templates, is not a drop-in replacement for it. I wanted to use Photologue with my Jinja templates, but because Photologue uses Django generics, so I decided to see if I could use Jinja2 with generics, and then only modify the templates. It was a bit of work, but I seem to have done it. Django generics can take template_loader as an option, so if you have the same interface, things should just work. The template must accept RequestContext as an argument to render(), so here we subclass jinja2.Template and when it receives Django's RequestContext object, it creates a flat dictionary from it, which jinja2 can work with.
This is exacly the same snippet as #197 http://www.djangosnippets.org/snippets/197/ but returning search enigne, search engine domain and search term in: request.search_referrer_engine request.search_referrer_domain request.search_referrer_term I wanted to show ads only to people comming from search engines so I took snippet #197 and modify it to put that info in the request object.
A cache decorator.
A simple view used to manage the page cache stored in the database (here Postgresql in the django_cache table, you also have to set correctly CACHE_TABLE_OID, by the OID of the cache table (you can get it in PgAdmin)
This middleware will put the sessionid in every place that it might be needed, I mean, as a hidden input in every form, at the end of the document as a javascrit variable to allow the AJAX request use it and of course as a GET variable of the request. To make it work correctly the MIDDLEWARE_CLASSES tuple must be in this order: ` 'CookielessSessionPreMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'CookielessSessionPosMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', ` Hope it work for someone else out there.
This was a wild experiment, which appears to work! One model holds all the data, from every object version ever to exist. The other model simply points to the latest object from its gigantic brother. All fields can be accessed transparently from the little model version, so the user need not know what is going on. Coincidently, Django model inheritance does exactly the same thing, so to keep things insanely simple, that's what we'll use: class EmployeeHistory(FullHistory): name = models.CharField(max_length=100) class Employee(EmployeeHistory): pass That's it! Django admin can be used to administer the `Employee` and every version will be kept as its own `EmployeeHistory` object, these can of course all be browsed using the admin :-) This is early days and just a proof of concept. I'd like to see how far I can go with this, handling `ForeignKey`s, `ManyToManyField`s, using custom managers and so on. It should all be straightforward, especially as the primary keys should be pretty static in the history objects... *updated 3 August 2009 for Django 1.1 and working date_updated fields*
a randomized version of {% include %} {% rand_include "foo.html","bar.html","zot.html" %}
This is a context processor that will allow you to cycle the values of your MEDIA_URL context variable. It will cycle through the urls defined in settings.MEDIA_URLS, so that you can distribute your media url's between multiple servers.
Django 1.0 is apparently hard-coded for cascading deletes. I find that I often have nullable foreign keys on models whose records must not be deleted along with those they refer to. I override Model.delete() in an intermediate base class and execute this method to clear out all nullable foreign keys before allowing a delete to proceed.
2955 snippets posted so far.