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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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.6
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
+ ```
@@ -3,7 +3,7 @@ formvalidator/admin.py,sha256=suMo4x8I3JBxAFBVIdE-5qnqZ6JAZV0FESABHOSc-vg,63
3
3
  formvalidator/apps.py,sha256=3C-Kq3f9oo1nB2RMXXC0jqYEYYV0MYkVg2nI1GIJE3Y,158
4
4
  formvalidator/forms.py,sha256=PSOiyrwDN_5XuX-f9l8ZAQozZwNo5PhZCRTAKl_Jlig,775
5
5
  formvalidator/models.py,sha256=Vjc0p2XbAPgE6HyTF6vll98A4eDhA5AvaQqsc4kQ9AQ,57
6
- formvalidator/settings.py,sha256=5ZckcudXktsLXdYykJ0q2EzgNQuaJ2_Mn95ZDWgPK94,712
6
+ formvalidator/settings.py,sha256=F5R5OxPB0ZOMKfuYH69etPP-mdntmgHH1sVyv_tAd0Y,709
7
7
  formvalidator/tests.py,sha256=jq5sY8A7Pe0VQ-j33gRJTRgBf-BPu4I6Z2sND68EP8A,842
8
8
  formvalidator/urls.py,sha256=Y2NSQC0IzLEHU4HqNhx_8DnQhScV9D8Ssbc8WGueTMA,301
9
9
  formvalidator/views.py,sha256=TYqBRjnpKccQZA-Dwajp0heJ7-rhEkHetkGqSd12cJs,1391
@@ -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.6.dist-info/LICENSE,sha256=gA3cqug2Eqh9zkbcEDQ1Ez1APddDnmbX6bO6_wcBRM8,1095
25
+ django_forms_frontend_validation-1.0.6.dist-info/METADATA,sha256=Wiaj50uTgNWofLUcRKc6i_VE-SoTi4Cht6pi7k2Bjug,5091
26
+ django_forms_frontend_validation-1.0.6.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
27
+ django_forms_frontend_validation-1.0.6.dist-info/top_level.txt,sha256=E9SLf9Mg8MAqnCin_sgh__XTquz_st_-Qyy9w3-3fms,14
28
+ django_forms_frontend_validation-1.0.6.dist-info/RECORD,,
formvalidator/settings.py CHANGED
@@ -11,4 +11,4 @@ IGNORE_VALIDATION = [] + IGNORED_CLASSES
11
11
  # the string keyword options are 'all', '__all__', '*'
12
12
  # if you would like to keep the type as an array, but still want to hit all forms, you can just set
13
13
  # index 0 as one of those keywords
14
- VALIDATE_ONLY_ON_SUBMIT = ["*"]
14
+ VALIDATE_ONLY_ON_SUBMIT = []