django-forms-frontend-validation 1.0.4__py3-none-any.whl → 1.0.5__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: django-forms-frontend-validation
3
- Version: 1.0.4
3
+ Version: 1.0.5
4
4
  Summary: A Django app for front-end form validation
5
5
  Home-page: https://github.com/andrew-kyle92/django-forms-frontend-validation
6
6
  Author: Andrew Kyle
@@ -34,11 +34,13 @@ The application is designed to streamline the process of form validation, ensuri
34
34
  - Includes CSRF token management for secure AJAX-based form submissions.
35
35
 
36
36
  ## Usage
37
+ ### Installation
38
+ 1. Install the Django project
39
+ ```cmd
40
+ pip install django-frontend-forms-validation
41
+ ```
37
42
  ### Setting Up
38
- 1. Include Required Components:
39
- - Include the JavaScript files in your project to enable client-side functionality.
40
- - Ensure `form_utils.py` is imported and accessible in your Django app.
41
- 2. Define Settings in settings.py
43
+ 1. Define Settings in settings.py
42
44
  - Add `formvalidator` to installed apps.
43
45
  ```python
44
46
  INSTALLED_APPS = [
@@ -54,7 +56,7 @@ The application is designed to streamline the process of form validation, ensuri
54
56
  IGNORE_VALIDATION = ['example-ignore-validation', ...]
55
57
  VALIDATE_ONLY_ON_SUBMIT = ['all'] # Options: "__all__", specific class names, or leave empty.
56
58
  ```
57
- 3. Initial Forms:
59
+ 2. Initial Forms:
58
60
  - Ensure the `_InitializeForms` method is called during page load to attach validation logic to forms dynamically.
59
61
  To your HTML template with the form, add this.
60
62
  ```html
@@ -74,7 +76,7 @@ The application is designed to streamline the process of form validation, ensuri
74
76
  });
75
77
  </script>
76
78
  ```
77
- 4. Server-Side Context:
79
+ 3. Server-Side Context:
78
80
  - Use the `FormsValidator` class to pass configuration to templates:
79
81
  ```python
80
82
  from formvalidator.form_utils import FormsValidator
@@ -87,3 +89,39 @@ The application is designed to streamline the process of form validation, ensuri
87
89
  }
88
90
  return render(request, 'my_template.html', context)
89
91
  ```
92
+ 4. Add `div` Groups to the HTML Form:
93
+ - The JavaScript in this project relies on each form field being wrapped inside an outer div with the classname of ```form-group```.
94
+ - It helps set apart each input from other inputs within the form.
95
+ - Here is an example of the setup:
96
+ ```html
97
+ <form ...>
98
+ {% csrf_token %}
99
+
100
+ <div class="form-group">
101
+ <label for="field1">Field 1</label>
102
+ <input type="text" name="field1">
103
+ </div>
104
+
105
+ <div class="form-group">
106
+ <label for="field2">Field 1</label>
107
+ <input type="text" name="field2">
108
+ </div>
109
+
110
+ <-- Adding the rest of the form groups below -->
111
+ ...
112
+ </form>
113
+ ```
114
+ - If iterating through each form input using the ```form``` context variable:
115
+ ```html
116
+ <form ...>
117
+ {% csrf_token %}
118
+
119
+ <-- iterating through each form field -->
120
+ {% for field in form %}
121
+ <div class="form-group">
122
+ <label for="{{ field.name }}">{{ field.label }}</label>
123
+ {{ field }}
124
+ </div>
125
+ {% endfor %}
126
+ </form>
127
+ ```
@@ -21,8 +21,8 @@ formvalidator/templates/base.html,sha256=husejzZpyn7DKk-3S6frsalTMz4-ZO5EV5GWobW
21
21
  formvalidator/templates/formvalidator/sample.html,sha256=IKklx25wt-paXmfaMbSZfTZaWFzlq_BGMOuVKACNpyI,2048
22
22
  formvalidator/templates/formvalidator/sample2.html,sha256=_E5Rtv4fWOut5dbpRsguoEUw-X_Hln6wok4g2KPlzCo,2129
23
23
  formvalidator/templates/includes/header.html,sha256=5EWbHxj-JFu7fzmGUWWqOxoG2bwl03UwwUG_O68qzj0,946
24
- django_forms_frontend_validation-1.0.4.dist-info/LICENSE,sha256=gA3cqug2Eqh9zkbcEDQ1Ez1APddDnmbX6bO6_wcBRM8,1095
25
- django_forms_frontend_validation-1.0.4.dist-info/METADATA,sha256=heJyVqKbV2b-Y9-4puM282id75TGa5DNvw2w0OvVO4w,4028
26
- django_forms_frontend_validation-1.0.4.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
27
- django_forms_frontend_validation-1.0.4.dist-info/top_level.txt,sha256=E9SLf9Mg8MAqnCin_sgh__XTquz_st_-Qyy9w3-3fms,14
28
- django_forms_frontend_validation-1.0.4.dist-info/RECORD,,
24
+ django_forms_frontend_validation-1.0.5.dist-info/LICENSE,sha256=gA3cqug2Eqh9zkbcEDQ1Ez1APddDnmbX6bO6_wcBRM8,1095
25
+ django_forms_frontend_validation-1.0.5.dist-info/METADATA,sha256=kSXSZ8Qzv7JojQleBT7Sww0Wed-QagqPsSuVkDtUirY,5091
26
+ django_forms_frontend_validation-1.0.5.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
27
+ django_forms_frontend_validation-1.0.5.dist-info/top_level.txt,sha256=E9SLf9Mg8MAqnCin_sgh__XTquz_st_-Qyy9w3-3fms,14
28
+ django_forms_frontend_validation-1.0.5.dist-info/RECORD,,