MCPcopy
hub / github.com/django/django / create_model

Method create_model

tests/migrations/test_state.py:1950–1972  ·  view source on GitHub ↗
(
        self, name, foreign_keys=[], bases=(), abstract=False, proxy=False
    )

Source from the content-addressed store, hash-verified

1948 self.apps = Apps(["migrations.related_models_app"])
1949
1950 def create_model(
1951 self, name, foreign_keys=[], bases=(), abstract=False, proxy=False
1952 ):
1953 test_name = "related_models_app"
1954 assert not (abstract and proxy)
1955 meta_contents = {
1956 "abstract": abstract,
1957 "app_label": test_name,
1958 "apps": self.apps,
1959 "proxy": proxy,
1960 }
1961 meta = type("Meta", (), meta_contents)
1962 if not bases:
1963 bases = (models.Model,)
1964 body = {
1965 "Meta": meta,
1966 "__module__": "__fake__",
1967 }
1968 fname_base = fname = "%s_%%d" % name.lower()
1969 for i, fk in enumerate(foreign_keys, 1):
1970 fname = fname_base % i
1971 body[fname] = fk
1972 return type(name, bases, body)
1973
1974 def assertRelated(self, model, needle):
1975 self.assertEqual(

Callers 15

test_unrelatedMethod · 0.95
test_direct_fkMethod · 0.95
test_direct_hidden_fkMethod · 0.95
test_fk_through_proxyMethod · 0.95
test_nested_fkMethod · 0.95
test_two_sidedMethod · 0.95
test_circleMethod · 0.95
test_baseMethod · 0.95
test_nested_baseMethod · 0.95
test_multiple_basesMethod · 0.95
test_base_to_base_fkMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected