Modified:
trunk/docs/model-api.txt
Log:
Seção Referência do modelo, Tipos de campos, AutoField, NullBooleanField, PositiveIntegerField e partes de outras seções traduzidos
Modified: trunk/docs/model-api.txt
==============================================================================
--- trunk/docs/model-api.txt (original)
+++ trunk/docs/model-api.txt Fri Jul 25 11:09:52 2008
@@ -17,9 +17,9 @@
Referência do modelo
====================
-A model is the single, definitive source of data about your data. It contains
-the essential fields and behaviors of the data you're storing. Generally, each
-model maps to a single database table.
+Um modelo é a fonte única e definitiva de dados sobre os seus dados. Ele contém
+os campos essenciais e comportamentos dos dados que você está gravando. Geralmente, cada
+modelo mapeia para uma única tabela no banco de dados.
O básico:
@@ -32,12 +32,12 @@
* Com isso, o Django dá a você uma API de acesso a banco de dados gerada automaticamente,
o que é explicado em `Referência da API de banco de dados`_.
-A companion to this document is the `official repository of model examples`_.
-(In the Django source distribution, these examples are in the
-``tests/modeltests`` directory.)
+Um companheiro para esse documento é o `repositório oficial de exemplos de modelo`_.
+(Na distribuição do fonte do Django, esses exemplos estão no diretório
+``tests/modeltests``.)
.. _Referência da API de banco de dados: ../db-api/
-.. _official repository of model examples: ../models/
+.. _repositório oficial de exemplos de modelo: ../models/
Exemplo rápido
==============
@@ -64,10 +64,10 @@
Algumas notas técnicas:
- * The name of the table, ``myapp_person``, is automatically derived from
- some model metadata but can be overridden. See `Table names`_ below.
- * An ``id`` field is added automatically, but this behavior can be
- overridden. See `Automatic primary key fields`_ below.
+ * O nome da tabela, ``myapp_person``, é automaticamente derivado de alguns metadados
+ do modelo, mas pode ser sobrescrito. Veja `Nomes de tabelas`_ abaixo.
+ * Um campo ``id`` é adicionado automaticamente, mas esse comportamento pode ser
+ alterado. Veja `Campos de chave primária automáticos`_ abaixo.
* The ``CREATE TABLE`` SQL in this example is formatted using PostgreSQL
syntax, but it's worth noting Django uses SQL tailored to the database
backend specified in your `settings file`_.
@@ -94,8 +94,8 @@
release_date = models.DateField()
num_stars = models.IntegerField()
-Field name restrictions
------------------------
+Restrições de nome de campos
+----------------------------
Django places only two restrictions on model field names:
@@ -122,24 +122,24 @@
Tipos de campos
---------------
-Each field in your model should be an instance of the appropriate ``Field``
-class. Django uses the field class types to determine a few things:
+Cada campo no seu modelo deve ser uma instância da classe ``Field`` apropriada.
+O Django usa os tipos das classes para determinar algumas coisas:
- * The database column type (e.g. ``INTEGER``, ``VARCHAR``).
- * The widget to use in Django's admin interface, if you care to use it
- (e.g. ``<input type="text">``, ``<select>``).
- * The minimal validation requirements, used in Django's admin and in
- manipulators.
+ * O tipo de coluna no banco de dados (ex: ``INTEGER``, ``VARCHAR``).
+ * O widget a ser usado na interface administrativa do Django, se você a utilizar
+ (ex: ``<input type="text">``, ``<select>``).
+ * Os requerimentos mínimos de validação, usados no site administrativo do Django
+ e nos manipuladores.
-Here are all available field types:
+Aqui estão todos os tipos disponíveis:
``AutoField``
~~~~~~~~~~~~~
-An ``IntegerField`` that automatically increments according to available IDs.
-You usually won't need to use this directly; a primary key field will
-automatically be added to your model if you don't specify otherwise. See
-`Automatic primary key fields`_.
+Um ``IntegerField`` que incrementa seu valor automaticamente de acordo com os IDs disponíveis.
+Você normalmente não precisa usá-lo diretamente; um campo de chave primária será
+automaticamente adicionado ao seu modelo se você não especificar um. Veja
+`Campos de chave primária automáticos`_.
``BooleanField``
~~~~~~~~~~~~~~~~
@@ -174,10 +174,10 @@
``DateField``
~~~~~~~~~~~~~
-A date field. Has a few extra optional arguments:
+Um campo de data. Tem alguns argumentos opcionais extras:
====================== ===================================================
- Argument Description
+ Argumento Descrição
====================== ===================================================
``auto_now`` Automatically set the field to now every time the
object is saved. Useful for "last-modified"
@@ -199,7 +199,7 @@
``DateTimeField``
~~~~~~~~~~~~~~~~~
-A date and time field. Takes the same extra options as ``DateField``.
+Um campo de data e hora. Takes the same extra options as ``DateField``.
The admin represents this as two ``<input type="text">`` fields, with
JavaScript shortcuts.
@@ -236,7 +236,7 @@
``EmailField``
~~~~~~~~~~~~~~
-A ``CharField`` that checks that the value is a valid e-mail address.
+Um ``CharField`` que verifica se o valor é um e-mail válido.
In Django 0.96, this doesn't accept ``max_length``; its ``max_length`` is
automatically set to 75. In the Django development version, ``max_length`` is
@@ -379,7 +379,7 @@
``FileField``, an ``ImageField`` also has ``get_FOO_height()`` and
``get_FOO_width()`` methods. These are documented elsewhere_.
-Requires the `Python Imaging Library`_.
+Requer a `Python Imaging Library`_.
.. _Python Imaging Library: http://www.pythonware.com/products/pil/
.. _elsewhere: ../db-api/#get-foo-height-and-get-foo-width
@@ -392,24 +392,24 @@
``IntegerField``
~~~~~~~~~~~~~~~~
-An integer.
+Um inteiro.
The admin represents this as an ``<input type="text">`` (a single-line input).
``IPAddressField``
~~~~~~~~~~~~~~~~~~
-An IP address, in string format (e.g. "192.0.2.30").
+Um endereço IP, em formato texto (ex: "192.0.2.30").
The admin represents this as an ``<input type="text">`` (a single-line input).
``NullBooleanField``
~~~~~~~~~~~~~~~~~~~~
-Like a ``BooleanField``, but allows ``NULL`` as one of the options. Use this
-instead of a ``BooleanField`` with ``null=True``.
+Como um ``BooleanField``, mas permite ``NULL`` como uma das opções. Use-o no lugar
+de um ``BooleanField`` com ``null=True``.
-The admin represents this as a ``<select>`` box with "Unknown", "Yes" and "No" choices.
+O admin o representa como um ``<select>`` box com as escolhas "Unknown", "Yes" e "No".
``PhoneNumberField``
~~~~~~~~~~~~~~~~~~~~
@@ -420,7 +420,7 @@
``PositiveIntegerField``
~~~~~~~~~~~~~~~~~~~~~~~~
-Like an ``IntegerField``, but must be positive.
+Como um ``IntegerField``, mas deve ser positivo.
``PositiveSmallIntegerField``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -477,7 +477,7 @@
``URLField``
~~~~~~~~~~~~
-A field for a URL. If the ``verify_exists`` option is ``True`` (default),
+Um campo para URL. If the ``verify_exists`` option is ``True`` (default),
the URL given will be checked for existence (i.e., the URL actually loads
and doesn't give a 404 response).
@@ -512,8 +512,8 @@
``null``
~~~~~~~~
-If ``True``, Django will store empty values as ``NULL`` in the database.
-Default is ``False``.
+Se ``True``, o Django irá gravar valores vazios como ``NULL`` no banco de dados.
+O padrão é ``False``.
Note that empty string values will always get stored as empty strings, not
as ``NULL``. Only use ``null=True`` for non-string fields such as integers,
@@ -641,7 +641,7 @@
``default``
~~~~~~~~~~~
-The default value for the field. This can be a value or a callable object. If
+O valor padrão para o campo. This can be a value or a callable object. If
callable it will be called every time a new object is created.
``editable``
@@ -667,7 +667,7 @@
``primary_key``
~~~~~~~~~~~~~~~
-If ``True``, this field is the primary key for the model.
+Se ``True``, esse campo será a chave primária para o modelo.
If you don't specify ``primary_key=True`` for any fields in your model,
Django will automatically add this field::
@@ -714,18 +714,18 @@
``unique_for_month``
~~~~~~~~~~~~~~~~~~~~
-Like ``unique_for_date``, but requires the field to be unique with respect
-to the month.
+Semelhante ao ``unique_for_date``, mas requer que o campo seja único com respeito
+ao mês.
``unique_for_year``
~~~~~~~~~~~~~~~~~~~
-Like ``unique_for_date`` and ``unique_for_month``.
+Semelhante a ``unique_for_date`` e ``unique_for_month``.
``validator_list``
~~~~~~~~~~~~~~~~~~
-A list of extra validators to apply to the field. Each should be a callable
+Uma lista de validadores extras para aplicar ao campo. Each should be a callable
that takes the parameters ``field_data, all_data`` and raises
``django.core.validators.ValidationError`` for errors. (See the
`validator docs`_.)
@@ -760,15 +760,15 @@
Convention is not to capitalize the first letter of the ``verbose_name``.
Django will automatically capitalize the first letter where it needs to.
-Relationships
--------------
+Relacionamentos
+---------------
Clearly, the power of relational databases lies in relating tables to each
other. Django offers ways to define the three most common types of database
relationships: Many-to-one, many-to-many and one-to-one.
-Many-to-one relationships
-~~~~~~~~~~~~~~~~~~~~~~~~~
+Relacionamentos muitos-para-um
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To define a many-to-one relationship, use ``ForeignKey``. You use it just like
any other ``Field`` type: by including it as a class attribute of your model.
@@ -915,12 +915,12 @@
.. _abstract base class: `Classes Bases Abstratas`_
.. _extra notes: `Be careful with related_name`_
-Many-to-many relationships
-~~~~~~~~~~~~~~~~~~~~~~~~~~
+Relacionamentos muitos-para-muitos
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-To define a many-to-many relationship, use ``ManyToManyField``. You use it just
-like any other ``Field`` type: by including it as a class attribute of your
-model.
+Para definir um relacionamento muitos-para-muitos, use o ``ManyToManyField``. Você o utiliza
+como qualquer outro ``Field``: incluindo ele como um atributo de classe do seu
+modelo.
``ManyToManyField`` requires a positional argument: the class to which the
model is related.
@@ -964,11 +964,11 @@
.. _Many-to-many relationship model example: ../models/many_to_many/
-``ManyToManyField`` objects take a number of extra arguments for defining how
-the relationship should work. All are optional:
+Objetos ``ManyToManyField`` podem receber alguns argumentos extras que definem
+como o relacionamento deve funcionar. Todos são opcionais:
======================= ============================================================
- Argument Description
+ Argumento Descrição
======================= ============================================================
``related_name`` See the description under ``ForeignKey`` above.
@@ -1006,12 +1006,11 @@
======================= ============================================================
-One-to-one relationships
-~~~~~~~~~~~~~~~~~~~~~~~~
+Relacionamentos um-para-um
+~~~~~~~~~~~~~~~~~~~~~~~~~~
-To define a one-to-one relationship, use ``OneToOneField``. You use it just
-like any other ``Field`` type: by including it as a class attribute of your
-model.
+Para definir um relacionamento um-para-um, use o ``OneToOneField``. Você deve utilizá-lo
+como qualquer outro ``Field``: incluindo-o como um atributo de classe em seu modelo.
This is most useful on the primary key of an object when that object "extends"
another object in some way.
@@ -1088,8 +1087,8 @@
**New in Django development version**
-When set to ``True``, denotes this model as an abstract base class. See
-`Classes Bases Abstratas`_ for more details. Defaults to ``False``.
+Quando configurado para ``True``, indica que esse modelo é uma classe base abstrata. Veja
+`Classes Bases Abstratas`_ para mais detalhes. O padrão é ``False``.
``db_table``
------------
@@ -1110,8 +1109,8 @@
**New in Django development version**
-The name of the database tablespace to use for the model. If the backend
-doesn't support tablespaces, this option is ignored.
+O nome do tablespace do banco de dados para usar no modelo. Se o backend
+não suporta tablespaces, essa opção é ignorada.
``get_latest_by``
-----------------
@@ -1146,32 +1145,32 @@
``ordering``
------------
-The default ordering for the object, for use when obtaining lists of objects::
+A ordenação padrão para o objeto, para uso na obtenção de listas de objetos::
ordering = ['-order_date']
-This is a tuple or list of strings. Each string is a field name with an
-optional "-" prefix, which indicates descending order. Fields without a
-leading "-" will be ordered ascending. Use the string "?" to order randomly.
+Isso é uma tupla ou lista de strings. Cada string é um nome de campo com um
+prefixo "-" opcional, que indica ordem descendente. Campos sem um "-" inicial
+serão ordenados em ordem ascendente. Usa a string "?" para ordenar aleatoriamente.
-For example, to order by a ``pub_date`` field ascending, use this::
+Por exemplo, para ordenar por um campo ``pub_date`` ascendentemente, use isso::
ordering = ['pub_date']
-To order by ``pub_date`` descending, use this::
+Para ordenar por um campo ``pub_date`` descendentemente, use isso::
ordering = ['-pub_date']
-To order by ``pub_date`` descending, then by ``author`` ascending, use this::
+Para ordenar por ``pub_date`` desendentemente, então, então, por ``author`` ascendentemente, use isso::
ordering = ['-pub_date', 'author']
-See `Specifying ordering`_ for more examples.
+Veja `Especificando ordenação`_ para mais exemplos.
-Note that, regardless of how many fields are in ``ordering``, the admin
-site uses only the first field.
+Note que o site administratiovo usa apenas o primeiro campo, não importa quantos campos estejam
+definidos em ``ordering``.
-.. _Specifying ordering: ../models/ordering/
+.. _Especificando ordenação: ../models/ordering/
``permissions``
---------------
@@ -1228,8 +1227,8 @@
If this isn't given, Django will use ``verbose_name + "s"``.
-Table names
-===========
+Nomes de tabelas
+================
To save you time, Django automatically derives the name of the database table
from the name of your model class and the app that contains it. A model's
@@ -1244,8 +1243,8 @@
To override the database table name, use the ``db_table`` parameter in
``class Meta``.
-Automatic primary key fields
-============================
+Campos de chave primária automáticos
+====================================
By default, Django gives each model the following field::
@@ -1259,8 +1258,8 @@
Each model requires exactly one field to have ``primary_key=True``.
-The ``pk`` property
--------------------
+A propriedade ``pk``
+--------------------
**New in Django development version**
Regardless of whether you define a primary key field yourself, or let Django
@@ -1365,22 +1364,22 @@
``classes``
~~~~~~~~~~~
-A string containing extra CSS classes to apply to the fieldset.
+Uma string contento classes CSS extras para aplicar ao fieldset.
-Example::
+Exemplo::
{
'classes': 'wide',
}
-Apply multiple classes by separating them with spaces. Example::
+Aplique múltiplas classes separando-as com espaços. Exemplo::
{
'classes': 'wide extrapretty',
}
-Two useful classes defined by the default admin-site stylesheet are
-``collapse`` and ``wide``. Fieldsets with the ``collapse`` style will be
+Duas classes úteis definidas pela folha de estilos padrão do site adminitrativo são
+``collapse`` e ``wide``. Fieldsets com o estilo ``collapse`` style will be
initially collapsed in the admin and replaced with a small "click to expand"
link. Fieldsets with the ``wide`` style will be given extra horizontal space.