{"id":28503834,"url":"https://github.com/michaelmob/django-semanticui-forms","last_synced_at":"2025-07-05T19:31:46.148Z","repository":{"id":57421846,"uuid":"63733213","full_name":"michaelmob/django-semanticui-forms","owner":"michaelmob","description":"Effortlessly style all of your Django forms and form fields with Semantic UI wrappers.","archived":false,"fork":false,"pushed_at":"2019-04-10T13:29:21.000Z","size":66,"stargazers_count":60,"open_issues_count":7,"forks_count":14,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-06-04T10:03:13.902Z","etag":null,"topics":["django","forms","semantic-ui"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaelmob.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-19T22:55:53.000Z","updated_at":"2025-03-11T02:14:07.000Z","dependencies_parsed_at":"2022-09-10T13:21:46.030Z","dependency_job_id":null,"html_url":"https://github.com/michaelmob/django-semanticui-forms","commit_stats":null,"previous_names":["thetarkus/django-semanticui-forms"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/michaelmob/django-semanticui-forms","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmob%2Fdjango-semanticui-forms","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmob%2Fdjango-semanticui-forms/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmob%2Fdjango-semanticui-forms/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmob%2Fdjango-semanticui-forms/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaelmob","download_url":"https://codeload.github.com/michaelmob/django-semanticui-forms/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaelmob%2Fdjango-semanticui-forms/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260927194,"owners_count":23083974,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","forms","semantic-ui"],"created_at":"2025-06-08T17:31:25.229Z","updated_at":"2025-07-05T19:31:46.142Z","avatar_url":"https://github.com/michaelmob.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Semantic UI for Django Forms\nEffortlessly style all of your Django forms and form fields with Semantic UI wrappers.\n\n\n#### Starting Off\n1. Install this `django-semanticui-forms` with pip or git.  \n```\npip install django-semanticui-forms\n```\n2. Add `semanticuiforms` to your `INSTALLED_APPS`.\n3. Load the templatetags into your template `{% load semanticui %}`  \n\n#### Template Tag\nTo render a form, it's as simple as `{% render_form my_form %}`  \n\nIt is possible to render each field individually allowing for more\ncustomization within the template. `{% render_field my_form.field %}`  \n\n## Attributes\n#### Form Attributes  \nForm attributes given to the template tag that are not specified for internal\nuse are passed onto each field.\n\nIt is possible to exclude fields from `render_form` using the `exclude` parameter.\nFields to be excluded should be separated by commas.  \n```html\n{% render_form my_form exclude='field1,field3' %}\n```  \n\nFor example: `{% render_form my_form name='Hello' %}` will add a name attribute\nto each field in that form.\n\nFor good use: `{% render_form my_form _help=1 %}` will display the field's\nhelp_text on all fields.  \n\n #### Field Attributes\nAny attribute can be assigned to most fields. This can be done by either\nassigning within the form class or on-the-fly in the template.\n\n**In form class**\n```python\nfield = forms.CharField(widget=forms.TextInput(attrs={\"value\": \"Testing\"}))\n```\n\n**In template tag**\n```html\n{% render_field my_form.field value='My Value' placeholder='Put your text here!' %}\n```\n\nSpecific attributes can modify how your fields are rendered. Private attributes\nstart with a `_` and will not be added to the field's attributes. These attributes\ncan be set in the form class or as an argument like above.\n\n* `_no_label`: Do not show label\n* `_no_required`: Do not show required asterisk\n* `_required`: Do show required asterisk (assumes `_no_required` is absent)\n* `_no_errors`: Do not show inline errors\n* `_inline`: Adds inline class to field\n* `_field_class`: Allows for custom field classes\n* `_override`: Render as a different input type\n* `_style`: Stylize specific fields (BooleanField, ChoiceField)\n    * `BooleanField`: set to 'toggle' or 'slider'\n    * `ChoiceField`: set to 'search' or 'multiple' and more\n* `_icon`: Put icon on field\n* `_dropdown_icon`: Set dropdown icon for ChoiceFields, defaults to 'dropdown'\n* `_help`: Display `help_text` if available\n* `_align`: Used with `_icon`, which side icon is on; not required\n\n#### Icons\nIcons can be added to input fields easily. Add the attribute `_icon` and\noptionally `_align` to your arguments.\n\n```html\n{% render_field my_form.field _icon='star' _align='left' %}\n```\n\n## Custom/Overriding Fields\n#### Override to render as different field\nOverriding the function that renders the field is done using the `_override`\nattribute. This is useful for things like using `CountrySelect` as it is\nnot its own field type.  \n\n\n### Custom ChoiceFields\n\n**CountrySelect**  \n`CountrySelect` from the `django-countries` package can be used to create a nice\nfield that displays a list of countries alongside their flags, to access it you\nmust set the `_override` attribute to `CountrySelect`.\n\n**Icon ChoiceField**  \n`IconSelect` can be used with overriding just like `CountrySelect`. This\nfield is useful since icons can be placed next to the values in the field.\n\n```python\n# Python\n# (\"key\", \"value|icon\")\nchoices = (\n    (\"male\", \"Male|man\"),\n    (\"female\", \"Female|woman\"),\n    (\"other\", \"Other|genderless\"),\n)\n\n# Template\n{% render_field my_form.gender _override='IconSelect' %}\n```\n\n## Layouts\nUsing Semantic UI's form layout classes with \u003ci\u003eSemantic UI Forms for Django\u003c/i\u003e is simple.  \nWithin your form's Meta class, simply create a `layout` list. Within that list,\ncreate tuples with an function name as the first value, and the value as the second.  \n\nFunctions names are as followed:\n* `Text` is for any text or HTML markup. Text in this is considered safe.\n* `Field`'s value must be the name of a field.\n* `[X] Fields` are containers. It's value must include `Field` items or more\n`[X] Field` items. `[X]` should be replaced, either by a number or a class.\nAll items inside this will be wrapped with a `div` that has the class of the key.\n    * `Four Fields`\n    * `Six Fields`\n    * `Inline Fields`\n    * `Equal Width Fields`\n\nTo set \"wideness\" of a specific field, you must add it to the `_field_class`\nattribute on your field. It cannot be done in the `layout`.\n\n```python\nclass ExampleLayoutForm(forms.Form):\n    class Meta:\n        layout = [\n            (\"Text\", \"\u003ch4 class=\\\"ui dividing header\\\"\u003ePersonal Details\u003c/h4\u003e\"),\n            (\"Three Fields\",\n                (\"Field\", \"first_name\"),\n                (\"Field\", \"middle_initial\"),\n                (\"Field\", \"last_name\"),\n            ),\n\n            (\"Text\", \"\u003ch4 class=\\\"ui dividing header\\\"\u003eMore Details\u003c/h4\u003e\"),\n            (\"Inline Fields\",\n                (\"Field\", \"website\"),\n                (\"Field\", \"email\"),\n            ),\n\n            (\"Text\", \"\u003ch4 class=\\\"ui dividing header\\\"\u003eComplicated Details\u003c/h4\u003e\"),\n            (\"Four Fields\",\n                (\"Field\", \"first_name\"),\n                (\"Field\", \"middle_initial\"),\n                (\"Field\", \"last_name\"),\n                (\"Two Fields\",\n                    (\"Field\", \"username\"),\n                    (\"Field\", \"email\"),\n                ),\n            ),\n\n            (\"Field\", \"helpful\")\n        ]\n\n\n    username = forms.CharField()\n    first_name = forms.CharField()\n    middle_initial = forms.CharField()\n    last_name = forms.CharField()\n    website = forms.CharField()\n    email = forms.EmailField()\n    phone_number = forms.CharField()\n    helpful = forms.BooleanField()\n```\n\n\n## Settings\nOverride wrappers by finding the wrapper variable name and prepending `SUI_` to it\nand inserting it into your `settings.py`.  \n```python\nSUI_ERROR_WRAPPER = \"\u003cdiv class=\\\"ui red pointing prompt label\\\"\u003e%(message)s\u003c/div\u003e\"\n```   \n\nYou can also change the default placeholder text.\n```python\nSUI_PLACEHOLDER_TEXT = \"Select Option\"\n```\n\n## Basic Semantic UI Validation Generator\n\u003ci\u003eSemantic UI Forms for Django\u003c/i\u003e can generate a basic validation configuration for your form. The generator is very basic and does not have many features. It is only intended to give you a starting point.  \n\nView https://semantic-ui.com/behaviors/form.html for more details.\n\n```bash\npython manage.py semanticuivalidation app.forms.ExampleForm [--shorthand]\n```\n\n\n## Testing\n1. Create a virtual environment.  \n```bash\nvirtualenv -p $(which python3) .env\n```\n\n2. Source the activation script.  \n```bash\nsource .env/bin/activate\n```\n\n3. Set current directory to the `semanticuiforms` app and then install Python requirements.\n```bash\npip install -r requirements.txt\n```\n\n4. Inside of the `example` app, make and run migrations for testing purposes.\n```bash\npython manage.py makemigrations \npython manage.py migrate \n```\n\n5. Run tests.\n```bash\npython manage.py test semanticuiforms \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelmob%2Fdjango-semanticui-forms","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaelmob%2Fdjango-semanticui-forms","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaelmob%2Fdjango-semanticui-forms/lists"}