I create a new Django app (not project) called Bussinesses, then add following class to the models.py.
class Bussinesses(models.Model):
business_email = models.EmailField()
password = models.CharField(max_length=20)
contact_first_name = models.CharField(max_length=30)
contact_last_name = models.CharField(max_length=30)
If I use Bussinesses directly, the Django will access the “bussinesses_bussinesses” table in the database, which obviously does not exist.
Because the table “bussinesses” is also used by another APP, So can’t rename it.
I want to know how to use the Django model without using table prefix, and I don’t want to use the raw database API directly.
Just use the model meta options.
BTW businesses is misspelled. Since you’re specifying the name of the table you don’t have to give your model the same name as the table, so if the table name is misspelled and you can’t easily fix it, you can at least change the name of your class to the proper spelling of businesses. I would also get rid of the pluralization, and make it
class Business. Finally it’s not uncommon when using Django or Rails on an existing database to need to set a custom table name for every table.