Skip to content

Commit

Permalink
Merge pull request #17 from barseghyanartur/dev
Browse files Browse the repository at this point in the history
Improve docs (#16)
  • Loading branch information
barseghyanartur authored Dec 4, 2023
2 parents 60fe5a7 + 88cacf6 commit 7e925de
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ This is how you could define a factory for `Django`_'s built-in ``User`` model.
FileSystemStorage,
SubFactory,
pre_save,
trait,
)
STORAGE = FileSystemStorage(root_path=settings.MEDIA_ROOT, rel_path="tmp")
Expand All @@ -230,6 +231,12 @@ This is how you could define a factory for `Django`_'s built-in ``User`` model.
model = User
get_or_create = ("username",)
@trait
def is_admin_user(self, instance: User) -> None:
instance.is_superuser = True
instance.is_staff = True
instance.is_active = True
@pre_save
def __set_password(instance):
instance.set_password("test")
Expand All @@ -238,9 +245,15 @@ And this is how you could use it:

.. code-block:: python
# Create just one user
user = UserFactory()
# Create 5 users
users = UserFactory.create_batch(5)
# Create a user using `is_admin_user` trait
user = UserFactory(is_admin_user=True)
Tests
=====

Expand Down

0 comments on commit 7e925de

Please sign in to comment.