Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
e69348b4
Kaydet (Commit)
e69348b4
authored
Eyl 08, 2012
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Avoided mixing dates and datetimes in the examples.
Refs #16023.
üst
b7d3b057
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
34 additions
and
23 deletions
+34
-23
models.txt
docs/faq/models.txt
+1
-1
overview.txt
docs/intro/overview.txt
+4
-4
moderation.txt
docs/ref/contrib/comments/moderation.txt
+4
-4
fields.txt
docs/ref/models/fields.txt
+2
-2
instances.txt
docs/ref/models/instances.txt
+1
-1
querysets.txt
docs/ref/models/querysets.txt
+12
-1
many_to_one.txt
docs/topics/db/examples/many_to_one.txt
+4
-4
queries.txt
docs/topics/db/queries.txt
+6
-6
No files found.
docs/faq/models.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -11,7 +11,7 @@ Then, just do this::
>>> from django.db import connection
>>> connection.queries
[{'sql': 'SELECT polls_polls.id,
polls_polls.question,
polls_polls.pub_date FROM polls_polls',
[{'sql': 'SELECT polls_polls.id,
polls_polls.question,
polls_polls.pub_date FROM polls_polls',
'time': '0.002'}]
``connection.queries`` is only available if :setting:`DEBUG` is ``True``.
...
...
docs/intro/overview.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -31,7 +31,7 @@ the file ``mysite/news/models.py``::
return self.full_name
class Article(models.Model):
pub_date = models.Date
Time
Field()
pub_date = models.DateField()
headline = models.CharField(max_length=200)
content = models.TextField()
reporter = models.ForeignKey(Reporter)
...
...
@@ -96,8 +96,8 @@ access your data. The API is created on the fly, no code generation necessary::
DoesNotExist: Reporter matching query does not exist. Lookup parameters were {'id': 2}
# Create an article.
>>> from datetime import date
time
>>> a = Article(pub_date=date
time.now
(), headline='Django is cool',
>>> from datetime import date
>>> a = Article(pub_date=date
.today
(), headline='Django is cool',
... content='Yeah.', reporter=r)
>>> a.save()
...
...
@@ -140,7 +140,7 @@ as registering your model in the admin site::
from django.db import models
class Article(models.Model):
pub_date = models.Date
Time
Field()
pub_date = models.DateField()
headline = models.CharField(max_length=200)
content = models.TextField()
reporter = models.ForeignKey(Reporter)
...
...
docs/ref/contrib/comments/moderation.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -32,11 +32,11 @@ A simple example is the best illustration of this. Suppose we have the
following model, which would represent entries in a Weblog::
from django.db import models
class Entry(models.Model):
title = models.CharField(maxlength=250)
body = models.TextField()
pub_date = models.Date
Time
Field()
pub_date = models.DateField()
enable_comments = models.BooleanField()
Now, suppose that we want the following steps to be applied whenever a
...
...
@@ -55,11 +55,11 @@ Accomplishing this is fairly straightforward and requires very little
code::
from django.contrib.comments.moderation import CommentModerator, moderator
class EntryModerator(CommentModerator):
email_notification = True
enable_field = 'enable_comments'
moderator.register(Entry, EntryModerator)
The :class:`CommentModerator` class pre-defines a number of useful moderation
...
...
docs/ref/models/fields.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -983,10 +983,10 @@ define the details of how the relation works.
this with functions from the Python ``datetime`` module to limit choices of
objects by date. For example::
limit_choices_to = {'pub_date__lte': datetime.
now
}
limit_choices_to = {'pub_date__lte': datetime.
date.today
}
only allows the choice of related objects with a ``pub_date`` before the
current date
/time
to be chosen.
current date to be chosen.
Instead of a dictionary this can also be a :class:`~django.db.models.Q`
object for more :ref:`complex queries <complex-lookups-with-q>`. However,
...
...
docs/ref/models/instances.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -135,7 +135,7 @@ access to more than a single field::
raise ValidationError('Draft entries may not have a publication date.')
# Set the pub_date for published items if it hasn't been set already.
if self.status == 'published' and self.pub_date is None:
self.pub_date = datetime.date
time.now
()
self.pub_date = datetime.date
.today
()
Any :exc:`~django.core.exceptions.ValidationError` exceptions raised by
``Model.clean()`` will be stored in a special key error dictionary key,
...
...
docs/ref/models/querysets.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -1945,6 +1945,17 @@ SQL equivalent::
You can use ``range`` anywhere you can use ``BETWEEN`` in SQL — for dates,
numbers and even characters.
.. warning::
Filtering a ``DateTimeField`` with dates won't include items on the last
day, because the bounds are interpreted as "0am on the given date". If
``pub_date`` was a ``DateTimeField``, the above expression would be turned
into this SQL::
SELECT ... WHERE pub_date BETWEEN '2005-01-01 00:00:00' and '2005-03-31 00:00:00';
Generally speaking, you can't mix dates and datetimes.
.. fieldlookup:: year
year
...
...
@@ -1958,7 +1969,7 @@ Example::
SQL equivalent::
SELECT ... WHERE pub_date BETWEEN '2005-01-01' AND '2005-12-31
23:59:59.999999
';
SELECT ... WHERE pub_date BETWEEN '2005-01-01' AND '2005-12-31';
(The exact SQL syntax varies for each database engine.)
...
...
docs/topics/db/examples/many_to_one.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -42,8 +42,8 @@ Create a few Reporters::
Create an Article::
>>> from datetime import date
time
>>> a = Article(id=None, headline="This is a test", pub_date=date
time
(2005, 7, 27), reporter=r)
>>> from datetime import date
>>> a = Article(id=None, headline="This is a test", pub_date=date(2005, 7, 27), reporter=r)
>>> a.save()
>>> a.reporter.id
...
...
@@ -65,7 +65,7 @@ database, which always returns unicode strings)::
Create an Article via the Reporter object::
>>> new_article = r.article_set.create(headline="John's second story", pub_date=date
time
(2005, 7, 29))
>>> new_article = r.article_set.create(headline="John's second story", pub_date=date(2005, 7, 29))
>>> new_article
<Article: John's second story>
>>> new_article.reporter
...
...
@@ -75,7 +75,7 @@ Create an Article via the Reporter object::
Create a new article, and add it to the article set::
>>> new_article2 = Article(headline="Paul's story", pub_date=date
time
(2006, 1, 17))
>>> new_article2 = Article(headline="Paul's story", pub_date=date(2006, 1, 17))
>>> r.article_set.add(new_article2)
>>> new_article2.reporter
<Reporter: John Smith>
...
...
docs/topics/db/queries.txt
Dosyayı görüntüle @
e69348b4
...
...
@@ -35,8 +35,8 @@ models, which comprise a Weblog application:
blog = models.ForeignKey(Blog)
headline = models.CharField(max_length=255)
body_text = models.TextField()
pub_date = models.Date
Time
Field()
mod_date = models.Date
Time
Field()
pub_date = models.DateField()
mod_date = models.DateField()
authors = models.ManyToManyField(Author)
n_comments = models.IntegerField()
n_pingbacks = models.IntegerField()
...
...
@@ -233,7 +233,7 @@ refinements together. For example::
>>> Entry.objects.filter(
... headline__startswith='What'
... ).exclude(
... pub_date__gte=datetime.
now
()
... pub_date__gte=datetime.
date.today
()
... ).filter(
... pub_date__gte=datetime(2005, 1, 30)
... )
...
...
@@ -258,8 +258,8 @@ stored, used and reused.
Example::
>> q1 = Entry.objects.filter(headline__startswith="What")
>> q2 = q1.exclude(pub_date__gte=datetime.
now
())
>> q3 = q1.filter(pub_date__gte=datetime.
now
())
>> q2 = q1.exclude(pub_date__gte=datetime.
date.today
())
>> q3 = q1.filter(pub_date__gte=datetime.
date.today
())
These three ``QuerySets`` are separate. The first is a base
:class:`~django.db.models.query.QuerySet` containing all entries that contain a
...
...
@@ -282,7 +282,7 @@ actually run the query until the :class:`~django.db.models.query.QuerySet` is
*evaluated*. Take a look at this example::
>>> q = Entry.objects.filter(headline__startswith="What")
>>> q = q.filter(pub_date__lte=datetime.
now
())
>>> q = q.filter(pub_date__lte=datetime.
date.today
())
>>> q = q.exclude(body_text__icontains="food")
>>> print(q)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment