What is the best way to create a UML class diagram for a Django project that uses the MVT design pattern, especially when using the function-based views in the project? Is it correct to treat views as classes even if they're function-based ones? I have a mix of class-based and function-based views, so the option looks convenient, but I'm not sure if that's correct from a technical perspective. Also, can I treat the templates as the classes?
2 Answers
UML from django model - pls check this
https://simpleit.rocks/python/django/generate-uml-class-diagrams-from-django-models/

- 21
- 2
Yes, in UML, you may represent an independent function with a class as explained here.
I do not know django, nor MVT, but it appears that by its official definition a view is a callable:
A view is a callable which takes a request and returns a response. This can be more than just a function, and Django provides an example of some classes which can be used as views. These allow you to structure your views and reuse code by harnessing inheritance and mixins.
So in this context, it would even be recommended to represent it as a class, since the function is a special case of the more general class of callables.
The django template appears to be defined by a file (data), that may be used to instantiate a Template
object. So each template of your project would end up as a different object, and there should be only one Template
class.

- 68,716
- 7
- 72
- 138