Skip to content

Commit

Permalink
Fixed chamber documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
matllubos committed Jan 15, 2019
1 parent 4e5e8dd commit 78d5d35
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions chamber/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,12 +251,12 @@ def fast_distinct(self):
"""
return self.model.objects.filter(pk__in=self.values_list('pk', flat=True))

def change_and_save(self, update_only_changed_fields=False, **chaned_fields):
def change_and_save(self, update_only_changed_fields=False, **changed_fields):
"""
Changes a given `changed_fields` on each object in the queryset, saves objects
and returns the changed objects in the queryset.
"""
bulk_change_and_save(self, update_only_changed_fields=update_only_changed_fields, **chaned_fields)
bulk_change_and_save(self, update_only_changed_fields=update_only_changed_fields, **changed_fields)
return self.filter()


Expand Down
14 changes: 7 additions & 7 deletions docs/models.rst
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,11 @@ SmartModel

.. attribute:: initial_values

Returns dict initial values of all instance fields that were loaded from the database. If object is not store in the database the values will be ``Unknown`` which is similar object to ``None`` value
Returns dict initial values of all instance fields that were loaded from the database. If object is not stored in the database the values will be ``Unknown`` which is similar object to ``None`` value

.. attribute:: changed_fields

Returns ``ChangedFields`` instance that contains information what fields have been changed and how
Returns ``ChangedFields`` instance that contains information which fields have been changed and how

.. method:: clean_<field_name>()

Expand Down Expand Up @@ -141,11 +141,11 @@ SmartModel

.. method:: change(**changed_fields)

Update instance field values with values send in ``changed_fields``
Update instance field values with values sent in ``changed_fields``

.. method:: change_and_save(update_only_changed_fields=False, **changed_fields)

Update instance field values with values send in ``changed_fields`` and finally instance is saved. If you want to update only changed fields in the database you can use parameter ``update_only_changed_fields`` to achieve it
Update instance field values with values sent in ``changed_fields`` and finally instance is saved. If you want to update only changed fields in the database you can use parameter ``update_only_changed_fields`` to achieve it


SmartMeta
Expand Down Expand Up @@ -197,7 +197,7 @@ Unknown
ChangedFields
-------------

``chamber.models.ChangedFields`` is dict-like class that is used for storing what fields of model instance was changed
``chamber.models.ChangedFields`` is dict-like class that is used for storing which fields of model instance were changed

::

Expand Down Expand Up @@ -236,7 +236,7 @@ ChangedFields

.. method:: has_any_key(*keys)

Return if on of the fields ``keys`` were changed
Return if any of the fields ``keys`` were changed

.. method:: keys()

Expand Down Expand Up @@ -280,7 +280,7 @@ will assume the custom filters to be there).
.. method:: change_and_save(update_only_changed_fields=False, **changed_fields)

Change selected fields on the selected queryset and saves it, finnaly is returned changed objects in the queryset. Difference from update is that there is called save method on the instance, but it is slower. If you want to update only changed fields in the database you can use parameter ``update_only_changed_fields`` to achieve it
Changes selected fields on the selected queryset and saves it and returns changed objects in the queryset. Difference from update is that there is called save method on the instance, but it is slower. If you want to update only changed fields in the database you can use parameter ``update_only_changed_fields`` to achieve it



Expand Down
6 changes: 3 additions & 3 deletions docs/shortcuts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Shortcut for ``chamber.shortcuts.filter_or_exclude_by_date`` with first paramete

.. function:: chamber.shortcuts.change(obj, **changed_fields)

Helper for changing model instance fields without saving. All field names are validated if really exists.
Helper for changing model instance fields without saving. All field names are validated if really exist.

::

Expand All @@ -94,7 +94,7 @@ Helper for changing model instance fields with saving. If you can update only re

.. function:: chamber.shortcuts.bulk_change(iterable, **changed_fields)

Ganges model instances in the given iterable without saving.
Changes model instances in the given iterable without saving.

::
>>> users = User.objects.filter(last_name='Gaul')
Expand All @@ -106,7 +106,7 @@ Ganges model instances in the given iterable without saving.

.. function:: chamber.shortcuts.bulk_change_and_save(iterable, update_only_changed_fields=False, **changed_fields)

Change model iinstances in the given iterable with saving. If you can update only really changed fields you can set ``update_only_changed_fields`` to ``True``.
Change model instances in the given iterable with saving. If you want to update only really changed fields you can set ``update_only_changed_fields`` to ``True``.

::
>>> users = User.objects.filter(last_name='Gaul')
Expand Down

0 comments on commit 78d5d35

Please sign in to comment.