Connecting to existing database

I’m working (well, investigating at the moment) with a very old SQL server database primarily used for another system written using MS Access (connecting with ODBC). I’m finding that I am having to create views for each table that I use in my Django project named along the lines of dbo.AppName_ModelName.

The screen shot shows the STAFF table recreated in a sandpit database and the PollsterSystem_vwSTAFF view needed to service a vwSTAFF model class.

The Model class is then

class vwSTAFF(models.Model):
    STAFF_CODE = models.CharField(primary_key=True, max_length=50)
    EMPLOYEE_NUMBER = models.CharField(max_length=30)   #User name
    PASSWORD = models.CharField(max_length=10)

    class Meta:
        managed=False

This all works fine but it’s ugly as sin. Is there a way of persuading Django to not insist on the application prefix?

You can specify the table name using the db_table setting in the Meta class for a model.

Thanks very. For clarity, just in case someone else reads this, the code that works doesn’t include reference to the table owner (dbo in this case):

class STAFF(models.Model):
    STAFF_CODE = models.CharField(primary_key=True, max_length=50)        #Unique identifier
    EMPLOYEE_NUMBER = models.CharField(max_length=30)   #User name
    PASSWORD = models.CharField(max_length=10)

    class Meta:
        managed=False
        db_table='STAFF'