Chicken and Egg scenario for URLs

Can this be done with Django?
Seems like a chicken and egg problem to me.

Background: a dear friend has a mess of a broken website, with a life’s work of clinical/medical data loaded into a postgreSQL DB. His developer left the project in pieces on the ground ( with good reasons, unrelated) .It would be nice if some of the backend could be salvaged. Current stack includes Postgresql, Django, and a bunch of other acronyms and names of which I am not familiar. I have not been a programmer for > 40 years ( C and assembler), so I am not helpful, just asking questions and helping him formulate a plan. I’ve familiarized myself a tiny bit with an overview of Django to try to be able to ask this question ( one which his programmer told him the answer was an adamant NO), and I do hope I have simplified it enough and explained the issue here.

a vastly oversimplified example/scenario describing the problem:

For every town in a state:
Data entered using Django Admin pages residing in a PostgreSQL database. Imagine data of various types, i.e. name of town, zip code, text, images, videos, charts, graphs, etc.
One page of the site generates a list of the towns, and end-user can select a town and a Template is rendered with a “block body”. The body block is dynamically generated from the database, and contains his data.

The chicken and egg scenario: friend needs to be able to link to other towns in his database during his Django Admin data entry.( i.e, while entering text data via a WYSIWYG in Django Admin for townA, he might want to reference ( insert a url link) to TownD.)
in my rudimentary understanding of Django, because these town pages are dynamically generated, this would not be possible because the individual towns do not have URL’s in the URLs.py file.

So… how to afford him a way to do this as he creates or edits a town? Again, his lost programmer told him this was not possible ( I do question, to myself, WHY this requirement wasn’t baked into the original design)

Either I am missing a fundamental understanding, or his programmer that bailed was incorrect and you experienced young folks can enlighten me that there IS a way to do this.

I have been out tech for way too long to be helpful and get down in this mud. I’m just trying to check the veracity of what he has been told. Without this capability, all this work, years of work, on building this database, was a waste)…

Thanks!.

The key here depends upon getting a better understanding of what you mean by “reference”.

To digress a little - Django works very well with variable urls and data references. A common pattern is that a url is defined with a placeholder in some position of that url, referencing the primary key of some model. You don’t define all the individual URLs - you define the pattern for the URL, and Django retrieves data according to that pattern.

So no, those “future references” do not create a problem. They are easily addressed in different ways - again, the precise answer depending upon more specific details concerning the actual intended operations.

Ken:
Thanks!h. I fear I was imprecise. ( Been a long time since I’ve had to be , lol). Edited original question to clarify.

User is entering text in a WSIWYG interface via Admin. Can he create a URL in the WSIWYG for TownD that will link to the page for TownA( or any other town that already exists in the DB). It has to be easy for this end user, or his staff, brilliant as he may be

Thanks! FWIW, it is a not-for-profit endeavor, and I am just a friend who saw his work in pieces on the floor.

What WSIWYG interface? Django doesn’t provide one, so if one is being used, it’s a third-party add-on.

No, and Yes. You don’t “create” URLs in the admin, but you can “use” URLs. This may be tough for you to wrap your head around - in which case my best recommendation would be for you to work your way through the Official Django Tutorial.

But to give you an idea, you might have a url pattern that looks like this:
path('display/<str:town_name>/', display_town_details),

You would then be able to reference “TownA” as http://example.com/display/TownA/, and as long as the town_name exists at the time the url is referenced, you won’t have any problems.

“Easy” is very subjective, and going to depend a lot upon the system being built around this data.

But the bottom line is that you haven’t described any situation that should give you cause for concern.

YES !!
Did not want to move forward with recommendations until I knew this for certain.

( and yes not “create”, but rather “use”. ack!)

THANK YOU!
( just gotta poke around!)