Admin
- class django_faker_admin.mixins.FakerModelAdminMixin[source]
A mixin for Django ModelAdmin classes to add functionality for generating dummy data.
This mixin provides a custom view for populating dummy data in the admin interface. It allows administrators to easily create dummy instances of a model using a specified factory class.
- change_list_template = 'admin/faker_admin_change_list.html'
The template used for the change list view in the admin interface.
- factory_class = None
The factory class used to generate dummy model instances.
- faker_view(request, extra_context=None)[source]
View function to render the populate dummy data form and handle form submissions.
This method is invoked when the custom URL for populating dummy data is accessed. It renders a view that allows the user to specify the number of dummy instances to create. The view is generated using the PopulateDummyDataAdminView class.
- Parameters:
request (-) – The HttpRequest object.
extra_context (-) – Additional context data to pass to the template. Defaults to None.
- Returns:
The response generated by the PopulateDummyDataAdminView.
- Return type:
HttpResponse
- get_faker_view_class(request)[source]
Returns the view class used for populating dummy data. This method can be overridden to provide a custom view class if needed.
- Parameters:
request (-) – The HttpRequest object.
- Returns:
The view class to be used for dummy data population. By default, it returns the FakerAdminView.
- Return type:
class
- get_faker_view_kwargs(request)[source]
Returns the keyword arguments to be passed to the view class. This method can be overridden to provide additional context or configuration for the view.
- Returns:
A dictionary of keyword arguments to be passed to the view class.
- Return type:
dict
- get_urls()[source]
Extends the ModelAdmin’s URLs to include a custom path for the dummy data population view.
This method adds a new URL pattern that points to the populate_dummy_data_view method. It ensures that the custom view integrates seamlessly with the existing admin URLs.
- Returns:
A list of URL patterns, including the new pattern for dummy data population.
- Return type:
list