Below are auto-generated docs mostly covering each of the packages contained within Mezzanine that are added to settings.INSTALLED_APPS.
An app that is forced to the top of the list in INSTALLED_APPS for the purpose of hooking into Django’s class_prepared signal and adding custom fields as defined by the EXTRA_MODEL_FIELDS setting. Also patches django.contrib.admin.site to use LazyAdminSite that defers certains register/unregister calls until admin.autodiscover to avoid some timing issues around custom fields not being available when custom admin classes are registered.
Provides abstract models and admin features used throughout the various Mezzanine apps.
Abstract model that provides features of a visible page on the website such as publishing fields. Basis of Mezzanine pages, blog posts, and Cartridge products.
Set default for publish_date. We can’t use auto_add on the field as it will be blank when a blog post is created from the quick blog form in the admin dashboard.
Abstract model that provides meta data for content.
Returns the first block or sentence of the first content-like field.
Set the description field on save.
Abstract model that provides a custom ordering integer field similar to using Meta’s order_with_respect_to, since to date (Django 1.2) this doesn’t work with ForeignKey("self"), or with Generic Relations. We may also want this feature for models that aren’t ordered with respect to a particular field.
Update the ordering values for siblings.
Set the initial ordering value.
Returns a dict to use as a filter for ordering operations containing the original Meta.order_with_respect_to value if provided. If the field is a Generic Relation, the dict returned contains names and values for looking up the relation’s ct_field and fk_field attributes.
Checks for order_with_respect_to on the model’s inner Meta class and if found, copies it to a custom attribute and deletes it since it will cause errors when used with ForeignKey("self"). Also creates the ordering attribute on the Meta class if not yet provided.
Abstract model that provides ownership of an object for a user.
Restrict in-line editing to the objects’s owner and superusers.
Provides a Rich Text field for managing general content and making it searchable.
Abstract model that handles auto-generating slugs. Each slugged object is also affiliated with a specific site object.
Allows subclasses to implement their own slug creation logic.
Create a unique slug by appending an index. Set the site to the current site when the record is first created, unless the update_site argument is explicitly set to True.
Manually combines CurrentSiteManager, PublishedManager and SearchableManager for the Displayable model.
Provides filter for restricting items returned by status and publish date when the given user is not a staff member.
For non-staff users, return items with a published status and whose publish and expiry dates fall before and after the current date when specified.
Manager providing a chainable queryset. Adapted from http://www.djangosnippets.org/snippets/562/ search method supports spanning across models that subclass the model being used to search.
Proxy to queryset’s search method for the manager’s model and any models that subclass from this manager’s model if the model is abstract.
QuerySet providing main search functionality for SearchableManager.
If search has occurred and no ordering has occurred, decorate each result with the number of search terms so that it can be sorted by the number of occurrence of terms.
Mark the filter as being ordered if search has occurred.
Build a queryset matching words in the given search query, treating quoted terms as exact phrases and taking into account + and - symbols as modifiers controlling which terms to require and exclude.
Display and handle both the login and signup forms.
Replacement for Django’s direct_to_template that uses TemplateResponse via mezzanine.utils.views.render.
Process the inline editing form.
Log the user out.
Display search results.
Mimics Django’s error handler but adds STATIC_URL to the context.
Sets a device name in a cookie when a user explicitly wants to go to the site for a particular device (eg mobile).
View for the link in the verification email sent to a new user when they create an account and ACCOUNTS_VERIFICATION_REQUIRED is set to True. Activates the user and logs them in, redirecting to the URL they tried to access when signing up.
Form for DynamicInlineAdmin that can be collapsed and sorted with drag and drop using OrderWidget.
Add up and down arrows for ordering controls next to a hidden form field.
Combines Django’s SelectDateTimeWidget and SelectDateWidget.
Setup the JS files and targetting CSS class for a textarea to use TinyMCE.
Fields for signup & login.
Validate email and password as well as setting the user for login.
Log the user in.
Returns the in-line editing form for editing a single model field.
Admin inline that uses JS to inject an “Add another” link which when clicked, dynamically reveals another fieldset. Also handles adding the _order field and its widget for models that subclass Orderable.
alias of DynamicInlineAdminForm
Admin class for subclasses of the abstract Displayable model.
Admin class for models that subclass the abstract Ownable model. Handles limiting the change list to objects owned by the logged in user, as well as setting the owner of newly created objects to the logged in user.
Filter the change list by currently logged in user if not a superuser.
Set the object’s owner as the logged in user.
Admin class for models that should only contain a single instance in the database. Redirect all views to the change view when the instance exists, and to the add view when it doesn’t.
Redirect to the change view if the singleton instance exists.
If only the singleton instance exists, pass True for singleton into the template which will use CSS to hide the “save and add another” button.
Redirect to the add view if no records exist or the change view if the singleton instance exists.
Checks for a POST from the admin login view and if authentication is successful and the “site” interface is selected, redirect to the site.
Mixin for device-aware cache middleware that provides the method for prefixing the cache key with a device.
Device-aware version of Django’s FetchFromCacheMiddleware - prefixes the internal cache key with the device for the request for each request.
Device-aware version of Django’s UpdateCacheMiddleware - prefixes the internal cache key with the device for the request for each response.
Handles redirections required for SSL when SSL_ENABLED is True.
If SSL_FORCE_HOST is True, and is not the current host, redirect to it.
Also ensure URLs defined by SSL_FORCE_URL_PREFIXES are redirect to HTTPS, and redirect all other URLs to HTTP if on HTTPS.
Adopted from django.contrib.admin.sites.AdminSite.index. Returns a list of lists of models grouped and ordered according to mezzanine.conf.ADMIN_MENU_ORDER. Called from the admin_dropdown_menu template tag as well as the app_list dashboard widget.
Renders the app list for the admin dropdown menu navigation.
Renders the app list for the admin dashboard widget.
Takes an index for retrieving the sequence of template tags from mezzanine.conf.DASHBOARD_TAGS to render into the admin dashboard.
Add the required HTML to the parsed content for in-line editing, such as the icon and edit form if the object is deemed to be editable - either it has an editable method which returns True, or the logged in user has change permissions for the model.
Set up the required JS/CSS for the in-line editing toolbar and controls.
Renders fields for a form.
Returns True if the given app name is in the INSTALLED_APPS setting.
Remove HTML tags, entities and superfluous characters from meta blocks.
Include the pagination template and data for persisting querystring in pagination links.
Renders the recent actions list for the admin dashboard widget.
This template filter takes a string value and passes it through the function specified by the RICHTEXT_FILTER setting.
Sets the short_url attribute of the given model using the bit.ly credentials if they have been specified and saves it.
Given the URL to an image, resizes the image using the given width and height on the first time it is requested, and returns the URL to the new resized image. if width or height are zero then original ratio is maintained.
Mimics Django’s url template tag but fails silently. Used for url names in admin templates as these won’t resolve when admin tests are running.
Mezzanine tests.
Create multiple levels of recursive objects.
Return the number of queries used when rendering a template string.
Create an admin user.
Test account creation.
Basic status code test for blog views.
Test that rendering comments executes the same number of queries, regardless of the number of nested replies.
Test generated description is text version of the first line of content.
Test that an alternate template is rendered when a mobile device is used.
Test a draft page as only being viewable by a staff member.
Simple 200 status check against rendering and posting to forms with both optional and required fields.
Test that a gallery creates images when given a zip file to import, and that descriptions are created.
Test that the keywords_string field is correctly populated.
Test that a page with a slug matching a non-page urlpattern return True for its overridden property.
Test that rendering a page menu executes the same number of queries regardless of the number of pages or levels of children.
Test that ratings can be posted and avarage/count are calculated.
Test search.
Test that an editable setting can be overridden with a DB value and that the data type is preserved when the value is returned back out of the DB. Also checks to ensure no unsupported types are defined for editable settings.
Run pyflakes/pep8 across the code base to check for potential errors.
Test that a thumbnail is created and resized.
Miscellanous tests for the mezzanine.utils package.
Provides the main structure of a Mezzanine site with a hierarchical tree of pages, each subclassing the Page model to create a content structure.
A page in the page tree. This is the base class that custom content types need to subclass.
Dynamic add permission for content types to override.
Dynamic change permission for content types to override.
Dynamic change permission for content types to override.
Provies a generic method of retrieving the instance of the custom content type’s model for this page.
Recursively build the slug from the chain of parents.
Returns True if the page’s slug has an explicitly defined urlpattern and is therefore considered to be overridden.
Called when the parent page is changed in the admin and the slug plus all child slugs need to be recreated given the new parent.
Create the titles field using the titles up the parent chain and set the initial value for ordering.
Called from the page_menu template tag and assigns a handful of properties based on the current URL that are used within the various types of menus.
Implements the default type of page with a single Rich Text content field.
Updates the ordering of pages via AJAX from within the admin.
Display content for a page. First check for any matching page processors and handle them. Secondly, build the list of template names to choose from given the slug and type of page being viewed.
Admin class for the Page model and all subclasses of Page. Handles redirections between admin interfaces for the Page model and its subclasses.
For the Page model, redirect to the add view for the RichText model.
For the Page model, check page.get_content_model() for a subclass and redirect to its admin change view. Also enforce custom change permissions for the page instance.
Redirect to the Page changelist view for Page subclasses.
Enforce custom delete permissions for the page instance.
Hide subclasses from the admin menu.
Enforce page permissions and maintain the parent ID in the querystring.
Enforce page permissions and maintain the parent ID in the querystring.
Set the ID of the parent page if passed in via querystring.
Create a select list containing each of the models that subclass the Page model.
Return a list of child pages for the given parent, storing all pages in a dict in the context when first called using parents as keys for retrieval on subsequent recursive calls from the menu template.
Assigns a permissions dict to the given model, much like Django does with its dashboard app list.
Used within the change list for pages, to implement permission checks for the navigation tree.
Assigns a permissions dict to the given page instance, combining Django’s permission for the page’s model and a permission check against the instance itself calling the page’s can_add, can_change and can_delete custom methods.
Used within the change list for pages, to implement permission checks for the navigation tree.
Taken from django.contrib.admin.autodiscover and used to run any calls to the processor_for decorator.
Decorator that registers the decorated function as a page processor for the given content model or slug.
Provides various models and associated functionality, that can be related to any other model using generic relationshipswith Django’s contenttypes framework, such as comments, keywords/tags and voting.
A Keyword assigned to a model instance.
Keywords/tags which are managed via a custom Javascript based widget in the admin.
A rating that can be given to a piece of content.
Validate that the rating falls between the min and max values.
Extend the Comment model from django.contrib.comments to add comment threading.
Use the URL for the comment’s content object, with a URL hash appended that references the individual comment.
Store the email hash of the comment for using with Gravatar.com, and set is_public based on the setting COMMENTS_DEFAULT_APPROVED.
Provides filter for restricting comments that are not approved if COMMENTS_UNAPPROVED_VISIBLE is set to False.
Called from CommentsField.related_items_changed to store the comment count against an item each time a comment is saved.
Return the comments that are visible based on the COMMENTS_XXX_VISIBLE settings. When these settings are set to True, the relevant comments are returned that shouldn’t be shown, and are given placeholders in the template generic/includes/comment.html.
Provides natural key method.
Extends GenericRelation to:
Add each of the names and fields in the fields attribute to the model the relationship field is applied to, and set up the related item save and delete signals for calling related_items_changed.
Can be implemented by subclasses - called whenever the state of related items change, eg they’re saved or deleted. The instance for this field and the related manager for the field are passed as arguments.
Stores the number of comments against the COMMENTS_FIELD_NAME_count field when a comment is saved or deleted.
Stores the number of comments. A custom count_filter queryset gets checked for, allowing managers to implement custom count logic.
Stores the keywords as a single string into the KEYWORDS_FIELD_NAME_string field for convenient access when searching.
Swap out any reference to KeywordsField with the KEYWORDS_FIELD_string field in search_fields.
Provide the custom form widget for the admin, since there isn’t a form field mapped to GenericRelation model fields.
Stores the keywords as a single string for searching.
The KeywordsWidget field will return data as a string of comma separated IDs for the Keyword model - convert these into actual AssignedKeyword instances. Also delete Keyword instances if their last related AssignedKeyword instance is being removed.
Stores the rating count and average against the RATING_FIELD_NAME_count and RATING_FIELD_NAME_average fields when a rating is saved or deleted.
Calculates and saves the average rating.
Adds any new given keywords from the custom keywords field in the admin, and returns their IDs for use when saving a model with a keywords field.
Handle a ThreadedCommentForm submission and redirect back to its related object.
Handle a RatingForm submission and redirect back to its related object.
Form field for the KeywordsField generic relation field. Since the admin with model forms has no form field for generic relations, this form field provides a single field for managing the keywords. It contains two actual widgets, a text input for entering keywords, and a hidden input that stores the ID of each Keyword instance.
The attached JavaScript adds behaviour so that when the form is submitted, an AJAX post is made that passes the list of keywords in the text input, and returns a list of keyword IDs which are then entered into the hidden input before the form submits. The list of IDs in the hidden input is what is used when retrieving an actual value from the field for the form.
Takes the sequence of AssignedKeyword instances and splits them into lists of keyword IDs and titles each mapping to one of the form field widgets.
Wraps the output HTML with a list of all available Keyword instances that can be clicked on to toggle a keyword.
Return the comma separated list of keyword IDs for use in KeywordsField.save_form_data().
Form for a rating. Subclasses CommentSecurityForm to make use of its easy setup for generic relations.
Admin class for comments.
Return a list of child comments for the given parent, storing all comments in a dict in the context when first called, using parents as keys for retrieval on subsequent recursive calls from the comments template.
Provides a generic context variable name for the object that comments are being rendered for.
Return the full URL for a Gravatar given an email hash.
Dashboard widget for displaying recent comments.
Returns a unique identifier for the object to be used in DISQUS JavaScript.
Provides a generic context variable which adds single-sign-on support to DISQUS if COMMENTS_DISQUS_API_PUBLIC_KEY and COMMENTS_DISQUS_API_SECRET_KEY are specified.
Return a list of Keyword objects for the given model instance or a model class. In the case of a model class, retrieve all keywords for all instances of the model and apply a weight attribute that can be used to create a tag cloud.
Provides a generic context variable name for the object that ratings are being rendered for, and the rating form.
Provides a blogging app with posts, keywords, categories and comments. Posts can be listed by month, keyword, category or author.
A category for grouping blog posts into a series.
A blog post.
Return the Blog page from the pages app.
. Custom templates are checked for using the name blog/blog_post_detail_XXX.html where XXX is the blog posts’s slug.
Display a list of blog posts that are filtered by tag, year, month, author or category. Custom templates are checked for using the name blog/blog_post_list_XXX.html where XXX is either the category slug or author’s username if given.
Model form for BlogPost that provides the quick blog panel in the admin dashboard.
Admin class for blog categories. Hides itself from the admin menu unless explicitly specified.
Hide from the admin menu unless explicitly set in ADMIN_MENU_ORDER.
Atom feed for all blog posts.
RSS feed for all blog posts.
Put a list of authors (users) for blog posts into the template context.
Put a list of categories for blog posts into the template context.
Put a list of dates for blog posts into the template context.
Put a list of recently published blog posts into the template context.
Admin dashboard tag for the quick blog form.
Base importer command for blogging platform specific management commands to subclass when importing blog posts into Mezzanine. The handle_import method should be overridden to provide the import mechanism specific to the blogging platform being dealt with.
Adds a comment to the post provided.
Adds a post to the post list for processing.
Processes the converted data into the Mezzanine database correctly.
Should be overridden by subclasses - performs the conversion from the originating data source into the lists of posts and comments ready for processing.
Implements a Blogger importer. Takes a Blogger ID in order to be able to determine which blog it should point to and harvest the XML from.
Gets posts from Blogger.
Implements a Wordpress importer. Takes a file path or a URL for the Wordpress Extended RSS file.
Gets the element’s text value from the XML object provided.
Gets the posts from either the provided URL or the path if it is local.
Import Tumblr blog posts into the blog app.
Try and extract the first sentence from a block of test to use as a title.
A port of django-forms-builder for Mezzanine. Allows admin users to create their own HTML5 forms and export form submissions as CSV.
A field for a user-built form.
Parse a comma separated choice string into a list of choices taking into account quoted choices.
Helper that returns True if the field’s type is given in any arg.
A single field value for a form entry submitted via a user-built form.
Only show visible fields when displaying actual form..
A user-built form.
An entry submitted via a user-built form.
Form with a set of fields dynamically assigned that can be used to filter entries for the given forms.models.Form instance.
Returns the list of selected column names.
Returns each row based on the selected criteria.
Form with a set of fields dynamically assigned, directly based on the given forms.models.Form instance.
Return the value entered for the first field of type forms.fields.EMAIL.
Create a FormEntry instance and related FieldEntry instances for each form field.
Display a built form and handle submission.
Convert a list into a comma separated string, for displaying select multiple values in emails.
Admin class for the form field. Inherits from TabularDynamicInlineAdmin to add dynamic “Add another” link and drag/drop ordering.
alias of Field
Admin class for the Form model. Includes the urls & views for exporting form entries as CSV and downloading files uploaded via the forms app.
Displays the form entries in a HTML table with option to export as CSV file.
Output the file for the requested field entry.
Add the entries view to urls.
Implements a photo gallery content type.
Drop-in replacement for django.conf.settings that provides a consistent access method for settings defined in applications, the project or Django itself. Settings can also be made editable via the admin.
An object that provides settings via dynamic attribute access. Settings that are registered as editable and can therefore be stored in the database are all loaded once only, the first time any editable setting is accessed. When accessing uneditable settings their default values are used. The Settings object also provides access to Django settings via django.conf.settings in order to provide a consistent method of access for all settings.
Empty the editable settings cache and set the loaded flag to False so that settings will be loaded from the DB on next access. If the conf app is not installed then set the loaded flag to True in order to bypass DB lookup entirely.
Registers a setting that can be edited via the admin.
Form for settings - creates a field for each setting in mezzanine.conf that is marked as editable.
Extends django.template.Library providing several shortcuts that attempt to take the leg-work out of creating different types of template tags.
Creates a tag expecting the format: {% tag_name as var_name %} The decorated func returns the value that is given to var_name in the template.
Replacement for Django’s inclusion_tag which looks up device specific templates at render time.
Creates a tag using the decorated func as the render function for the template tag node. The render function takes two arguments - the template context and the tag token.
Creates a tag that parses until it finds the corresponding end tag, eg: for a tag named mytag it will parse until endmytag. The decorated func’s return value is used to render the parsed content and takes three arguments - the parsed content between the start and end tags, the template context and the tag token.
Provides models and utilities for displaying different types of Twitter feeds.
Query(id, type, value, interested)
Request new tweets from the Twitter API.
Tweet(id, remote_id, created_at, text, profile_image_url, user_name, full_name, retweeter_profile_image_url, retweeter_user_name, retweeter_full_name, query_id)
Retrieve tweets for a user, list or search term. The optional per_user arg limits the number of tweets per user, for example to allow a fair spread of tweets per user for a list.
Tweets for a user’s list.
Tweets for a search query.
Tweets for a user.
Various utility functions used throughout the different Mezzanine apps.
Called at the end of the project’s settings module and is passed its globals dict for updating with some final tweaks for settings that generally aren’t specified but can be given some better defaults based on other settings that have been specified. Broken out into its own function so that the code need not be replicated in the settings modules of other project-based apps that leverage Mezzanine’s settings module.
HTMLParser that closes open tags. Takes a HTML string as its first arg, and populate a html attribute on the parser with the original HTML arg and any required closing tags.
Remove HTML entities from a string. Adapted from http://effbot.org/zone/re-sub.htm#unescape-html
Utils called from project_root/docs/conf.py when Sphinx documentation is generated.
Converts Mercurial commits into a changelog in RST format.
Creates a diagram of all the models for mezzanine and the given package name, generates a smaller version and add it to the docs directory for use in model-graph.rst
Updates the requirements file with Mezzanine’s version number.
Converts names, descriptions and defaults for settings in mezzanine.conf.registry into RST format for use in docs, optionally filtered by setting names with the given prefix.
Takes a dotted path to a member name in a module, and returns the member after importing it.
Returns the directory path for the given package or module.
Used as a subclass for mixin models that inject their behaviour onto models defined outside of a project. The subclass should define an inner Meta class with a mixin_for attribute containing the model that will be mixed into.
Metaclass for ModelMixin which is ued for injecting model fields and methods into models defined outside of a project.
Used in methods of abstract models to find the super-most concrete (non abstract) model in the inheritance chain that inherits from the given abstract model. This is so the methods in the abstract model can query data consistently across the correct concrete model.
Consider the following:
class Abstract(models.Model)
class Meta:
abstract = True
def concrete(self):
return base_concrete_model(Abstract, self)
class Super(Abstract):
pass
class Sub(Super):
pass
sub = Sub.objects.create()
sub.concrete() # returns Super
In actual Mezzanine usage, this allows methods in the Displayable and Orderable abstract models to access the Page instance when instances of custom content types, (eg: models that inherit from Page) need to query the Page model to determine correct values for slug and _order which are only relevant in the context of the Page model and not the model of the custom content type.
Copies a file from Mezzanine’s test data path to MEDIA_ROOT. Used in tests and demo fixtures.
If pep8 is installed, run it across the given package name returning any warnings or errors found.
If pyflakes is installed, run it across the given package name returning any warnings found.
Returns the URL for the given model and admin url name.
Loads the callable defined by the SLUGIFY setting, which defaults to the slugify_unicode function.
Replacement for Django’s slugify which allows unicode chars in slugs, for URLs in Chinese, Russian, etc. Adopted from https://github.com/mozilla/unicode-slugify/
Returns True if the object is editable for the request. First check for a custom editable handler on the object, otherwise use the logged in user and check change permissions for the object’s model.
Identifies form data as being spam, using the http://akismet.com service. The Akismet API key should be specified in the AKISMET_API_KEY setting.
The name, email, url and comment fields are all guessed from the form fields:
If the actual comment can’t be extracted, spam checking is passed.
The referrer field expects a hidden form field to pass the referrer through, since the HTTP_REFERER will be the URL the form is posted from. The hidden referrer field is made available by default with the {% fields_for %} templatetag used for rendering form fields.
Return a paginated page for the given objects, giving it a custom visible_page_range attribute calculated from max_paging_links.
Mimics django.shortcuts.render but uses a TemplateResponse for mezzanine.core.middleware.TemplateForDeviceMiddleware
Set cookie wrapper that allows number of seconds to be given as the expiry time, and ensures values are correctly encoded.