Changes between Version 25 and Version 26 of DescriptorFields


Ignore:
Timestamp:
01/25/06 22:01:49 (9 years ago)
Author:
adrian
Comment:

Fixed formatting of examples

Legend:

Unmodified
Added
Removed
Modified
  • DescriptorFields

    v25 v26  
    6969Related-object lookup uses the default manager of the related object, which means the API for accessing related objects is completely consistent with the API for accessing objects via a manager.
    7070
    71 Another improvement is that the lookup type {{{__exact}}} can be left off.
     71Another improvement is that the lookup type "{{{__exact}}}" can be left off.
    7272
    7373== Examples ==
    7474
    7575|| '''Old syntax'''                                        || '''New syntax'''                             ||
    76 || Reporter.objects.get_list()                             || Reporter.objects.all()                       ||
    77 || Reporter.objects.get_list(fname__exact='John')          || Reporter.objects.filter(fname='John')        ||
    78 || Reporter.objects.get_list(order_by=('-lname', 'fname')) || Reporter.objects.order_by('-lname', 'fname') ||
    79 || Reporter.objects.get_list(fname__exact='John', order_by=('lname',)) || Reporter.objects.filter(fname='John').order_by('lname') ||
    80 || Reporter.objects.get_object(pk=3)                       || Reporter.objects.get(pk=3)                   ||
    81 || Reporter.objects.get_object(fname__contains='John')     || Reporter.objects.get(fname__contains='John') ||
    82 || Reporter.objects.get_list(distinct=True)                || Reporter.objects.all().distinct() ||
    83 || Reporter.objects.get_values()                           || Reporter.objects.values() ||
    84 || Reporter.objects.get_in_bulk([1, 2])                    || Reporter.objects.in_bulk([1, 2]) ||
    85 || Reporter.objects.get_in_bulk([1, 2], fname__exact='John') || Reporter.objects.filter(fname='John').in_bulk([1, 2]) ||
     76|| {{{Reporter.objects.get_list()}}}                             || {{{Reporter.objects.all()}}}                       ||
     77|| {{{Reporter.objects.get_list(fname__exact='John')}}}          || {{{Reporter.objects.filter(fname='John')}}}        ||
     78|| {{{Reporter.objects.get_list(order_by=('-lname', 'fname'))}}} || {{{Reporter.objects.order_by('-lname', 'fname')}}} ||
     79|| {{{Reporter.objects.get_list(fname__exact='John', order_by=('lname',))}}} || {{{Reporter.objects.filter(fname='John').order_by('lname') ||
     80|| {{{Reporter.objects.get_object(pk=3)}}}                       || {{{Reporter.objects.get(pk=3)}}}                   ||
     81|| {{{Reporter.objects.get_object(fname__contains='John')}}}     || {{{Reporter.objects.get(fname__contains='John')}}} ||
     82|| {{{Reporter.objects.get_list(distinct=True)}}}                || {{{Reporter.objects.all().distinct()}}} ||
     83|| {{{Reporter.objects.get_values()}}}                           || {{{Reporter.objects.values()}}} ||
     84|| {{{Reporter.objects.get_in_bulk([1, 2])}}}                    || {{{Reporter.objects.in_bulk([1, 2])}}} ||
     85|| {{{Reporter.objects.get_in_bulk([1, 2], fname__exact='John')}}} || {{{Reporter.objects.filter(fname='John').in_bulk([1, 2])}}} ||
    8686|| '''Many-to-one related lookup'''                        ||                                              ||
    87 || article_obj.reporter_id                                 || article_obj.reporter.id ||
    88 || article_obj.get_reporter()                              || article_obj.reporter    ||
    89 || reporter_obj.get_article_list()                         || reporter_obj.article_set.all() ||
    90 || reporter_obj.get_article_list(headline__exact='Hello')  || reporter_obj.article_set.filter(headline='Hello') ||
    91 || reporter_obj.get_article_count()                        || reporter_obj.article_set.count() ||
    92 || reporter_obj.add_article(headline='Foo')                || reporter_obj.article_set.add(headline='Foo') ||
    93 || (Alternate syntax)                                      || reporter_obj.article_set.add(article_obj) ||
    94 || ("values" lookup, etc., not previously possible)        || reporter_obj.article_set.values() ||
     87|| {{{article_obj.reporter_id}}}                                 || {{{article_obj.reporter.id}}} ||
     88|| {{{article_obj.get_reporter()}}}                              || {{{article_obj.reporter}}}    ||
     89|| {{{reporter_obj.get_article_list()}}}                         || {{{reporter_obj.article_set.all()}}} ||
     90|| {{{reporter_obj.get_article_list(headline__exact='Hello')}}}  || {{{reporter_obj.article_set.filter(headline='Hello')}}} ||
     91|| {{{reporter_obj.get_article_count()}}}                        || {{{reporter_obj.article_set.count()}}} ||
     92|| {{{reporter_obj.add_article(headline='Foo')}}}                || {{{reporter_obj.article_set.add(headline='Foo')}}} ||
     93|| (Alternate syntax)                                      || {{{reporter_obj.article_set.add(article_obj)}}} ||
     94|| ("values" lookup, etc., not previously possible)        || {{{reporter_obj.article_set.values()}}} ||
    9595|| '''Many-to-many related lookup'''                       ||                         ||
    96 || article_obj.get_site_list()                             || article_obj.site_set.all() ||
    97 || article_obj.set_sites([s1.id, s2.id])                   || article_obj.site_set.clear(); article_obj.site_set.add(s1); article_obj.site_set.add(s2) ||
    98 || article_obj.set_sites([s1.id]) # deletion               || article_obj.site_set.remove(s2) ||
    99 || site_obj.get_reporter_list()                            || site_obj.reporter_set.all() ||
     96|| {{{article_obj.get_site_list()}}}                             || {{{article_obj.site_set.all()}}} ||
     97|| {{{article_obj.set_sites([s1.id, s2.id])}}}                   || {{{article_obj.site_set.clear(); article_obj.site_set.add(s1); article_obj.site_set.add(s2)}}} ||
     98|| {{{article_obj.set_sites([s1.id]) # deletion}}}               || {{{article_obj.site_set.remove(s2)}}} ||
     99|| {{{site_obj.get_reporter_list()}}}                            || {{{site_obj.reporter_set.all()}}} ||
    100100
Back to Top