Package: django-html-sweatshop
Some common html renderings are tedious. Let django-html-sweatshop do the hard work.FeaturesDigg style pagination with optional integration with django-tables2Display messagesPop up confirmation dialog before deletingInstallationTo get started usingdjango-html-sweatshop:install it withpip:$ pip install django-html-sweatshopadd the app toINSTALLED_APPS:INSTALLED_APPS = (
    ...
    'html_sweatshop',
    'django_tables2', #Required if you need digg style pagination
    ...
)Digg Style PaginationA set of tags are provided to render digg style pagination. To use these tags, load them in the template{% load digg_pagination_tags %}Raw PaginationUsage:{% digg_paginator page_obj page_field theme %}This is the raw way to render pagination. You have to take care of actual work of pagination (some generic view can do that part of work for you) as outlined inhttps://docs.djangoproject.com/en/1.9/topics/pagination/. This tag will take care of the rendering of pagination. It provides greater flexibility than the other two.page_objOptional. A page object as outlined inhttps://docs.djangoproject.com/en/1.9/topics/pagination/#page-objects. By default, a variable named “page_obj” in the context will be used if it’s not provided.page_fieldOptional. The name of the page parameter in the url. For example, if “page_field” is set to “page”, when the link of the second page is clicked, “page=2” will be appended to the url. The default value is “page”.themeOptional. The theme pack to use. Right now Bootstrap 3 is the only valid theme available. So there’s no need to set this parameter.Django-table2 IntegrationUsage:{% digg_paginator_tables2 table theme %}This tag provides integration with django-tables2. It’s usually used along side with the SingleTableView generic view shipped with django-tables2. But the tables rendered by django-tables2 tag might look alien with the pagination without overriding the default table template.tableOptional. A table instance of django-tables2. Please refer to django-tables2 document regarding table class. By default, a variable named “table” in the context will be used if it’s not provided.themeOptional. The theme pack to use. Right now Bootstrap 3 is the only valid theme available. So there’s no need to set this parameter.Django-table2 Seamless IntegrationUsage:{% render_paginated_table table theme %}This tag provides seamless integration with django-tables2. Unlike the other two tags which only render pagination, this tag render table and pagination altogether.tableOptional. A table instance of django-tables2. Please refer to django-tables2 document regarding table class. By default, a variable named “table” in the context will be used if it’s not provided.themeOptional. The theme pack to use. Right now Bootstrap 3 is the only valid theme available. So there’s no need to set this parameter.Message CentreA tag to display all the messages with meaningful background color and icons. To use this tag, load it in the template{% load message_centre_tags %}Then at where you want to display the messages{% message_centre dismissible theme %}dismissibleOptional. A boolean value to indicate if the messages are dissmissible (depending on the theme pack). By default, its value is HTML_SWEATSHOP_MESSAGE_CENTRE_MESSAGE_DISMISSIBLE which defaults to True.themeOptional. The theme pack to use. Right now Bootstrap 3 is the only valid theme available. So there’s no need to set this parameter.One Step DeleteDeleteView generic view makes deletion a two step process. First step, a confirmation page is rendered. Second step, the deletion is submitted. But in most systems, it’s more desirable to simply pop up a confirmation modal before submitting the deletion, all happening on the same page.A tag and a Jquery plugin are provided to make it simpler.Load the tag definition{% load one_step_delete_tags static %}Load the JQuery pluginLoad the JQuery plugin at where js should be included. It’s your own responsibility to include JQuery itself.{% include_one_step_delete_js %}<script type=”text/javascript” src=”{% static ‘one_step_delete/js/init_one_step_delete.js’ %}”></script>Render delete buttonsRender delete buttons depending on the theme pack. Take Bootstrap 3 theme as an example, a delete button can be<button class=”btn btn-danger” data-toggle=”modal” data-target=”…” data-modal-title=”…” data-modal-action=”…” data-obj-description=”…”>…</button>A few JQuery plugin specific data properties can be defined to allow multiple delete buttons to share the same confirmation modal.data-modal-titleReplace the modal title with this value when the button is clicked.data-modal-actionReplace the action url of deletion submission with this value when the button is clicked.data-obj-descriptionIf you are satisfied with the overall message in the modal body, you can replace the description of the object to delete with this value to fine tune the message when the button is clicked.data-bodyReplace the message of the modal body with this value totally when the button is clicked.Render confirmation modalsUse the following tag to render the confirmation modal. You can render each confirmation modal for each delete button or you can render one to be shared among delete buttons.{% render_confirm_modal dialog_id obj obj_description url title body theme %}dialog_idOptional. The HTML id of the confirmation modal. Defaults to “confirmation-modal”.objOptional. A model object to be deleted. Once provided, a default confirmation message can be inferred by the tag.obj_descriptionOptional. The default confirmation message use the verbose name of “obj” as the description. It can be overridden by this parameter.urlOptional. The action url delete is submitted to. By default it’s empty.titleOptional. The title of the confirmation modal. By default, it’s “Are you sure?”bodyOptional. Used to override the whole default confirmation message.themeOptional. The theme pack to use. Right now Bootstrap 3 is the only valid theme available. So there’s no need to set this parameter.SettingsHTML_SWEATSHOP_DIGG_PAGINATION_LEADING_PAGE_RANGE_DISPLAYEDDefaults to 10HTML_SWEATSHOP_DIGG_PAGINATION_TRAILING_PAGE_RANGE_DISPLAYEDDefaults to 10HTML_SWEATSHOP_DIGG_PAGINATION_NUM_PAGES_OUTSIDE_RANGEDefaults to 2HTML_SWEATSHOP_DIGG_PAGINATION_LEADING_PAGE_RANGEDefaults to 8HTML_SWEATSHOP_DIGG_PAGINATION_TRAILING_PAGE_RANGEDefaults to 8HTML_SWEATSHOP_DIGG_PAGINATION_ADJACENT_PAGESDefaults to 4HTML_SWEATSHOP_THEMEThe theme pack to use. Defauls to ‘bootstrap3’HTML_SWEATSHOP_MESSAGE_CENTRE_MESSAGE_DISMISSIBLEIf the messages are dimissible. Defaults to TrueDemoCheckout the source codes. Inside the source codes folder, run the following commands:mkvirtualenv demopip install -r requirements.txtpython manage.py runserverHow to contributeFork the project and submit pull requests. Need more theme packs.