mysql - Django: create Index: non-unique, multiple column -


Looking at the following model, I want to index fields (sequence, stock)

  class quote model (models.model): quotedate = models.DateField () high = models.FloatField () # (9.2) default faucet, low = model. Floatfield () # (9,2) default faucet, close = model. Flatfield () # (9.2) default faucet, closes = model. Flatfield () # (9.2) default null, volume = model.tectorfield () # (9, 2) default faucet, stock = model.tegerfield (db_indicate = tru) # (9.2) default faucet, open = model. Flatfield () # (9.2) default faucet, Sequence = Model.IntergerField () # (9, 2) Default faucet,  

This index should be unique - Something like this in mysql :

  Model_quoteManage index ndx_1 on the modell (sequence, share);  

I know that the same Django solution is creating a "SQL" file that will be executed by the deployment on table construction. Therefore, I have created a "Stockmodel SQL" that has the following query (as given above)

  Model_totmode index ndx_1 on modell (sequence, stock);  

Is there a "cleaner" way to do this?

As Django 1.5, you can use it:

 < Code> Square QuoteModel (models.Model): # ... field ... class meta: index_together = [("sequence", "stock"),]  

(note: From the original answer 2009, it was not possible to index many areas, it has since been changed)


Comments

Popular posts from this blog

MySql variables and php -

url rewriting - How to implement the returnurl like SO in PHP? -

Which Python client library should I use for CouchdB? -