app.view.dependency module

class app.view.dependency.HttpRequest[源代码]

基类:object

A basic HTTP request.

accepted_types

Return a list of MediaType instances.

accepts(media_type)[源代码]
property body
build_absolute_uri(location=None)[源代码]

Build an absolute URI from the location and the variables available in this request. If no location is specified, build the absolute URI using request.get_full_path(). If the location is absolute, convert it to an RFC 3987 compliant URI and return it. If location is relative or is scheme-relative (i.e., //example.com/), urljoin() it to a base URL constructed from the request variables.

close()[源代码]
property encoding
get_full_path(force_append_slash=False)[源代码]
get_full_path_info(force_append_slash=False)[源代码]
get_host()[源代码]

Return the HTTP host using the environment or request headers.

get_port()[源代码]

Return the port number for the request as a string.

Attempt to return a signed cookie. If the signature fails or the cookie has expired, raise an exception, unless the default argument is provided, in which case return that value.

headers
is_secure()[源代码]
parse_file_upload(META, post_data)[源代码]

Return a tuple of (POST QueryDict, FILES MultiValueDict).

read(*args, **kwargs)[源代码]
readline(*args, **kwargs)[源代码]
readlines()[源代码]
property scheme
property upload_handlers
class app.view.dependency.HttpResponse(content=b'', *args, **kwargs)[源代码]

基类:HttpResponseBase

An HTTP response class with a string as content.

This content can be read, appended to, or replaced.

property content
getvalue()[源代码]
serialize()[源代码]

Full HTTP message, including headers, as a bytestring.

streaming = False
tell()[源代码]
writable()[源代码]
write(content)[源代码]
writelines(lines)[源代码]
class app.view.dependency.JsonResponse(data, encoder=<class 'django.core.serializers.json.DjangoJSONEncoder'>, safe=True, json_dumps_params=None, **kwargs)[源代码]

基类:HttpResponse

An HTTP response class that consumes data to be serialized to JSON.

参数:
  • data -- Data to be dumped into json. By default only dict objects are allowed to be passed due to a security flaw before ECMAScript 5. See the safe parameter for more information.

  • encoder -- Should be a json encoder class. Defaults to django.core.serializers.json.DjangoJSONEncoder.

  • safe -- Controls if only dict objects may be serialized. Defaults to True.

  • json_dumps_params -- A dictionary of kwargs passed to json.dumps().

class app.view.dependency.ProfileJsonView(**kwargs)[源代码]

基类:ProfileView, SecureJsonView

args: _ArgType
data: dict[str, Any]
json_response(extra_data=None, **kwargs)[源代码]
kwargs: _KWType
logger_name: str = 'ProfileAPIerror'
request: UserRequest
class app.view.dependency.ProfileTemplateView(**kwargs)[源代码]

基类:ProfileView, SecureTemplateView

args: _ArgType
extra_context: dict[str, Any]
kwargs: _KWType
logger_name: str = 'ProfileError'
page_name: str
render(**kwargs)[源代码]
request: UserRequest
template_name: str
class app.view.dependency.User(*args, **kwargs)[源代码]

基类:AbstractUser, PointMixin

用户模型

Attributes: - id: 用户主键 - username: 用户名,学号 - name: 用户名称 - utype: 用户类型,参考User.Type - 其它继承字段参考AbstractUser

See Also: - UserManager - django.contrib.auth.models.AbstractUser

exception DoesNotExist

基类:ObjectDoesNotExist

MAX_CREDIT: Final = 3
MIN_CREDIT: Final = 0
exception MultipleObjectsReturned

基类:MultipleObjectsReturned

REQUIRED_FIELDS = ['name']
class Type(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[源代码]

基类:TextChoices

ORG = 'Organization'
PERSON = 'Person'
classmethod Persons() list[Type][源代码]
SPECIAL = ''
STUDENT = 'Student'
TEACHER = 'Teacher'
UNAUTHORIZED = 'Unauthorized'
YQpoint

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

academicqaawards

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

accept_anonymous_chat

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

accept_chat

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

achievementunlock_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.

acronym

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

active

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

agreement_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.

answersheet_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.

comment_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.

credit

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

creditrecord_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.

date_joined

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

dormitoryassignment_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.

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_full_name() str[源代码]

User的通用方法,展示用户的名称

get_next_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=True, **kwargs)
get_previous_by_date_joined(*, field=<django.db.models.fields.DateTimeField: date_joined>, is_next=False, **kwargs)
get_short_name() str[源代码]

User的通用方法,展示用户的简写

get_utype_display(*, field=<django.db.models.fields.CharField: utype>)
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.

is_active

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

is_newuser

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

is_org() bool[源代码]
is_person() bool[源代码]
is_staff

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

is_student() bool[源代码]
is_superuser

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

is_teacher() bool[源代码]
is_valid() bool[源代码]

返回用户是否合法,存在对应的子类对象

last_login

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

last_name

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.

modify_records

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.

modifyorganization_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.

modulelog_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.

name

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

naturalperson

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

objects: UserManager = <generic.models.UserManager object>
organization

Accessor to the related object on the reverse side of a one-to-one relation.

In the example:

class Restaurant(Model):
    place = OneToOneField(Place, related_name='restaurant')

Place.restaurant is a ReverseOneToOneDescriptor instance.

pagelog_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.

password

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

permissionblacklist_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.

pinyin

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

poolrecord_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.

prize_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.

receive_chat_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.

recv_notice

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.

send_chat_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.

send_notice

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.

survey_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_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.

username

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

utype: Type | str

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

yqpointrecord_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.

app.view.dependency.UserRequest

HttpRequest 的别名

app.view.dependency.login_required(function=None, redirect_field_name='next', login_url=None)[源代码]

Decorator for views that checks that the user is logged in, redirecting to the log-in page if necessary.

app.view.dependency.message_url(context: dict | dict, url: str = '/welcome/') str[源代码]

提供要发送的信息体和原始URL,返回带提示信息的URL - context: 包含`warn_code`和`warn_message`的字典 - url: str, 可以包含GET参数

app.view.dependency.redirect(to, *args, permanent=False, **kwargs)[源代码]

Return an HttpResponseRedirect to the appropriate URL for the arguments passed.

The arguments could be:

  • A model: the model's get_absolute_url() function will be called.

  • A view name, possibly with arguments: urls.reverse() will be used to reverse-resolve the name.

  • A URL, which will be used as-is for the redirect location.

Issues a temporary redirect by default; pass permanent=True to issue a permanent redirect.

app.view.dependency.render(request, template_name, context=None, content_type=None, status=None, using=None)[源代码]

Return an HttpResponse whose content is filled with the result of calling django.template.loader.render_to_string() with the passed arguments.

app.view.dependency.reverse(viewname, urlconf=None, args=None, kwargs=None, current_app=None)[源代码]
app.view.dependency.succeed(message: str, context: dict = None) dict[源代码]

在成功的情况下返回的字典, message为提示信息 如果提供了context,则向其中添加信息

app.view.dependency.wrong(message: str, context: dict = None) dict[源代码]

在错误的情况下返回的字典, message为错误信息 如果提供了context,则向其中添加信息