Changes between Version 81 and Version 82 of RemovingTheMagic


Ignore:
Timestamp:
02/27/2006 04:58:19 PM (10 years ago)
Author:
jacob
Comment:

Added info about exlcude() and the removal of ne lookups

Legend:

Unmodified
Added
Removed
Modified
  • RemovingTheMagic

    v81 v82  
    355355    * {{{all()}}} -- Returns a {{{QuerySet}}} of all objects in the database. This is like the old {{{get_list()}}}. Takes no arguments.
    356356    * {{{filter(**kwargs)}}} -- Returns a {{{QuerySet}}}, filtered by the given keyword arguments. Lookup arguments are in the same style as previously, e.g. {{{pubdate__year=2005}}}, except you can leave off {{{__exact}}} as a convenience. For example, {{{name='John'}}} and {{{name__exact='John'}}} are equivalent.
     357    * {{{exclude(**kwargs)}}} is the same as {{{filter()}}}, but returns objects where the given arguments are not true.
    357358    * {{{order_by(*fieldnames)}}} -- Returns a {{{QuerySet}}}
    358359    * {{{count()}}} -- Returns the count of all objects in the database.
     
    399400}}}
    400401
    401 || '''Old syntax'''                                        || '''New syntax'''                             ||
     402|| '''Old syntax'''                                       || '''New syntax'''                             ||
    402403|| {{{reporters.get_list()}}}                             || {{{Reporter.objects.all()}}}                       ||
    403404|| {{{reporters.get_list(fname__exact='John')}}}          || {{{Reporter.objects.filter(fname='John')}}}        ||
     
    406407|| {{{reporters.get_object(pk=3)}}}                       || {{{Reporter.objects.get(pk=3)}}}                   ||
    407408|| {{{reporters.get_object(fname__contains='John')}}}     || {{{Reporter.objects.get(fname__contains='John')}}} ||
     409|| {{{reporters.get_list(fname__ne='John')}}}             || {{{Reporter.objects.exclude(fname='John')}}} (note that {{{ne}}} is no longer a valid lookup type) ||
     410|| (not previously possible)             || {{{Reporter.objects.exclude(fname__contains='n')}}} ||
    408411|| {{{reporters.get_list(distinct=True)}}}                || {{{Reporter.objects.distinct()}}} ||
    409412|| {{{reporters.get_values()}}}                           || {{{Reporter.objects.values()}}} ||
    410413|| {{{reporters.get_in_bulk([1, 2])}}}                    || {{{Reporter.objects.in_bulk([1, 2])}}} ||
    411414|| {{{reporters.get_in_bulk([1, 2], fname__exact='John')}}} || {{{Reporter.objects.filter(fname='John').in_bulk([1, 2])}}} ||
    412 || '''Date lookup'''                                      ||                                              ||
    413 || {{{articles.get_pub_date_list('year')}}}                     || {{{Article.objects.dates('pub_date', 'year')}}} ||
    414 || '''Latest-object lookup'''                             ||                                               ||
     415|| '''Date lookup'''                                        ||                                              ||
     416|| {{{articles.get_pub_date_list('year')}}}                 || {{{Article.objects.dates('pub_date', 'year')}}} ||
     417|| '''Latest-object lookup'''                               ||                                               ||
    415418|| {{{articles.get_latest()}}} (required {{{get_latest_by}}} in model) || {{{Article.objects.latest()}}} (with {{{get_latest_by}}} in model) ||
    416419|| (Not previously possible)                                     || {{{Article.objects.latest('pub_date')}}} # Latest by pub_date (overrides {{{get_latest_by}}} field in model) ||
Back to Top