democrasite.activitypub.models module¶
Models for the activitypub app.
- class democrasite.activitypub.models.Follow(*args, **kwargs)¶
Bases:
ModelTimestamped record of a person following another
- Parameters:
id (BigAutoField) – Primary key: ID
created (DateTimeField) – Created
Relationship fields:
- Parameters:
following (
ForeignKeytoPerson) – Following (related name:follower_set)follower (
ForeignKeytoPerson) – Follower (related name:following_set)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- created¶
Type:
DateTimeFieldCreated
A wrapper for a deferred-loading field. When the value is read from this
- follower¶
Type:
ForeignKeytoPersonFollower (related name:
following_set)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')
- following¶
Type:
ForeignKeytoPersonFollowing (related name:
follower_set)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')
- get_next_by_created(*, field=<django.db.models.DateTimeField: created>, is_next=True, **kwargs)¶
Finds next instance based on
created. Seeget_next_by_FOO()for more information.
- get_previous_by_created(*, field=<django.db.models.DateTimeField: created>, is_next=False, **kwargs)¶
Finds previous instance based on
created. Seeget_previous_by_FOO()for more information.
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- objects = <django.db.models.Manager object>¶
- class democrasite.activitypub.models.Like(*args, **kwargs)¶
Bases:
ModelA model to represent a like on a Note by a Person.
- Parameters:
id (BigAutoField) – Primary key: ID
created (DateTimeField) – Created
Relationship fields:
- Parameters:
person (
ForeignKeytoPerson) – Person (related name:like)note (
ForeignKeytoNote) – Note (related name:like)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- created¶
Type:
DateTimeFieldCreated
A wrapper for a deferred-loading field. When the value is read from this
- get_next_by_created(*, field=<django.db.models.DateTimeField: created>, is_next=True, **kwargs)¶
Finds next instance based on
created. Seeget_next_by_FOO()for more information.
- get_previous_by_created(*, field=<django.db.models.DateTimeField: created>, is_next=False, **kwargs)¶
Finds previous instance based on
created. Seeget_previous_by_FOO()for more information.
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- note¶
Type:
ForeignKeytoNoteNote (related name:
like)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')
- objects = <django.db.models.Manager object>¶
- person¶
Type:
ForeignKeytoPersonPerson (related name:
like)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')
- class democrasite.activitypub.models.Note(*args, **kwargs)¶
Bases:
TimeStampedModel,MPTTModelA note in the ActivityPub network, representing a short piece of content.
- Parameters:
id (BigAutoField) – Primary key: ID
created (AutoCreatedField) – Created
modified (AutoLastModifiedField) – Modified
content (TextField) – Content
lft (PositiveIntegerField) – Lft
rght (PositiveIntegerField) – Rght
tree_id (PositiveIntegerField) – Tree id
level (PositiveIntegerField) – Level
Relationship fields:
- Parameters:
author (
ForeignKeytoPerson) – Author (related name:notes)in_reply_to (
TreeForeignKeytoNote) – In reply to (related name:replies)likes (
ManyToManyFieldtoPerson) – Likes (related name:likes)reposts (
ManyToManyFieldtoPerson) – Reposts (related name:reposts)
Reverse relationships:
- Parameters:
like (Reverse
ForeignKeyfromLike) – All likes of this note (related name ofnote)repost (Reverse
ForeignKeyfromRepost) – All reposts of this note (related name ofnote)replies (Reverse
TreeForeignKeyfromNote) – All replies of this note (related name ofin_reply_to)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- author¶
Type:
ForeignKeytoPersonAuthor (related name:
notes)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')
- content¶
Type:
TextFieldContent
A wrapper for a deferred-loading field. When the value is read from this
- created¶
Type:
AutoCreatedFieldCreated
A wrapper for a deferred-loading field. When the value is read from this
- get_absolute_url()¶
Get the URL for the note’s detail view.
- Returns:
URL for the note detail.
- Return type:
- get_like_url()¶
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
Finds next instance based on
created. Seeget_next_by_FOO()for more information.
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
Finds next instance based on
modified. Seeget_next_by_FOO()for more information.
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
Finds previous instance based on
created. Seeget_previous_by_FOO()for more information.
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
Finds previous instance based on
modified. Seeget_previous_by_FOO()for more information.
- get_repost_url()¶
- history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>¶
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- in_reply_to¶
Type:
TreeForeignKeytoNoteIn reply to (related name:
replies)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')
- in_reply_to_id¶
Internal field, use
in_reply_toinstead.
- level¶
Type:
PositiveIntegerFieldLevel
A wrapper for a deferred-loading field. When the value is read from this
- lft¶
Type:
PositiveIntegerFieldLft
A wrapper for a deferred-loading field. When the value is read from this
- like_set¶
Type: Reverse
ForeignKeyfromLikeAll likes of this note (related name of
note)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- likes¶
Type:
ManyToManyFieldtoPersonLikes (related name:
likes)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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- modified¶
Type:
AutoLastModifiedFieldModified
A wrapper for a deferred-loading field. When the value is read from this
- objects = <democrasite.activitypub.models.NoteManager object>¶
- replies¶
Type: Reverse
TreeForeignKeyfromNoteAll replies of this note (related name of
in_reply_to)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- repost_set¶
Type: Reverse
ForeignKeyfromRepostAll reposts of this note (related name of
note)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- reposts¶
Type:
ManyToManyFieldtoPersonReposts (related name:
reposts)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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- rght¶
Type:
PositiveIntegerFieldRght
A wrapper for a deferred-loading field. When the value is read from this
- save_without_historical_record(*args, **kwargs)¶
Save the model instance without creating a historical record.
Make sure you know what you’re doing before using this method.
- tree_id¶
Type:
PositiveIntegerFieldTree id
A wrapper for a deferred-loading field. When the value is read from this
- class democrasite.activitypub.models.NoteManager(*args, **kwargs)¶
Bases:
TreeManager- get_person_following_notes(person: Person) QuerySet¶
Get notes from people the person is following.
This method retrieves all notes authored or reposted by people that the specified person is following, ordered by the creation or repost time of the notes. This method removes duplicate notes.
- Parameters:
person (Person) – The person whose following notes are to be retrieved.
- Returns:
A queryset of notes and reposts from followed persons, ordered by time.
- Return type:
models.QuerySet[T]
- get_person_notes(person: Person) QuerySet¶
Get notes for display on a person’s profile page.
This method returns all notes authored by the person as well as all their reposts, ordered by their creation or repost time. Reposts are annotated with the reposted_by and reposted_at fields for use in templates. If a user has reposted their own note, both the original note and the repost will be included in the results.
- Parameters:
person (Person) – The person whose notes and reposts are to be retrieved.
- Returns:
A queryset of notes and reposts ordered by time.
- Return type:
models.QuerySet[T]
- class democrasite.activitypub.models.Person(*args, **kwargs)¶
Bases:
TimeStampedModelA person in the ActivityPub network, linked to a Django User.
- Parameters:
id (BigAutoField) – Primary key: ID
created (AutoCreatedField) – Created
modified (AutoLastModifiedField) – Modified
private_key (TextField) – Private key
public_key (TextField) – Public key
bio (TextField) – Bio. A short biography or description of the person
Relationship fields:
- Parameters:
user (
OneToOneFieldtoUser) – User (related name:person)following (
ManyToManyFieldtoPerson) – Following. People this person is following (related name:followers)
Reverse relationships:
- Parameters:
follower_set (Reverse
ForeignKeyfromFollow) – All follower set of this person (related name offollowing)following_set (Reverse
ForeignKeyfromFollow) – All following set of this person (related name offollower)followers (Reverse
ManyToManyFieldfromPerson) – All followers of this person (related name offollowing)like (Reverse
ForeignKeyfromLike) – All likes of this person (related name ofperson)repost (Reverse
ForeignKeyfromRepost) – All reposts of this person (related name ofperson)notes (Reverse
ForeignKeyfromNote) – All notes of this person (related name ofauthor)likes (Reverse
ManyToManyFieldfromNote) – All likes of this person (related name oflikes)reposts (Reverse
ManyToManyFieldfromNote) – All reposts of this person (related name ofreposts)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- bio¶
Type:
TextFieldBio. A short biography or description of the person
A wrapper for a deferred-loading field. When the value is read from this
- created¶
Type:
AutoCreatedFieldCreated
A wrapper for a deferred-loading field. When the value is read from this
- property display_name¶
Get the display name for the person.
- Returns:
The username of the person.
- Return type:
- follower_set¶
Type: Reverse
ForeignKeyfromFollowAll follower set of this person (related name of
following)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- followers¶
Type: Reverse
ManyToManyFieldfromPersonAll followers of this person (related name of
following)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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- following¶
Type:
ManyToManyFieldtoPersonFollowing. People this person is following (related name:
followers)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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- following_set¶
Type: Reverse
ForeignKeyfromFollowAll following set of this person (related name of
follower)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- get_absolute_url()¶
Get the URL for the person’s detail view.
- Returns:
URL for the person detail.
- Return type:
- get_follow_url()¶
- get_next_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=True, **kwargs)¶
Finds next instance based on
created. Seeget_next_by_FOO()for more information.
- get_next_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=True, **kwargs)¶
Finds next instance based on
modified. Seeget_next_by_FOO()for more information.
- get_previous_by_created(*, field=<model_utils.fields.AutoCreatedField: created>, is_next=False, **kwargs)¶
Finds previous instance based on
created. Seeget_previous_by_FOO()for more information.
- get_previous_by_modified(*, field=<model_utils.fields.AutoLastModifiedField: modified>, is_next=False, **kwargs)¶
Finds previous instance based on
modified. Seeget_previous_by_FOO()for more information.
- history = <django.db.models.manager.HistoryManagerFromHistoricalQuerySet object>¶
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- like_set¶
Type: Reverse
ForeignKeyfromLikeAll likes of this person (related name of
person)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- likes¶
Type: Reverse
ManyToManyFieldfromNoteAll likes of this person (related name of
likes)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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- modified¶
Type:
AutoLastModifiedFieldModified
A wrapper for a deferred-loading field. When the value is read from this
- notes¶
Type: Reverse
ForeignKeyfromNoteAll notes of this person (related name of
author)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- objects = <democrasite.activitypub.models.PersonManager object>¶
- private_key¶
Type:
TextFieldPrivate key
A wrapper for a deferred-loading field. When the value is read from this
- public_key¶
Type:
TextFieldPublic key
A wrapper for a deferred-loading field. When the value is read from this
- repost_set¶
Type: Reverse
ForeignKeyfromRepostAll reposts of this person (related name of
person)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.childrenis aReverseManyToOneDescriptorinstance.Most of the implementation is delegated to a dynamically defined manager
- reposts¶
Type: Reverse
ManyToManyFieldfromNoteAll reposts of this person (related name of
reposts)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.toppingsandTopping.pizzasareManyToManyDescriptorinstances.Most of the implementation is delegated to a dynamically defined manager
- save_without_historical_record(*args, **kwargs)¶
Save the model instance without creating a historical record.
Make sure you know what you’re doing before using this method.
- user¶
Type:
OneToOneFieldtoUserUser (related name:
person)Accessor to the related object on the forward side of a one-to-one relation.
In the example:
class Restaurant(Model): place = OneToOneField(Place, related_name='restaurant')
- class democrasite.activitypub.models.PersonManager(*args, **kwargs)¶
Bases:
ManagerManager for Person model with user prefetched.
- get_queryset()¶
Return a new QuerySet object. Subclasses can override this method to customize the behavior of the Manager.
- class democrasite.activitypub.models.Repost(*args, **kwargs)¶
Bases:
ModelA model to represent a repost of a Note by a Person.
- Parameters:
id (BigAutoField) – Primary key: ID
created (DateTimeField) – Created
Relationship fields:
- Parameters:
person (
ForeignKeytoPerson) – Person (related name:repost)note (
ForeignKeytoNote) – Note (related name:repost)
- exception DoesNotExist¶
Bases:
ObjectDoesNotExist
- exception MultipleObjectsReturned¶
Bases:
MultipleObjectsReturned
- created¶
Type:
DateTimeFieldCreated
A wrapper for a deferred-loading field. When the value is read from this
- get_next_by_created(*, field=<django.db.models.DateTimeField: created>, is_next=True, **kwargs)¶
Finds next instance based on
created. Seeget_next_by_FOO()for more information.
- get_previous_by_created(*, field=<django.db.models.DateTimeField: created>, is_next=False, **kwargs)¶
Finds previous instance based on
created. Seeget_previous_by_FOO()for more information.
- id¶
Type:
BigAutoFieldPrimary key: ID
A wrapper for a deferred-loading field. When the value is read from this
- note¶
Type:
ForeignKeytoNoteNote (related name:
repost)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')
- objects = <django.db.models.Manager object>¶
- person¶
Type:
ForeignKeytoPersonPerson (related name:
repost)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')