Skip to content

Commit

Permalink
fix NonDatabaseField
Browse files Browse the repository at this point in the history
  • Loading branch information
leondaz committed Dec 26, 2023
1 parent c5822ad commit cc10580
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions djkit/db/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .fields import MoneyField, NonDatabaseField

__all__ = (
"MoneyField",
"NonDatabaseField",
)
18 changes: 9 additions & 9 deletions djkit/db/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,20 @@ class NonDatabaseField(Field):
prevent_kwargs = ["primary_key", "blank", "editable", "unique"]

def __init__(self, *args, **kwargs):
for kwarg_name in self.prevent_kwargs:
passed_kwargs = []
passed_kwargs = []

for kwarg_name in self.prevent_kwargs:
if kwargs.get(kwarg_name, None):
passed_kwargs.append(kwarg_name)

if passed_kwargs:
raise exceptions.ValidationError(
"parameters [%s] not allowed in %s"
% (
", ".join(passed_kwargs),
self.__class__.__name__,
)
if passed_kwargs:
raise exceptions.ValidationError(
"parameters [%s] not allowed in %s"
% (
", ".join(passed_kwargs),
self.__class__.__name__,
)
)

super().__init__(*args, **kwargs, primary_key=False)

Expand Down

0 comments on commit cc10580

Please sign in to comment.