Skip to main content

Home/ interesting_sites/ Group items matching "django" in title, tags, annotations or url

Group items matching
in title, tags, annotations or url

Sort By: Relevance | Date Filter: All | Bookmarks | Topics Simple Middle
pagetribe .

Working with models, part 2 - 0 views

  • Every Django model class and every instance of every Django model class has an attribute on it named _meta
  •  
    Nice info on the usage of _meta on django models.
pagetribe .

Hedged down: django - 0 views

  •  
    Practical Django Projects conversion to 1.0 blog
pagetribe .

Screencast on many to many relationships between Django models - 0 views

  •  
    A nice screencast on many to many relationships. Part of a 3 part series on developing a wiki in django.
pagetribe .

Big list of Django tips (and some python tips too) | Surfing in Kansas - 0 views

  • Big list of Django tips
  • Writing managers is really simple, and they provide a better user interface to your code. This code snippet simply adds a latest() method to the default objects manager class ForecastDayManager(Manager): def __init__(self, *args, **kwargs): super(ForecastDayManager, self).__init__(*args, **kwargs) def latest(self): return self.get_query_set().order_by('forecast_date')[0] It can be called ForecastDay.objects.latest(). This is a trivial example, but there is a lot of power that lies in this functionality.
pagetribe .

Django | Sending e-mail | Django Documentation - 0 views

  • Testing e-mail sending¶ The are times when you do not want Django to send e-mails at all. For example, while developing a website, you probably don't want to send out thousands of e-mails -- but you may want to validate that e-mails will be sent to the right people under the right conditions, and that those e-mails will contain the correct content.
  •  
    python -m smtpd -n -c DebuggingServer localhost:1025
pagetribe .

Deploying Django applications to a production server - 0 views

  • Deploying Django applications to a production server
pagetribe .

About this site - News Mixer - 0 views

  • Developers News Mixer is free and open source software, coded in Python with the Django Web development framework, and uses Facebook Connect for authentication. You can read more about our development process in our report, and find our source at Google Code.
  •  
    Developers News Mixer is free and open source software, coded in Python with the Django Web development framework, and uses Facebook Connect for authentication. You can read more about our development process in our report, and find our source at Google Code.
pagetribe .

Django | 23. Giving models a custom manager | Django Documentation - 0 views

  • class PersonManager(models.Manager): def get_fun_people(self): return self.filter(fun=True)
  • objects = PersonManager()
pagetribe .

Django Tagging - 0 views

shared by pagetribe . on 18 Nov 08 - Cached
  • >>> tags = Tag.objects.usage_for_model(Widget, counts=True)
  • [('cheese', 1), ('house', 2), ('thing', 1), ('toast', 1)]
  •  
    def usage_for_model(self, model, counts=False, min_count=None, filters=None): """ Obtain a list of tags associated with instances of the given Model class. If ``counts`` is True, a ``count`` attribute will be added to each tag, indicating how many times it has been used against the Model class in question. If ``min_count`` is given, only tags which have a ``count`` greater than or equal to ``min_count`` will be returned. Passing a value for ``min_count`` implies ``counts=True``. To limit the tags (and counts, if specified) returned to those used by a subset of the Model's instances, pass a dictionary of field lookups to be applied to the given Model as the ``filters`` argument. """ if filters is None: filters = {} if min_count is not None: counts = True model_table = qn(model._meta.db_table) model_pk = '%s.%s' % (model_table, qn(model._meta.pk.column)) query = """ SELECT DISTINCT %(tag)s.id, %(tag)s.name%(count_sql)s FROM %(tag)s INNER JOIN %(tagged_item)s ON %(tag)s.id = %(tagged_item)s.tag_id INNER JOIN %(model)s ON %(tagged_item)s.object_id = %(model_pk)s %%s WHERE %(tagged_item)s.content_type_id = %(content_type_id)s %%s GROUP BY %(tag)s.id, %(tag)s.name %%s ORDER BY %(tag)s.name ASC""" % { 'tag': qn(self.model._meta.db_table), 'count_sql': counts and (', COUNT(%s)' % model_pk) or '', 'tagged_item': qn(self._get_related_model_by_accessor('items')._meta.db_table), 'model': model_table, 'model_pk': model_pk, 'content_type_id': ContentType.objects.get_for_model(model).pk, } extra_joins = '' extra_criteria = '' min_count_sql
  •  
    usage_for_model
pagetribe .

Stripped-down Django Tutorial | Tony Abou-Assaleh - 0 views

  •  
    Inline
pagetribe .

Chapter 11: Generic Views - 0 views

  • from django.conf.urls.defaults import * from django.views.generic import list_detail from mysite.books.models import Publisher publisher_info = { 'queryset': Publisher.objects.all(), 'template_name': 'publisher_list_page.html', } urlpatterns = patterns('', (r'^publishers/$', list_detail.object_list, publisher_info) )
  • That’s really all there is to it. All the cool features of generic views come from changing the “info” dictionary passed to the generic view.
  • You might have noticed that sample publisher list template stores all the books in a variable named object_list.
  • ...10 more annotations...
  • it isn’t all that “friendly” to template authors: they have to “just know” that they’re dealing with books here.
  • better name
  • publisher_list;
  • 'template_object_name': 'publisher',
  • If you want to present a list of books by a particular publisher, you can use the same technique:
  • Another common need is to filter the objects given in a list page by some key in the URL. Earlier we hard-coded the publisher’s name in the URLconf, but what if we wanted to write a view that displayed all the books by some arbitrary publisher?
  • “wrap” the object_list generic view
  • # Look up the publisher (and raise a 404 if it can't be found). publisher = get_object_or_404(Publisher, name__iexact=name)
  • Notice that in the preceding example we passed the current publisher being displayed in the extra_context. This is usually a good idea in wrappers of this nature; it lets the template know which “parent” object is currently being browsed.
  • Or, you could use a less obvious but shorter version that relies on the fact that Book.objects.all is itself a callable:
pagetribe .

django.org.ua - 0 views

shared by pagetribe . on 13 Jun 09 - Cached
pagetribe .

Django 1.1 Talk Text - excess.org - 0 views

  •  
    Custom Upload Handling
pagetribe .

Django | QuerySet API reference | Django Documentation - 0 views

  •  
    QuerySet API reference¶
1 - 20 of 28 Next ›
Showing 20 items per page