import copy
import json
import operator
import re
from collections import OrderedDict
from functools import partial, reduce, update_wrapper
from urllib.parse import quote as urlquote
from django import forms
from django.conf import settings
from django.contrib import messages
from django.contrib.admin import helpers, widgets
from django.contrib.admin.checks import (
BaseModelAdminChecks, InlineModelAdminChecks, ModelAdminChecks,
)
from django.contrib.admin.exceptions import DisallowedModelAdminToField
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.admin.utils import (
NestedObjects, construct_change_message, flatten_fieldsets,
get_deleted_objects, lookup_needs_distinct, model_format_dict,
model_ngettext, quote, unquote,
)
from django.contrib.admin.views.autocomplete import AutocompleteJsonView
from django.contrib.admin.widgets import (
AutocompleteSelect, AutocompleteSelectMultiple,
)
from django.contrib.auth import get_permission_codename
from django.core.exceptions import (
FieldDoesNotExist, FieldError, PermissionDenied, ValidationError,
)
from django.core.paginator import Paginator
from django.db import models, router, transaction
from django.db.models.constants import LOOKUP_SEP
from django.db.models.fields import BLANK_CHOICE_DASH
from django.forms.formsets import DELETION_FIELD_NAME, all_valid
from django.forms.models import (
BaseInlineFormSet, inlineformset_factory, modelform_defines_fields,
modelform_factory, modelformset_factory,
)
from django.forms.widgets import CheckboxSelectMultiple, SelectMultiple
from django.http import HttpResponseRedirect
from django.http.response import HttpResponseBase
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.html import format_html
from django.utils.http import urlencode
from django.utils.inspect import get_func_args
from django.utils.safestring import mark_safe
from django.utils.text import capfirst, format_lazy, get_text_list
from django.utils.translation import gettext as _, ngettext
from django.views.decorators.csrf import csrf_protect
from django.views.generic import RedirectView
IS_POPUP_VAR = '_popup'
TO_FIELD_VAR = '_to_field'
HORIZONTAL, VERTICAL = 1, 2
def get_content_type_for_model(obj):
# Since this module gets imported in the application's root package,
# it cannot import models from other applications at the module level.
from django.contrib.contenttypes.models import ContentType
return ContentType.objects.get_for_model(obj, for_concrete_model=False)
def get_ul_class(radio_style):
return 'radiolist' if radio_style == VERTICAL else 'radiolist inline'
class IncorrectLookupParameters(Exception):
pass
# Defaults for formfield_overrides. ModelAdmin subclasses can change this
# by adding to ModelAdmin.formfield_overrides.
FORMFIELD_FOR_DBFIELD_DEFAULTS = {
models.DateTimeField: {
'form_class': forms.SplitDateTimeField,
'widget': widgets.AdminSplitDateTime
},
models.DateField: {'widget': widgets.AdminDateWidget},
models.TimeField: {'widget': widgets.AdminTimeWidget},
models.TextField: {'widget': widgets.AdminTextareaWidget},
models.URLField: {'widget': widgets.AdminURLFieldWidget},
models.IntegerField: {'widget': widgets.AdminIntegerFieldWidget},
models.BigIntegerField: {'widget': widgets.AdminBigIntegerFieldWidget},
models.CharField: {'widget': widgets.AdminTextInputWidget},
models.ImageField: {'widget': widgets.AdminFileWidget},
models.FileField: {'widget': widgets.AdminFileWidget},
models.EmailField: {'widget': widgets.AdminEmailInputWidget},
}
csrf_protect_m = method_decorator(csrf_protect)
class BaseModelAdmin(metaclass=forms.MediaDefiningClass):
"""Functionality common to both ModelAdmin and InlineAdmin."""
autocomplete_fields = ()
raw_id_fields = ()
fields = None
exclude = None
fieldsets = None
form = forms.ModelForm
filter_vertical = ()
filter_horizontal = ()
radio_fields = {}
prepopulated_fields = {}
formfield_overrides = {}
readonly_fields = ()
ordering = None
sortable_by = None
view_on_site = True
show_full_result_count = True
checks_class = BaseModelAdminChecks
def check(self, **kwargs):
return self.checks_class().check(self, **kwargs)
def __init__(self):
# Merge FORMFIELD_FOR_DBFIELD_DEFAULTS with the formfield_overrides
# rather than simply overwriting.
overrides = copy.deepcopy(FORMFIELD_FOR_DBFIELD_DEFAULTS)
for k, v in self.formfield_overrides.items():
overrides.setdefault(k, {}).update(v)
self.formfield_overrides = overrides
def formfield_for_dbfield(self, db_field, request, **kwargs):
"""
Hook for specifying the form Field instance for a given database Field
instance.
If kwargs are given, they're passed to the form Field's constructor.
"""
# If the field specifies choices, we don't need to look for special
# admin widgets - we just need to use a select widget of some kind.
if db_field.choices:
return self.formfield_for_choice_field(db_field, request, **kwargs)
# ForeignKey or ManyToManyFields
if isinstance(db_field, (models.ForeignKey, models.ManyToManyField)):
# Combine the field kwargs with any options for formfield_overrides.
# Make sure the passed in **kwargs override anything in
# formfield_overrides because **kwargs is more specific, and should
# always win.
if db_field.__class__ in self.formfield_overrides:
kwargs = {**self.formfield_overrides[db_field.__class__], **kwargs}
# Get the correct formfield.
if isinstance(db_field, models.ForeignKey):
formfield = self.formfield_for_foreignkey(db_field, request, **kwargs)
elif isinstance(db_field, models.ManyToManyField):
formfield = self.formfield_for_manytomany(db_field, request, **kwargs)
# For non-raw_id fields, wrap the widget with a wrapper that adds
# extra HTML -- the "add other" interface -- to the end of the
# rendered output. formfield can be None if it came from a
# OneToOneField with parent_link=True or a M2M intermediary.
if formfield and db_field.name not in self.raw_id_fields:
related_modeladmin = self.admin_site._registry.get(db_field.remote_field.model)
wrapper_kwargs = {}
if related_modeladmin:
wrapper_kwargs.update(
can_add_related=related_modeladmin.has_add_permission(request),
can_change_related=related_modeladmin.has_change_permission(request),
can_delete_related=related_modeladmin.has_delete_permission(request),
can_view_related=related_modeladmin.has_view_permission(request),
)
formfield.widget = widgets.RelatedFieldWidgetWrapper(
formfield.widget, db_field.remote_field, self.admin_site, **wrapper_kwargs
)
return formfield
# If we've got overrides for the formfield defined, use 'em. **kwargs
# passed to formfield_for_dbfield override the defaults.
for klass in db_field.__class__.mro():
if klass in self.formfield_overrides:
kwargs = {**copy.deepcopy(self.formfield_overrides[klass]), **kwargs}
return db_field.formfield(**kwargs)
# For any other type of field, just call its formfield() method.
return db_field.formfield(**kwargs)
def formfield_for_choice_field(self, db_field, request, **kwargs):
"""
Get a
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
该项目为Vue.js与Django REST framework结合的电子商务网站源码,采用Python 3.6和Django 2.02框架开发。源码总共有6891个文件,其中包括1853个Python源文件、1285个模板文件、1285个国际化文件、568个HTML文件、561个JavaScript文件、137个CSS文件、105个PNG图片文件、86个JPG图片文件、67个文本文件、54个GIF图片文件。项目完成度高达95%,适用于构建功能完善的电子商务平台。
资源推荐
资源详情
资源评论
收起资源包目录
基于Vue和DjangoRESTframework的Python3.6+Django2.02电子商务网站设计源码 (2000个子文件)
bootstrap.css 123KB
bootstrap.css 123KB
bootstrap.css 123KB
bootstrap.min.css 100KB
bootstrap.min.css 100KB
bootstrap.min.css 100KB
ueditor.css 43KB
ueditor.min.css 34KB
font-awesome.css 21KB
font-awesome.css 21KB
font-awesome.css 21KB
video-js.css 21KB
bootstrap-theme.css 19KB
bootstrap-theme.css 19KB
bootstrap-theme.css 19KB
select2.css 19KB
select2.css 19KB
select2.css 19KB
image.css 18KB
responsive.css 18KB
font-awesome.min.css 17KB
font-awesome.min.css 17KB
font-awesome.min.css 17KB
bootstrap-theme.min.css 17KB
bootstrap-theme.min.css 17KB
bootstrap-theme.min.css 17KB
select2.css 17KB
base.css 16KB
selectize.bootstrap2.css 15KB
selectize.bootstrap2.css 15KB
selectize.bootstrap2.css 15KB
select2.min.css 15KB
video.css 15KB
attachment.css 14KB
selectize.default.css 11KB
selectize.default.css 11KB
selectize.default.css 11KB
video-js.min.css 11KB
selectize.legacy.css 11KB
selectize.legacy.css 11KB
selectize.legacy.css 11KB
selectize.bootstrap3.css 10KB
selectize.bootstrap3.css 10KB
selectize.bootstrap3.css 10KB
widgets.css 10KB
datepicker.css 10KB
datepicker.css 10KB
datepicker.css 10KB
forms.css 8KB
autocomplete.css 8KB
selectize.css 8KB
selectize.css 8KB
selectize.css 8KB
xadmin.main.css 8KB
xadmin.main.css 8KB
xadmin.main.css 8KB
shCoreDefault.css 7KB
changelists.css 6KB
xadmin.responsive.css 4KB
xadmin.responsive.css 4KB
xadmin.responsive.css 4KB
bootstrap-modal.css 4KB
bootstrap-modal.css 4KB
bootstrap-modal.css 4KB
scrawl.css 4KB
rtl.css 4KB
bootstrap-clockpicker.css 4KB
bootstrap-clockpicker.css 4KB
bootstrap-clockpicker.css 4KB
xadmin.form.css 3KB
xadmin.form.css 3KB
xadmin.form.css 3KB
bootstrap-image-gallery.css 3KB
bootstrap-image-gallery.css 3KB
bootstrap-image-gallery.css 3KB
bootstrap-clockpicker.min.css 3KB
bootstrap-clockpicker.min.css 3KB
bootstrap-clockpicker.min.css 3KB
codemirror.css 3KB
bootstrap-timepicker.css 3KB
bootstrap-timepicker.css 3KB
bootstrap-timepicker.css 3KB
charts.css 3KB
bootstrap-image-gallery.min.css 2KB
bootstrap-image-gallery.min.css 2KB
bootstrap-image-gallery.min.css 2KB
bootstrap-timepicker.min.css 2KB
bootstrap-timepicker.min.css 2KB
bootstrap-timepicker.min.css 2KB
background.css 2KB
xadmin.widget.select-transfer.css 2KB
xadmin.widget.select-transfer.css 2KB
xadmin.widget.select-transfer.css 2KB
bootstrap-xadmin.css 2KB
bootstrap-xadmin.css 2KB
bootstrap-xadmin.css 2KB
responsive_rtl.css 2KB
emotion.css 2KB
dialogbase.css 2KB
music.css 2KB
共 2000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 20
资源评论
xyq2024
- 粉丝: 2972
- 资源: 5575
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 社交网络引流副业的简易实施策略及收益分析
- 西门子消防图层显示软件
- 基于Node.js和Express框架的租房系统房屋出租管理后端设计源码
- VideoSpeed_87621.zip
- 基于Typescript和CSS的八电极指标报告PDF设计源码
- 短视频游戏推广副业快速获利-通过快手小游戏合伙人计划轻松入行
- MATLAB仿真均匀光纤布拉格光栅 传输矩阵法 可以仿真得到其透射谱与反射谱
- 基于Vue框架的快递代取后台管理新版本设计源码
- Linux驱动开发环境Ubuntu,已经制作好网络文件系统和zImage内核,已经交叉编译好Qt5.6.2 1.安装好交叉编译工具链 2.制作好网络文件系统 3.已经编译好Linux内核源码树(版本
- 基于广西忻城红渡初中22班的HTML, JavaScript, CSS同学录设计源码
- MATLAB环境下一种时间序列信号的基线消除算法 算法运行环境为MATLAB r2018a 1.所有代码均经过运行测试,没有问题 2.前请仔细阅读作品简介,这非常重要,因为涉及到不同的编程语言
- 基于Mql5语言的MT5客户端直连期货公司CTP柜台的期货程序化交易软件设计源码
- containerd源码1.7.22 tag
- 基于Java语言的Swing游戏引擎设计源码
- MATLAB环境下一种基于粒子群优化算法神经网络非线性函数拟合方法 算法运行环境为MATLAB R2018a,执行基于粒子群优化算法神经网络非线性函数拟合,并与其他改进的粒子群算法进行对比,结果如下
- 图像处理实验、图像分割 1打开计算机,安装和启动MATLAB程序;程序组中“work”文件夹中应有待处理的图像文件; 2对于血细胞图像 a).对图像进行去噪、增强处理; b)运用
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功