Edit views

Views

BaseCreateView

class flask_views.db.mongoengine.edit.BaseCreateView

Base view for creating objects.

This class inherits from:

This implements all logic for creating objects, but does not implement the rendering of responses. See CreateView for an usage example.

get(*args, **kwargs)

Handler for GET requests.

This will set self.object to None.

Returns:Output returned by ProcessFormMixin.get().
post(*args, **kwargs)

Handler for POST requests.

This will set self.object to None.

Returns:Output returned by ProcessFormMixin.post().

CreateView

class flask_views.db.mongoengine.edit.CreateView

View for creating objects.

This class inherits from:

This implements all logic for creating objects, including the rendering of a template. Usage example:

class PostCreateView(CreateView):
    form_class = PostForm
    document_class = Post
    template_name = 'post_form.html'

    def get_success_url(self):
        return url_for('posts.index')

BaseUpdateView

class flask_views.db.mongoengine.edit.BaseUpdateView

Base view for updating objects.

This class inherits from:

This implements all logic for retrieving the object for updating and processing the form. This does not implement rendering the responses. See UpdateView for an usage example.

get(*args, **kwargs)

Handler for GET requests.

post(*args, **kwargs)

Handler for POST requests.

UpdateView

class flask_views.db.mongoengine.edit.UpdateView

View for updating objects.

This class inherits from:

This implements all logic for retrieving the object for updating and processing the form. As well this implements the rendering of a template. Usage example:

class PostUpdateView(UpdateView):
    form_class = PostForm
    document_class = Post
    template_name = 'post_form.html'

    def get_success_url(self):
        url_for('posts.index')

See also

SingleObjectMixin.get_fields for more information about how the object is retrieved from the database.

Mixins

ModelFormMixin

class flask_views.db.mongoengine.edit.ModelFormMixin

Mixin for handling model-form processing.

This class inherits from:

form_valid(form)

Handle a valid form submission.

When editing an object, the object will be updated and saved, else a new object will be created and saved.

Returns:Output returned by FormMixin.form_valid().
get_context_data(**kwargs)

Return context data for rendering template.

This adds self.object as object to the context data returned by FormMixin.get_context_data().

Returns:A dict containing the context data.
get_form_kwargs()

Return parameters for creating the form instance.

This adds a model instance (or None) to the form parameters returned by FormMixin.get_form_kwargs().

Returns:A dict containing the arguments for creating the form instance.

Table Of Contents

Related Topics

This Page