Overriding app from other app

Hi there
I have been working with Django for a handful of months now, and my project has grown big and unwieldy.

I divided things into different apps but they are quite interconnected, and I was wondering if it is possible to modify an app “behaviour” from within another app.
I’ll make an example:
I have a “base” app, with a model “BaseModel”, and in the admin interface i show the data I want through:

class BaseModelAdmin(ModelAdmin):
    list_display = ("item", "code", "url", "publish")

   def publish(self, obj):
        return format_html('<a  href=/publish?basemodelid={0}>publish</a>&nbsp;',obj.id)

where the “publish” column is a link that sends me to a view that is handled by the “publish” app.

This means that the “base” app cannot exist without the “publish” app, so I would like to take the relevant code and put it in the “publish” admin.py file, so that if “publish” is installed the link would be shown, and otherwise not.
I’ve never come across such thing in the tutorials, and I don’t know what it would be called, so my search attempts have been fruitless.
Is such thing possible? If yes, where should I look for info?

You can’t do it directly - that function is an attribute of the ModelAdmin class. And you don’t have direct control over where and how the ModelAdmin classes are registered in the admin app.

You’ve got a couple different options. For example, you could make your admin class more dynamic. You could create a get_list_display function that builds the list of variables to be displayed by the ModelAdmin class. The information needed to do this could be retrieved directly from your settings. (The specifics for this would depend upon the exact requirements for all of these types of situations.)

Or, depending upon a number of different topics, you might want to reconsider whether the Django Admin really is the right mechanism for providing the functionality desired in your project.

(Side note: I’m a little curious as to what you consider “big and unwieldy”, and why you think that the solution to that issue is to necessarily separate your code into apps.)

@KenWhitesell thanks for the reply

Well, I’m not a professional, I dabble in programming as an hobby, so my version of big is probably tiny. When OOPing I try to build little self contained pieces that I can plug together. It helps me with testing, and also with the sporadic nature of my coding time. Django was a first time, so I was experimenting, adding functionality after functionality, in a trial and error approach, and I came to a point where I wanted to give it a more uniform shape.