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
4f1eb64a
Kaydet (Commit)
4f1eb64a
authored
Haz 18, 2017
tarafından
François Freitag
Kaydeden (comit)
Tim Graham
Haz 19, 2017
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18485 -- Doc'd behavior of PostgreSQL when manually setting AutoField.
üst
e36598f9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
0 deletions
+30
-0
databases.txt
docs/ref/databases.txt
+27
-0
instances.txt
docs/ref/models/instances.txt
+3
-0
No files found.
docs/ref/databases.txt
Dosyayı görüntüle @
4f1eb64a
...
...
@@ -224,6 +224,33 @@ live for the duration of the transaction.
.. _pgBouncer: https://pgbouncer.github.io/
.. _manually-specified-autoincrement-pk:
Manually-specifying values of auto-incrementing primary keys
------------------------------------------------------------
Django uses PostgreSQL's `SERIAL data type`_ to store auto-incrementing primary
keys. A ``SERIAL`` column is populated with values from a `sequence`_ that
keeps track of the next available value. Manually assigning a value to an
auto-incrementing field doesn't update the field's sequence, which might later
cause a conflict. For example::
>>> from django.contrib.auth.models import User
>>> User.objects.create(username='alice', pk=1)
<User: alice>
>>> # The sequence hasn't been updated; its next value is 1.
>>> User.objects.create(username='bob')
...
IntegrityError: duplicate key value violates unique constraint
"auth_user_pkey" DETAIL: Key (id)=(1) already exists.
If you need to specify such values, reset the sequence afterwards to avoid
reusing a value that's already in the table. The :djadmin:`sqlsequencereset`
management command generates the SQL statements to do that.
.. _SERIAL data type: https://www.postgresql.org/docs/current/static/datatype-numeric.html#DATATYPE-SERIAL
.. _sequence: https://www.postgresql.org/docs/current/static/sql-createsequence.html
Test database templates
-----------------------
...
...
docs/ref/models/instances.txt
Dosyayı görüntüle @
4f1eb64a
...
...
@@ -426,6 +426,9 @@ happens.
Explicitly specifying auto-primary-key values is mostly useful for bulk-saving
objects, when you're confident you won't have primary-key collision.
If you're using PostgreSQL, the sequence associated with the primary key might
need to be updated; see :ref:`manually-specified-autoincrement-pk`.
What happens when you save?
---------------------------
...
...
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