JohanSJA
JohanSJA

Reputation: 705

Is it possible to change the behavior in view of existing apps after new app is installed with touching the existing apps?

Let's take an example of two apps:

So IceCream was developed first, and all the views are Stock are created using the generic Class-Based Views - SListView, SCreateView,SDetailView, SUpdateView and SDeleteView. And the URL mapping are as follows:

And later StockBalance is being developed. Without touching the code from the Stock app, how can I change the behavior of the each view? And what is the common method in Django to do that?

What I want to archieve is that:

Upvotes: 0

Views: 21

Answers (1)

Simeon Visser
Simeon Visser

Reputation: 122436

You can insert the URL mappings of StockBalance in front of those of Stock. This ensures those URLs will be found first by Django and thus you can fully reimplement (inherit / override / etc) what those views will do.

So:

  • /stock/new = implemented by new app
  • /stock/{id} = implemented by new app
  • /stock/... = all others, as before

Upvotes: 1

Related Questions