{ // 获取包含Hugging Face文本的span元素 const spans = link.querySelectorAll('span.whitespace-nowrap, span.hidden.whitespace-nowrap'); spans.forEach(span => { if (span.textContent && span.textContent.trim().match(/Hugging\s*Face/i)) { span.textContent = 'AI快站'; } }); }); // 替换logo图片的alt属性 document.querySelectorAll('img[alt*="Hugging"], img[alt*="Face"]').forEach(img => { if (img.alt.match(/Hugging\s*Face/i)) { img.alt = 'AI快站 logo'; } }); } // 替换导航栏中的链接 function replaceNavigationLinks() { // 已替换标记,防止重复运行 if (window._navLinksReplaced) { return; } // 已经替换过的链接集合,防止重复替换 const replacedLinks = new Set(); // 只在导航栏区域查找和替换链接 const headerArea = document.querySelector('header') || document.querySelector('nav'); if (!headerArea) { return; } // 在导航区域内查找链接 const navLinks = headerArea.querySelectorAll('a'); navLinks.forEach(link => { // 如果已经替换过,跳过 if (replacedLinks.has(link)) return; const linkText = link.textContent.trim(); const linkHref = link.getAttribute('href') || ''; // 替换Spaces链接 - 仅替换一次 if ( (linkHref.includes('/spaces') || linkHref === '/spaces' || linkText === 'Spaces' || linkText.match(/^s*Spacess*$/i)) && linkText !== '免费Z-image图片生成' && linkText !== '免费Z-image图片生成' ) { link.textContent = '免费Z-image图片生成'; link.href = 'https://zimage.run'; link.setAttribute('target', '_blank'); link.setAttribute('rel', 'noopener noreferrer'); replacedLinks.add(link); } // 删除Posts链接 else if ( (linkHref.includes('/posts') || linkHref === '/posts' || linkText === 'Posts' || linkText.match(/^s*Postss*$/i)) ) { if (link.parentNode) { link.parentNode.removeChild(link); } replacedLinks.add(link); } // 替换Docs链接 - 仅替换一次 else if ( (linkHref.includes('/docs') || linkHref === '/docs' || linkText === 'Docs' || linkText.match(/^s*Docss*$/i)) && linkText !== 'Vibevoice' ) { link.textContent = 'Vibevoice'; link.href = 'https://vibevoice.info/'; replacedLinks.add(link); } // 替换Pricing链接 - 仅替换一次 else if ( (linkHref.includes('/pricing') || linkHref === '/pricing' || linkText === 'Pricing' || linkText.match(/^s*Pricings*$/i)) && linkText !== '免费去水印' ) { link.textContent = '免费去水印'; link.href = 'https://sora2watermarkremover.net/'; replacedLinks.add(link); } // 替换Enterprise链接 else if ( (linkHref.includes('/enterprise') || linkHref === '/enterprise' || linkText === 'Enterprise' || linkText.match(/^s*Enterprises*$/i)) && linkText !== 'LTX-2' ) { link.textContent = 'LTX-2'; link.href = 'https://ltx-2.run/'; replacedLinks.add(link); } }); // 查找可能嵌套的Spaces和Posts文本 const textNodes = []; function findTextNodes(element) { if (element.nodeType === Node.TEXT_NODE) { const text = element.textContent.trim(); if (text === 'Spaces' || text === 'Posts' || text === 'Enterprise') { textNodes.push(element); } } else { for (const child of element.childNodes) { findTextNodes(child); } } } // 只在导航区域内查找文本节点 findTextNodes(headerArea); // 替换找到的文本节点 textNodes.forEach(node => { const text = node.textContent.trim(); if (text === 'Spaces') { node.textContent = node.textContent.replace(/Spaces/g, '免费Z-image图片生成'); } else if (text === 'Posts') { // 删除Posts文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } else if (text === 'Enterprise') { // 删除Enterprise文本节点 if (node.parentNode) { node.parentNode.removeChild(node); } } }); // 标记已替换完成 window._navLinksReplaced = true; } // 替换代码区域中的域名 function replaceCodeDomains() { // 特别处理span.hljs-string和span.njs-string元素 document.querySelectorAll('span.hljs-string, span.njs-string, span[class*="hljs-string"], span[class*="njs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换hljs-string类的span中的域名(移除多余的转义符号) document.querySelectorAll('span.hljs-string, span[class*="hljs-string"]').forEach(span => { if (span.textContent && span.textContent.includes('huggingface.co')) { span.textContent = span.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 替换pre和code标签中包含git clone命令的域名 document.querySelectorAll('pre, code').forEach(element => { if (element.textContent && element.textContent.includes('git clone')) { const text = element.innerHTML; if (text.includes('huggingface.co')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 处理特定的命令行示例 document.querySelectorAll('pre, code').forEach(element => { const text = element.innerHTML; if (text.includes('huggingface.co')) { // 针对git clone命令的专门处理 if (text.includes('git clone') || text.includes('GIT_LFS_SKIP_SMUDGE=1')) { element.innerHTML = text.replace(/huggingface.co/g, 'aifasthub.com'); } } }); // 特别处理模型下载页面上的代码片段 document.querySelectorAll('.flex.border-t, .svelte_hydrator, .inline-block').forEach(container => { const content = container.innerHTML; if (content && content.includes('huggingface.co')) { container.innerHTML = content.replace(/huggingface.co/g, 'aifasthub.com'); } }); // 特别处理模型仓库克隆对话框中的代码片段 try { // 查找包含"Clone this model repository"标题的对话框 const cloneDialog = document.querySelector('.svelte_hydration_boundary, [data-target="MainHeader"]'); if (cloneDialog) { // 查找对话框中所有的代码片段和命令示例 const codeElements = cloneDialog.querySelectorAll('pre, code, span'); codeElements.forEach(element => { if (element.textContent && element.textContent.includes('huggingface.co')) { if (element.innerHTML.includes('huggingface.co')) { element.innerHTML = element.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { element.textContent = element.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); } // 更精确地定位克隆命令中的域名 document.querySelectorAll('[data-target]').forEach(container => { const codeBlocks = container.querySelectorAll('pre, code, span.hljs-string'); codeBlocks.forEach(block => { if (block.textContent && block.textContent.includes('huggingface.co')) { if (block.innerHTML.includes('huggingface.co')) { block.innerHTML = block.innerHTML.replace(/huggingface.co/g, 'aifasthub.com'); } else { block.textContent = block.textContent.replace(/huggingface.co/g, 'aifasthub.com'); } } }); }); } catch (e) { // 错误处理但不打印日志 } } // 当DOM加载完成后执行替换 if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', () => { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); }); } else { replaceHeaderBranding(); replaceNavigationLinks(); replaceCodeDomains(); // 只在必要时执行替换 - 3秒后再次检查 setTimeout(() => { if (!window._navLinksReplaced) { console.log('[Client] 3秒后重新检查导航链接'); replaceNavigationLinks(); } }, 3000); } // 增加一个MutationObserver来处理可能的动态元素加载 const observer = new MutationObserver(mutations => { // 检查是否导航区域有变化 const hasNavChanges = mutations.some(mutation => { // 检查是否存在header或nav元素变化 return Array.from(mutation.addedNodes).some(node => { if (node.nodeType === Node.ELEMENT_NODE) { // 检查是否是导航元素或其子元素 if (node.tagName === 'HEADER' || node.tagName === 'NAV' || node.querySelector('header, nav')) { return true; } // 检查是否在导航元素内部 let parent = node.parentElement; while (parent) { if (parent.tagName === 'HEADER' || parent.tagName === 'NAV') { return true; } parent = parent.parentElement; } } return false; }); }); // 只在导航区域有变化时执行替换 if (hasNavChanges) { // 重置替换状态,允许再次替换 window._navLinksReplaced = false; replaceHeaderBranding(); replaceNavigationLinks(); } }); // 开始观察document.body的变化,包括子节点 if (document.body) { observer.observe(document.body, { childList: true, subtree: true }); } else { document.addEventListener('DOMContentLoaded', () => { observer.observe(document.body, { childList: true, subtree: true }); }); } })(); \" \n response.send_content(200, http_content) \n else: \n http_content = \"

HTTP Services Proxy

    \" \n for isolate in self._local_isolates:\n http_content += \"
  • \" + isolate + \"
  • \" \n http_content += \"
\"\n response.send_content(200, http_content) \n \n\n def do_delete(self, request, response):\n \"\"\"\n\t\tHandle Delete actions : not yet IMPLEMENTED!\n\t\t\"\"\"\n pass\n \n def do_post(self, request, response):\n \"\"\"\n Not yet Implemented!\n \"\"\"\n pass \n\n\n \"\"\"\n\tiPOPO STUFF --------------------------------------------------------------------------------------------------------\n\t\"\"\"\n\n @Validate\n def validate(self, context):\n _logger.info(\"HTTP Service Proxy validated\")\n self._context = context\n # load initial list of local isolates (if already created!) \n self.load_local_isolates()\n\n\n @Invalidate\n def invalidate(self, context):\n _logger.info(\"HTTP Service Proxy invalidated\")\n\n\n def bound_to(self, path, params):\n \"\"\"\n\t\tServlet bound to a path\n\t\t\"\"\"\n _logger.info('Bound to ' + path)\n return True\n\n def unbound_from(self, path, params):\n \"\"\"\n\t\tServlet unbound from a path\n\t\t\"\"\"\n _logger.info('Unbound from ' + path)\n return None\n"}}},{"rowIdx":99815,"cells":{"gt":{"kind":"string","value":""},"context":{"kind":"string","value":"\"\"\"\nForm classes\n\"\"\"\n\nfrom django.core.exceptions import ValidationError\nfrom django.utils.copycompat import deepcopy\nfrom django.utils.datastructures import SortedDict\nfrom django.utils.html import conditional_escape\nfrom django.utils.encoding import StrAndUnicode, smart_unicode, force_unicode\nfrom django.utils.safestring import mark_safe\n\nfrom fields import Field, FileField\nfrom widgets import Media, media_property, TextInput, Textarea\nfrom util import flatatt, ErrorDict, ErrorList\n\n__all__ = ('BaseForm', 'Form')\n\nNON_FIELD_ERRORS = '__all__'\n\ndef pretty_name(name):\n \"\"\"Converts 'first_name' to 'First name'\"\"\" \n if not name: \n return u'' \n return name.replace('_', ' ').capitalize() \n\ndef get_declared_fields(bases, attrs, with_base_fields=True):\n \"\"\"\n Create a list of form field instances from the passed in 'attrs', plus any\n similar fields on the base classes (in 'bases'). This is used by both the\n Form and ModelForm metclasses.\n\n If 'with_base_fields' is True, all fields from the bases are used.\n Otherwise, only fields in the 'declared_fields' attribute on the bases are\n used. The distinction is useful in ModelForm subclassing.\n Also integrates any additional media definitions\n \"\"\"\n fields = [(field_name, attrs.pop(field_name)) for field_name, obj in attrs.items() if isinstance(obj, Field)]\n fields.sort(key=lambda x: x[1].creation_counter)\n\n # If this class is subclassing another Form, add that Form's fields.\n # Note that we loop over the bases in *reverse*. This is necessary in\n # order to preserve the correct order of fields.\n if with_base_fields:\n for base in bases[::-1]:\n if hasattr(base, 'base_fields'):\n fields = base.base_fields.items() + fields\n else:\n for base in bases[::-1]:\n if hasattr(base, 'declared_fields'):\n fields = base.declared_fields.items() + fields\n\n return SortedDict(fields)\n\nclass DeclarativeFieldsMetaclass(type):\n \"\"\"\n Metaclass that converts Field attributes to a dictionary called\n 'base_fields', taking into account parent class 'base_fields' as well.\n \"\"\"\n def __new__(cls, name, bases, attrs):\n attrs['base_fields'] = get_declared_fields(bases, attrs)\n new_class = super(DeclarativeFieldsMetaclass,\n cls).__new__(cls, name, bases, attrs)\n if 'media' not in attrs:\n new_class.media = media_property(new_class)\n return new_class\n\nclass BaseForm(StrAndUnicode):\n # This is the main implementation of all the Form logic. Note that this\n # class is different than Form. See the comments by the Form class for more\n # information. Any improvements to the form API should be made to *this*\n # class, not to the Form class.\n def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None,\n initial=None, error_class=ErrorList, label_suffix=':',\n empty_permitted=False):\n self.is_bound = data is not None or files is not None\n self.data = data or {}\n self.files = files or {}\n self.auto_id = auto_id\n self.prefix = prefix\n self.initial = initial or {}\n self.error_class = error_class\n self.label_suffix = label_suffix\n self.empty_permitted = empty_permitted\n self._errors = None # Stores the errors after clean() has been called.\n self._changed_data = None\n\n # The base_fields class attribute is the *class-wide* definition of\n # fields. Because a particular *instance* of the class might want to\n # alter self.fields, we create self.fields here by copying base_fields.\n # Instances should always modify self.fields; they should not modify\n # self.base_fields.\n self.fields = deepcopy(self.base_fields)\n\n def __unicode__(self):\n return self.as_table()\n\n def __iter__(self):\n for name, field in self.fields.items():\n yield BoundField(self, field, name)\n\n def __getitem__(self, name):\n \"Returns a BoundField with the given name.\"\n try:\n field = self.fields[name]\n except KeyError:\n raise KeyError('Key %r not found in Form' % name)\n return BoundField(self, field, name)\n\n def _get_errors(self):\n \"Returns an ErrorDict for the data provided for the form\"\n if self._errors is None:\n self.full_clean()\n return self._errors\n errors = property(_get_errors)\n\n def is_valid(self):\n \"\"\"\n Returns True if the form has no errors. Otherwise, False. If errors are\n being ignored, returns False.\n \"\"\"\n return self.is_bound and not bool(self.errors)\n\n def add_prefix(self, field_name):\n \"\"\"\n Returns the field name with a prefix appended, if this Form has a\n prefix set.\n\n Subclasses may wish to override.\n \"\"\"\n return self.prefix and ('%s-%s' % (self.prefix, field_name)) or field_name\n\n def add_initial_prefix(self, field_name):\n \"\"\"\n Add a 'initial' prefix for checking dynamic initial values\n \"\"\"\n return u'initial-%s' % self.add_prefix(field_name)\n\n def _html_output(self, normal_row, error_row, row_ender, help_text_html, errors_on_separate_row):\n \"Helper function for outputting HTML. Used by as_table(), as_ul(), as_p().\"\n top_errors = self.non_field_errors() # Errors that should be displayed above all fields.\n output, hidden_fields = [], []\n\n for name, field in self.fields.items():\n html_class_attr = ''\n bf = BoundField(self, field, name)\n bf_errors = self.error_class([conditional_escape(error) for error in bf.errors]) # Escape and cache in local variable.\n if bf.is_hidden:\n if bf_errors:\n top_errors.extend([u'(Hidden field %s) %s' % (name, force_unicode(e)) for e in bf_errors])\n hidden_fields.append(unicode(bf))\n else:\n # Create a 'class=\"...\"' atribute if the row should have any\n # CSS classes applied.\n css_classes = bf.css_classes()\n if css_classes:\n html_class_attr = ' class=\"%s\"' % css_classes\n\n if errors_on_separate_row and bf_errors:\n output.append(error_row % force_unicode(bf_errors))\n\n if bf.label:\n label = conditional_escape(force_unicode(bf.label))\n # Only add the suffix if the label does not end in\n # punctuation.\n if self.label_suffix:\n if label[-1] not in ':?.!':\n label += self.label_suffix\n label = bf.label_tag(label) or ''\n else:\n label = ''\n\n if field.help_text:\n help_text = help_text_html % force_unicode(field.help_text)\n else:\n help_text = u''\n\n output.append(normal_row % {\n 'errors': force_unicode(bf_errors),\n 'label': force_unicode(label),\n 'field': unicode(bf),\n 'help_text': help_text,\n 'html_class_attr': html_class_attr\n })\n\n if top_errors:\n output.insert(0, error_row % force_unicode(top_errors))\n\n if hidden_fields: # Insert any hidden fields in the last row.\n str_hidden = u''.join(hidden_fields)\n if output:\n last_row = output[-1]\n # Chop off the trailing row_ender (e.g. '') and\n # insert the hidden fields.\n if not last_row.endswith(row_ender):\n # This can happen in the as_p() case (and possibly others\n # that users write): if there are only top errors, we may\n # not be able to conscript the last row for our purposes,\n # so insert a new, empty row.\n last_row = (normal_row % {'errors': '', 'label': '',\n 'field': '', 'help_text':'',\n 'html_class_attr': html_class_attr})\n output.append(last_row)\n output[-1] = last_row[:-len(row_ender)] + str_hidden + row_ender\n else:\n # If there aren't any rows in the output, just append the\n # hidden fields.\n output.append(str_hidden)\n return mark_safe(u'\\n'.join(output))\n\n def as_table(self):\n \"Returns this form rendered as HTML s -- excluding the
.\"\n return self._html_output(\n normal_row = u'%(label)s%(errors)s%(field)s%(help_text)s',\n error_row = u'%s',\n row_ender = u'',\n help_text_html = u'
%s',\n errors_on_separate_row = False)\n\n def as_ul(self):\n \"Returns this form rendered as HTML
  • s -- excluding the
      .\"\n return self._html_output(\n normal_row = u'%(errors)s%(label)s %(field)s%(help_text)s
    • ',\n error_row = u'
    • %s
    • ',\n row_ender = '',\n help_text_html = u' %s',\n errors_on_separate_row = False)\n\n def as_p(self):\n \"Returns this form rendered as HTML

      s.\"\n return self._html_output(\n normal_row = u'%(label)s %(field)s%(help_text)s

      ',\n error_row = u'%s',\n row_ender = '

      ',\n help_text_html = u' %s',\n errors_on_separate_row = True)\n\n def non_field_errors(self):\n \"\"\"\n Returns an ErrorList of errors that aren't associated with a particular\n field -- i.e., from Form.clean(). Returns an empty ErrorList if there\n are none.\n \"\"\"\n return self.errors.get(NON_FIELD_ERRORS, self.error_class())\n\n def _raw_value(self, fieldname):\n \"\"\"\n Returns the raw_value for a particular field name. This is just a\n convenient wrapper around widget.value_from_datadict.\n \"\"\"\n field = self.fields[fieldname]\n prefix = self.add_prefix(fieldname)\n return field.widget.value_from_datadict(self.data, self.files, prefix)\n\n def full_clean(self):\n \"\"\"\n Cleans all of self.data and populates self._errors and\n self.cleaned_data.\n \"\"\"\n self._errors = ErrorDict()\n if not self.is_bound: # Stop further processing.\n return\n self.cleaned_data = {}\n # If the form is permitted to be empty, and none of the form data has\n # changed from the initial data, short circuit any validation.\n if self.empty_permitted and not self.has_changed():\n return\n self._clean_fields()\n self._clean_form()\n self._post_clean()\n if self._errors:\n delattr(self, 'cleaned_data')\n\n def _clean_fields(self):\n for name, field in self.fields.items():\n # value_from_datadict() gets the data from the data dictionaries.\n # Each widget type knows how to retrieve its own data, because some\n # widgets split data over several HTML fields.\n value = field.widget.value_from_datadict(self.data, self.files, self.add_prefix(name))\n try:\n if isinstance(field, FileField):\n initial = self.initial.get(name, field.initial)\n value = field.clean(value, initial)\n else:\n value = field.clean(value)\n self.cleaned_data[name] = value\n if hasattr(self, 'clean_%s' % name):\n value = getattr(self, 'clean_%s' % name)()\n self.cleaned_data[name] = value\n except ValidationError, e:\n self._errors[name] = self.error_class(e.messages)\n if name in self.cleaned_data:\n del self.cleaned_data[name]\n\n def _clean_form(self):\n try:\n self.cleaned_data = self.clean()\n except ValidationError, e:\n self._errors[NON_FIELD_ERRORS] = self.error_class(e.messages)\n\n def _post_clean(self):\n \"\"\"\n An internal hook for performing additional cleaning after form cleaning\n is complete. Used for model validation in model forms.\n \"\"\"\n pass\n\n def clean(self):\n \"\"\"\n Hook for doing any extra form-wide cleaning after Field.clean() been\n called on every field. Any ValidationError raised by this method will\n not be associated with a particular field; it will have a special-case\n association with the field named '__all__'.\n \"\"\"\n return self.cleaned_data\n\n def has_changed(self):\n \"\"\"\n Returns True if data differs from initial.\n \"\"\"\n return bool(self.changed_data)\n\n def _get_changed_data(self):\n if self._changed_data is None:\n self._changed_data = []\n # XXX: For now we're asking the individual widgets whether or not the\n # data has changed. It would probably be more efficient to hash the\n # initial data, store it in a hidden field, and compare a hash of the\n # submitted data, but we'd need a way to easily get the string value\n # for a given field. Right now, that logic is embedded in the render\n # method of each widget.\n for name, field in self.fields.items():\n prefixed_name = self.add_prefix(name)\n data_value = field.widget.value_from_datadict(self.data, self.files, prefixed_name)\n if not field.show_hidden_initial:\n initial_value = self.initial.get(name, field.initial)\n else:\n initial_prefixed_name = self.add_initial_prefix(name)\n hidden_widget = field.hidden_widget()\n initial_value = hidden_widget.value_from_datadict(\n self.data, self.files, initial_prefixed_name)\n if field.widget._has_changed(initial_value, data_value):\n self._changed_data.append(name)\n return self._changed_data\n changed_data = property(_get_changed_data)\n\n def _get_media(self):\n \"\"\"\n Provide a description of all media required to render the widgets on this form\n \"\"\"\n media = Media()\n for field in self.fields.values():\n media = media + field.widget.media\n return media\n media = property(_get_media)\n\n def is_multipart(self):\n \"\"\"\n Returns True if the form needs to be multipart-encrypted, i.e. it has\n FileInput. Otherwise, False.\n \"\"\"\n for field in self.fields.values():\n if field.widget.needs_multipart_form:\n return True\n return False\n\n def hidden_fields(self):\n \"\"\"\n Returns a list of all the BoundField objects that are hidden fields.\n Useful for manual form layout in templates.\n \"\"\"\n return [field for field in self if field.is_hidden]\n\n def visible_fields(self):\n \"\"\"\n Returns a list of BoundField objects that aren't hidden fields.\n The opposite of the hidden_fields() method.\n \"\"\"\n return [field for field in self if not field.is_hidden]\n\nclass Form(BaseForm):\n \"A collection of Fields, plus their associated data.\"\n # This is a separate class from BaseForm in order to abstract the way\n # self.fields is specified. This class (Form) is the one that does the\n # fancy metaclass stuff purely for the semantic sugar -- it allows one\n # to define a form using declarative syntax.\n # BaseForm itself has no way of designating self.fields.\n __metaclass__ = DeclarativeFieldsMetaclass\n\nclass BoundField(StrAndUnicode):\n \"A Field plus data\"\n def __init__(self, form, field, name):\n self.form = form\n self.field = field\n self.name = name\n self.html_name = form.add_prefix(name)\n self.html_initial_name = form.add_initial_prefix(name)\n self.html_initial_id = form.add_initial_prefix(self.auto_id)\n if self.field.label is None:\n self.label = pretty_name(name)\n else:\n self.label = self.field.label\n self.help_text = field.help_text or ''\n\n def __unicode__(self):\n \"\"\"Renders this field as an HTML widget.\"\"\"\n if self.field.show_hidden_initial:\n return self.as_widget() + self.as_hidden(only_initial=True)\n return self.as_widget()\n\n def _errors(self):\n \"\"\"\n Returns an ErrorList for this field. Returns an empty ErrorList\n if there are none.\n \"\"\"\n return self.form.errors.get(self.name, self.form.error_class())\n errors = property(_errors)\n\n def as_widget(self, widget=None, attrs=None, only_initial=False):\n \"\"\"\n Renders the field by rendering the passed widget, adding any HTML\n attributes passed as attrs. If no widget is specified, then the\n field's default widget will be used.\n \"\"\"\n if not widget:\n widget = self.field.widget\n attrs = attrs or {}\n auto_id = self.auto_id\n if auto_id and 'id' not in attrs and 'id' not in widget.attrs:\n if not only_initial:\n attrs['id'] = auto_id\n else:\n attrs['id'] = self.html_initial_id\n if not self.form.is_bound:\n data = self.form.initial.get(self.name, self.field.initial)\n if callable(data):\n data = data()\n else:\n if isinstance(self.field, FileField) and self.data is None:\n data = self.form.initial.get(self.name, self.field.initial)\n else:\n data = self.data\n if not only_initial:\n name = self.html_name\n else:\n name = self.html_initial_name\n return widget.render(name, data, attrs=attrs)\n\n def as_text(self, attrs=None, **kwargs):\n \"\"\"\n Returns a string of HTML for representing this as an .\n \"\"\"\n return self.as_widget(TextInput(), attrs, **kwargs)\n\n def as_textarea(self, attrs=None, **kwargs):\n \"Returns a string of HTML for representing this as a
      Subsets and Splits

      No community queries yet

      The top public SQL queries from the community will appear here once available.