mirror of
https://github.com/davidhalter/django-stubs.git
synced 2025-12-19 18:31:15 +08:00
add support for OneToOneField, more stubs
This commit is contained in:
@@ -7,6 +7,10 @@ from .fields import (AutoField as AutoField,
|
||||
Field as Field,
|
||||
SlugField as SlugField,
|
||||
TextField as TextField)
|
||||
from .fields.related import (ForeignKey as ForeignKey)
|
||||
from .deletion import CASCADE as CASCADE
|
||||
from .fields.related import (ForeignKey as ForeignKey,
|
||||
OneToOneField as OneToOneField)
|
||||
from .deletion import (CASCADE as CASCADE,
|
||||
SET_DEFAULT as SET_DEFAULT,
|
||||
SET_NULL as SET_NULL,
|
||||
DO_NOTHING as DO_NOTHING)
|
||||
from .query import QuerySet as QuerySet
|
||||
@@ -1,6 +1,16 @@
|
||||
from typing import Any
|
||||
|
||||
|
||||
class ModelBase(type):
|
||||
pass
|
||||
|
||||
|
||||
class Model(metaclass=ModelBase):
|
||||
pass
|
||||
class DoesNotExist(Exception):
|
||||
pass
|
||||
|
||||
def __init__(self, **kwargs) -> None: ...
|
||||
|
||||
def delete(self,
|
||||
using: Any = ...,
|
||||
keep_parents: bool = ...) -> None: ...
|
||||
@@ -1,2 +1,7 @@
|
||||
def CASCADE(collector, field, sub_objs, using):
|
||||
...
|
||||
def CASCADE(collector, field, sub_objs, using): ...
|
||||
|
||||
def SET_NULL(collector, field, sub_objs, using): ...
|
||||
|
||||
def SET_DEFAULT(collector, field, sub_objs, using): ...
|
||||
|
||||
def DO_NOTHING(collector, field, sub_objs, using): ...
|
||||
|
||||
@@ -10,5 +10,15 @@ class ForeignKey(Field, Generic[_T]):
|
||||
def __init__(self,
|
||||
to: Union[Type[_T], str],
|
||||
on_delete: Any,
|
||||
related_name: str = ...,
|
||||
**kwargs): ...
|
||||
def __get__(self, instance, owner) -> _T: ...
|
||||
|
||||
|
||||
class OneToOneField(Field, Generic[_T]):
|
||||
def __init__(self,
|
||||
to: Union[Type[_T], str],
|
||||
on_delete: Any,
|
||||
related_name: str = ...,
|
||||
**kwargs): ...
|
||||
def __get__(self, instance, owner) -> _T: ...
|
||||
|
||||
Reference in New Issue
Block a user