db package

Subpackages

Submodules

db.admin module

db.apps module

class db.apps.DbConfig(app_name, app_module)[source]

Bases: AppConfig

default_auto_field = 'django.db.models.BigAutoField'
name = 'db'

db.models module

class db.models.Avatar(id, avatar_owner, avatar_type, pet_name, flavour_text)[source]

Bases: Model

class AvatarType(value)[source]

Bases: TextChoices

An enumeration.

CAT = 'CT'
CRAB = 'CR'
DOG = 'DG'
ROCK = 'RK'
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

avatar_owner

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

avatar_owner_id
avatar_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

flavour_text

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_avatar_type_display(*, field=<django.db.models.fields.CharField: avatar_type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

last_feed

alias of DateField

last_interaction

alias of DateField

objects = <django.db.models.manager.Manager object>
pet_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

total_xp

alias of PositiveIntegerField

class db.models.CustomAccountManager(*args, **kwargs)[source]

Bases: BaseUserManager

Class responsible for the creation of superusers and standard users. Overrides built-in user class and constructor. Extends BaseUserManager.

create_superuser(email, user_name, first_name, password, **other_fields)[source]

Returns a superuser User object upon successful creation.

Parameters:
  • email (str) – user’s email, unique

  • user_name (str) – user’s username, unique

  • first_name (str) – user’s first name

  • password (str) – user’s password, hashed then stored

  • other_fields (dict) – additional keyword arguments: is_staff, is_superuser, is_active

create_user(email, user_name, first_name, password, **other_fields)[source]

Returns a standard User object upon successful creation.

Parameters:
  • email (str) – user’s email, unique

  • user_name (str) – user’s username, unique

  • first_name (str) – user’s first name

  • password (str) – user’s password, hashed then stored

  • other_fields (dict) – additional keyword arguments: is_staff, is_superuser, is_active

class db.models.Inventory(*args, **kwargs)[source]

Bases: Model

Class defining the model for the Inventory Extends models.Model.

class BaseType(value)[source]

Bases: TextChoices

Class defining the model for candy size Extends models.TextChoices.

CAKE = 'C'
LARGE = 'L'
MEDIUM = 'M'
SMALL = 'S'
class CandyLevel(value)[source]

Bases: IntegerChoices

Class defining the model for candy levels Extends models.IntegerChoices.

ADVANCED = 4
BEGINNER = 1
EXPERT = 5
INTERMEDIATE = 3
NOVICE = 2
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

candy_base_type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

candy_level

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_candy_base_type_display(*, field=<django.db.models.fields.CharField: candy_base_type>)
get_candy_level_display(*, field=<django.db.models.fields.PositiveIntegerField: candy_level>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

inventory_owner

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

inventory_owner_id
objects = <django.db.models.manager.Manager object>
quantity

alias of PositiveIntegerField

class db.models.NewUser(*args, **kwargs)[source]

Bases: AbstractBaseUser, PermissionsMixin

Class responsible for creating and storing account information for a user Extends AbstractBaseUser and PermissionsMixin.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

REQUIRED_FIELDS = ['user_name', 'first_name']
USERNAME_FIELD = 'email'
avatar_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

bio

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

birthday

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

email

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

first_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

get_next_by_join_date(*, field=<django.db.models.fields.DateTimeField: join_date>, is_next=True, **kwargs)
get_previous_by_join_date(*, field=<django.db.models.fields.DateTimeField: join_date>, is_next=False, **kwargs)
groups

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

inventory_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

is_staff

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

join_date

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

logentry_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

objects = <db.models.CustomAccountManager object>
task_set

Accessor to the related objects manager on the reverse side of a many-to-one relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Parent.children is a ReverseManyToOneDescriptor instance.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

user_name

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

user_permissions

Accessor to the related objects manager on the forward and reverse sides of a many-to-many relation.

In the example:

class Pizza(Model):
    toppings = ManyToManyField(Topping, related_name='pizzas')

Pizza.toppings and Topping.pizzas are ManyToManyDescriptor instances.

Most of the implementation is delegated to a dynamically defined manager class built by create_forward_many_to_many_manager() defined below.

class db.models.Task(*args, **kwargs)[source]

Bases: Model

Class definiing the model for a Task Extends models.Model.

class BaseType(value)[source]

Bases: TextChoices

An enumeration.

CAKE = 'C'
LARGE = 'L'
MEDIUM = 'M'
SMALL = 'S'
exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

active

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

assignment_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

completed

alias of BooleanField

completed_date

alias of DateField

course_id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

created_date

alias of DateField

description

alias of TextField

due_date

alias of DateTimeField

get_type_display(*, field=<django.db.models.fields.CharField: type>)
id

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

objects = <django.db.models.manager.Manager object>
recurring

alias of BooleanField

recurring_time_delta

alias of PositiveIntegerField

type

A wrapper for a deferred-loading field. When the value is read from this object the first time, the query is executed.

username

Accessor to the related object on the forward side of a many-to-one or one-to-one (via ForwardOneToOneDescriptor subclass) relation.

In the example:

class Child(Model):
    parent = ForeignKey(Parent, related_name='children')

Child.parent is a ForwardManyToOneDescriptor instance.

username_id

db.serializers module

class db.serializers.RegisterUserSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

class Meta[source]

Bases: object

extra_kwargs = {'password': {'write_only': True}}
fields = ('email', 'user_name', 'password')
model

alias of NewUser

create(validated_data)[source]

We have a bit of extra checking around this in order to provide descriptive messages when something goes wrong, but this method is essentially just:

return ExampleModel.objects.create(**validated_data)

If there are many to many fields present on the instance then they cannot be set until the model is instantiated, in which case the implementation is like so:

example_relationship = validated_data.pop(‘example_relationship’) instance = ExampleModel.objects.create(**validated_data) instance.example_relationship = example_relationship return instance

The default implementation also does not handle nested relationships. If you want to support writable nested relationships you’ll need to write an explicit .create() method.

db.tests module

db.urls module

db.views module

class db.views.CustomUserCreate(**kwargs)[source]

Bases: APIView

permission_classes = [<class 'rest_framework.permissions.AllowAny'>]
post(request)[source]

Module contents