nprati01 / P3_Festival_Ace

1 stars 0 forks source link

Glow Code Snippet #2

Open nprati01 opened 1 year ago

nprati01 commented 1 year ago

I included this code as a glow snippet primarily because it is provides functionality between between both the Festival Model and MyFestival Model. While Im listing it as a Glow because of the relationship it creates I also would describe it as a glow. I wanted to use a class based view for this view function but after several attempts was unable to make it work and changed it to a function based view. Screenshot 2023-04-24 at 1 58 42 PM

maker-jws commented 1 year ago

Other than saying, great work - I would say in this situation you did achieve your goals and your options were limited by the associated ids / FKs you needed to get your three models to work together. There are some pros / cons associated with this approach as well as the View CBV or the Create CBV and in this case there is not a magic bullet (that I know of) for updating / accessing across several related models.

If you were looking for practice a refactor, I would look at the base View CBV as a place to start, or a generic FormView class which is provided context through a get_context_data() custom method.