File tree Expand file tree Collapse file tree 3 files changed +16
-18
lines changed Expand file tree Collapse file tree 3 files changed +16
-18
lines changed Original file line number Diff line number Diff line change 1212
1313
1414class DjangoOrmModel (CrudModel ):
15- def __init__ (self , model : Type [models .Model ]) :
15+ def __init__ (self , model : Optional [ Type [models .Model ]] = None ) -> None :
1616 self .model = model
17- config = ModelMetaConfig ()
18- exclude_list = config .get_final_excluded_list (self .model ())
19- self .m2m_fields_list : List = list (
20- _field
21- for _field in self .model ._meta .get_fields (include_hidden = True )
22- if (
23- isinstance (_field , models .ManyToManyField )
24- and ((_field not in exclude_list ) if exclude_list else True )
17+ if self .model :
18+ config = ModelMetaConfig ()
19+ exclude_list = config .get_final_excluded_list (self .model ())
20+ self .m2m_fields_list : List = list (
21+ _field
22+ for _field in self .model ._meta .get_fields (include_hidden = True )
23+ if (
24+ isinstance (_field , models .ManyToManyField )
25+ and ((_field not in exclude_list ) if exclude_list else True )
26+ )
2527 )
26- )
27- super ().__init__ (self .model )
28+ super ().__init__ (self .model )
2829
2930 def _separate_payload (self , payload : Dict ) -> Tuple [Dict , Dict ]:
3031 m2m_fields = {}
Original file line number Diff line number Diff line change 11import logging
2- from typing import Type
2+ from typing import Optional , Type
33
44from django .db import models
55
1010
1111
1212class BaseService (CrudService , PermissionService ):
13- def __init__ (
14- self ,
15- model : Type [models .Model ],
16- ):
13+ def __init__ (self , model : Optional [Type [models .Model ]] = None ):
1714 self .model = model
1815 super ().__init__ (model = self .model )
Original file line number Diff line number Diff line change 11import logging
2- from typing import Any , Type
2+ from typing import Any , Optional , Type
33
44from asgiref .sync import sync_to_async
55from django .db import models
1010
1111
1212class CrudService (DjangoOrmModel ):
13- def __init__ (self , model : Type [models .Model ]):
13+ def __init__ (self , model : Optional [ Type [models .Model ]] = None ):
1414 super ().__init__ (model )
1515 self .model = model
1616
You can’t perform that action at this time.
0 commit comments