admin.AdminSite.has_permission()

AdminSite.has_permission(request) [source] Returns True if the user for the given HttpRequest has permission to view at least one page in the admin site. Defaults to requiring both User.is_active and User.is_staff to be True.

test.SimpleTestCase.assertFieldOutput()

SimpleTestCase.assertFieldOutput(fieldclass, valid, invalid, field_args=None, field_kwargs=None, empty_value='') [source] Asserts that a form field behaves correctly with various inputs. Parameters: fieldclass – the class of the field to be tested. valid – a dictionary mapping valid inputs to their expected cleaned values. invalid – a dictionary mapping invalid inputs to one or more raised error messages. field_args – the args passed to instantiate the field. field_kwargs – the kwargs

utils.html.strip_tags()

strip_tags(value) [source] Tries to remove anything that looks like an HTML tag from the string, that is anything contained within <>. Absolutely NO guarantee is provided about the resulting string being HTML safe. So NEVER mark safe the result of a strip_tag call without escaping it first, for example with escape(). For example: strip_tags(value) If value is "<b>Joel</b> <button>is</button> a <span>slug</span>" the return value will be "Joel is a s

forms.PasswordInput.render_value

render_value Determines whether the widget will have a value filled in when the form is re-displayed after a validation error (default is False).

forms.Form.errors.as_json()

Form.errors.as_json(escape_html=False) Returns the errors serialized as JSON. >>> f.errors.as_json() {"sender": [{"message": "Enter a valid email address.", "code": "invalid"}], "subject": [{"message": "This field is required.", "code": "required"}]} By default, as_json() does not escape its output. If you are using it for something like AJAX requests to a form view where the client interprets the response and inserts errors into the page, you’ll want to be sure to escape the resul

admin.InlineModelAdmin.show_change_link

InlineModelAdmin.show_change_link Specifies whether or not inline objects that can be changed in the admin have a link to the change form. Defaults to False.

admin.ModelAdmin.message_user()

ModelAdmin.message_user(request, message, level=messages.INFO, extra_tags='', fail_silently=False) [source] Sends a message to the user using the django.contrib.messages backend. See the custom ModelAdmin example. Keyword arguments allow you to change the message level, add extra CSS tags, or fail silently if the contrib.messages framework is not installed. These keyword arguments match those for django.contrib.messages.add_message(), see that function’s documentation for more details. One d

db.models.ImageField

class ImageField(upload_to=None, height_field=None, width_field=None, max_length=100, **options) [source] Inherits all attributes and methods from FileField, but also validates that the uploaded object is a valid image. In addition to the special attributes that are available for FileField, an ImageField also has height and width attributes. To facilitate querying on those attributes, ImageField has two extra optional arguments:

db.models.ImageField.width_field

ImageField.width_field Name of a model field which will be auto-populated with the width of the image each time the model instance is saved. Requires the Pillow library. ImageField instances are created in your database as varchar columns with a default max length of 100 characters. As with other fields, you can change the maximum length using the max_length argument. The default form widget for this field is a ClearableFileInput.

http.HttpRequest.is_ajax()

HttpRequest.is_ajax() [source] Returns True if the request was made via an XMLHttpRequest, by checking the HTTP_X_REQUESTED_WITH header for the string 'XMLHttpRequest'. Most modern JavaScript libraries send this header. If you write your own XMLHttpRequest call (on the browser side), you’ll have to set this header manually if you want is_ajax() to work. If a response varies on whether or not it’s requested via AJAX and you are using some form of caching like Django’s cache middleware, you sh