add ForeignKey

This commit is contained in:
Maxim Kurnikov
2018-11-10 20:03:09 +03:00
parent 233e047117
commit c32a7842d6
5 changed files with 34 additions and 1 deletions

View File

@@ -7,3 +7,5 @@ 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

View File

@@ -0,0 +1,2 @@
def CASCADE(collector, field, sub_objs, using):
...

View File

@@ -0,0 +1,14 @@
from typing import Type, Union, TypeVar, Any, Generic
from django.db import models
from django.db.models import Field
_T = TypeVar('_T', bound=models.Model)
class ForeignKey(Field, Generic[_T]):
def __init__(self,
to: Union[Type[_T], str],
on_delete: Any,
**kwargs): ...
def __get__(self, instance, owner) -> _T: ...