|
2 | 2 | import inspect |
3 | 3 | import logging |
4 | 4 | import pickle |
5 | | -from typing import Any, Callable, Dict, List, Optional, Type, Union |
| 5 | +from typing import Any, Callable, Dict, List, Optional, Sequence, Type, Union |
6 | 6 |
|
7 | 7 | from django.core.exceptions import ImproperlyConfigured |
8 | 8 | from django.db.models import Model |
@@ -471,6 +471,13 @@ def get_frontend_context_variables(self) -> str: |
471 | 471 | attributes = self._attributes() |
472 | 472 | frontend_context_variables.update(attributes) |
473 | 473 |
|
| 474 | + # Remove any field in `javascript_exclude` from the `frontend_context_variables` |
| 475 | + if hasattr(self, "Meta") and hasattr(self.Meta, "javascript_exclude"): |
| 476 | + if isinstance(self.Meta.javascript_exclude, Sequence): |
| 477 | + for field_name in self.Meta.javascript_exclude: |
| 478 | + if field_name in frontend_context_variables: |
| 479 | + del frontend_context_variables[field_name] |
| 480 | + |
474 | 481 | # Add cleaned values to `frontend_content_variables` based on the widget in form's fields |
475 | 482 | form = self._get_form(attributes) |
476 | 483 |
|
@@ -746,7 +753,8 @@ def _is_public(self, name: str) -> bool: |
746 | 753 | excludes = [] |
747 | 754 |
|
748 | 755 | if hasattr(self, "Meta") and hasattr(self.Meta, "exclude"): |
749 | | - excludes = self.Meta.exclude |
| 756 | + if isinstance(self.Meta.exclude, Sequence): |
| 757 | + excludes = self.Meta.exclude |
750 | 758 |
|
751 | 759 | return not ( |
752 | 760 | name.startswith("_") |
|
0 commit comments