Existing DB - query join best practice

New to Django.

I have a database that I am connecting to using the multiple database configurations. The tables from one database are obtained using the:

$ ./manage.py inspectdb --database=db_name > your_app/models.py

The models are:

class Orders(models.Model):
    OrderID = models.IntegerField()
    OrderDate = models.DateTimeField()
    CustomerID = models.IntegerField()

class Customers(models.Model):
    CustomerName= models.CharField(maxlength=200)
    CustomerID = models.IntegerField()

There are no keys on the tables and it is owned by a third party so cannot change this.

Lets say the tables are Orders and Customers and data can be returned by SQL:

SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;

What is the best approach in Django to query tables where I need to specify a join?
The Django site advises Explore the ORM before using raw SQL! but I cannot understand if this is covered or I am missing something as this seems a simple task.

It appears from the schema that OrderID in the Orders table might be your primary key - even if it’s not defined as such in the database schema. Is OrderID unique in Orders?

Also, CustomerID in Customers appears that it could be a primary key? Is it unique within that table?

If my guesses are correct, I would make my models look something like this:

class Orders(models.Model):
    OrderID = models.IntegerField(primary_key=True)
    OrderDate = models.DateTimeField()
    CustomerID = models.ForeignKey('Customers')

class Customers(models.Model):
    CustomerName= models.CharField(maxlength=200)
    CustomerID = models.IntegerField(primary_key=True)

(Along with absolutely setting managed = False in the Meta class for each of those models.)

Even if my guesses aren’t 100% correct, this is still probably about the best you’re going to be able to do with this. But please understand, without some kind of unique index, there are some things within Django that will fail under the wrong circumstances.

Ah! Thanks KenWhitesell, you have pointed out the key part here:

managed = False in the Meta class.

I had no idea about that and it is key.

So I can set the models and identify the ForeignKey then use the ORM without impacting or needing to change the DB.

Much appreciated!