I'm trying to understand how modelforms work in Django, so am going through the source code, and diagramming it out.
I'm stuck on this particular function in forms.widgets.py though, and I wonder if someone could explain it. Thank you.
What does the "type" argument mean? What are the args in "new"? I understand that this is returning a new class, but that's the extent of my comprehension.
Here is a link to the original code.
class MediaDefiningClass(type):
"""
Metaclass for classes that can have media definitions.
"""
def __new__(mcs, name, bases, attrs):
new_class = super(MediaDefiningClass, mcs).__new__(mcs, name, bases, attrs)
if 'media' not in attrs:
new_class.media = media_property(new_class)
return new_class