Django 1.11.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). To check if the bug really exists, using the Admin create a question whose date lies in the future and check the method using the shell: instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 1878 页 | 6.40 MB | 1 年前3
Django 1.10.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). To check if the bug really exists, using the Admin create a question whose date lies in the future and check the method using the shell: instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 1817 页 | 6.19 MB | 1 年前3
Django 1.11.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). To check if the bug really exists, using the Admin create a question whose date lies in the future and check the method using the shell: instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 2747 页 | 2.67 MB | 1 年前3
Django 1.10.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). To check if the bug really exists, using the Admin create a question whose date lies in the future and check the method using the shell: instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 2538 页 | 2.59 MB | 1 年前3
Django 1.8.x Documentationalso if the Question’s pub_date field is in the future (which certainly isn’t). You can see this in the Admin; create a question whose date lies in the future; you’ll see that the Question change list claims instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 1685 页 | 6.01 MB | 1 年前3
Django 1.8.x Documentationalso if the Question’s pub_date field is in the future (which certainly isn’t). You can see this in the Admin; create a question whose date lies in the future; you’ll see that the Question change list claims instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 2454 页 | 2.85 MB | 1 年前3
Django 2.2.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). Confirm the bug by using the shell to check the method on a question whose date lies in the future: $ python manage.py shell >>> import instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 2915 页 | 2.83 MB | 1 年前3
Django 2.1.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). Confirm the bug by using the shell to check the method on a question whose date lies in the future: $ python manage.py shell >>> import instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 1910 页 | 6.49 MB | 1 年前3
Django 2.1.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). Confirm the bug by using the shell to check the method on a question whose date lies in the future: $ python manage.py shell >>> import instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. Create a test to expose the bug What we’ve just done in the shell to test for the problem is exactly what we can do in an0 码力 | 2790 页 | 2.71 MB | 1 年前3
Django 2.0.x DocumentationQuestion’s pub_date field is in the future (which certainly isn’t). To check if the bug really exists, using the Admin create a question whose date lies in the future and check the method using the shell: instance with pub_date 30 days in the future >>> future_question = Question(pub_date=timezone.now() + datetime.timedelta(days=30)) >>> # was it published recently? >>> future_question.was_published_recently() () True Since things in the future are not ‘recent’, this is clearly wrong. 2.7. Writing your first Django app, part 5 43 Django Documentation, Release 2.0.14.dev20190701080343 Create a test to expose0 码力 | 1880 页 | 6.41 MB | 1 年前3
共 92 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10













