Forms

Forms for creating and modifying database objects. Please refer to django.forms for general information about Django forms (see also: Working with forms).

Custom Model Form

class integreat_compass.cms.forms.custom_model_form.CustomModelForm(**kwargs)

Bases: ModelForm

Form for populating all text widgets of a ModelForm with the default placeholder “Enter … here”. Use this form as base class instead of django.forms.ModelForm.

Form fields:

__init__(**kwargs)

Initialize placeholder model form

Parameters:

**kwargs (dict) – The supplied keyword arguments

Raises:

TypeError – If form is instantiated directly without an inheriting subclass

add_error_messages(request)

This function accepts the current request and adds the form’s error messages to the message queue of django.contrib.messages.

Parameters:

request (HttpRequest) – The current request submitting the form

clean()

This method extends the default clean()-method of the base ModelForm to provide debug logging

Returns:

The cleaned data (see Overriding the clean() method)

Return type:

dict

get_error_messages()

Return all error messages of this form and append labels to errors

Returns:

The errors of this form

Return type:

list

property media

Return all media required to render the widgets on this form.

save(commit=True)

This method extends the default save()-method of the base ModelForm to provide debug logging

Parameters:

commit (bool) – Whether or not the changes should be written to the database

Returns:

The saved object returned by The save() method

Return type:

object

integreat_compass.cms.forms.custom_model_form.lowfirst(string)

Make the first letter of a string lowercase (counterpart of capfirst(), see also capfirst).

Parameters:

string (str) – The input text

Returns:

The lowercase text

Return type:

str