diff options
| author | Santo Cariotti <dcariotti24@gmail.com> | 2020-04-06 19:54:53 +0000 |
|---|---|---|
| committer | Santo Cariotti <dcariotti24@gmail.com> | 2020-04-06 19:54:53 +0000 |
| commit | 3a2246e26e9febe3c15e2ddc1e7e6f320f86fe15 (patch) | |
| tree | 9cbd95771d38dfd66bedb4a447470391d34a68eb /frest/forms.py | |
| parent | 6188a952974b3e268936beb1027ea58fbfaa67aa (diff) | |
chore: move package in frest folder
Diffstat (limited to 'frest/forms.py')
| -rw-r--r-- | frest/forms.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/frest/forms.py b/frest/forms.py new file mode 100644 index 0000000..8ce2e95 --- /dev/null +++ b/frest/forms.py @@ -0,0 +1,20 @@ +class ModelForm(object): + def __init__(self, model): + self.data = {} + self.model = model + no_params = ["metadata", "query", "query_class"] + self.attributes = [ + i for i in dir(self.model) if not i.startswith("_") and i not in no_params + ] + self.ignore = [] + + def is_valid(self): + for key, value in self.data.items(): + if key in self.attributes: + if (value == "" or not value) and key not in self.ignore: + return False + + return True + + def get(self, attr): + return self.data.get(attr) |
