Django

Code

Ticket #5930: 5930.patch

File 5930.patch, 1.4 kB (added by nickl, 1 year ago)
  • a/docs/custom_model_fields.txt

    old new  
    5656 
    5757We assign to and retrieve from the ``hand`` attribute in our model just like 
    5858any other Python class. The trick is to tell Django how to handle saving and 
    59 loading such an object 
     59loading such an object. 
    6060 
    6161In order to use the ``Hand`` class in our models, we **do not** have to change 
    6262this class at all. This is ideal, because it means you can easily write 
     
    9898characters by concatenating all the cards together in a pre-determined order. 
    9999Say, all the *north* cards first, then the *east*, *south* and *west* cards, in 
    100100that order. So ``Hand`` objects can be saved to text or character columns in 
    101 the database 
     101the database. 
    102102 
    103103What does a field class do? 
    104104--------------------------- 
     
    549549Some general advice 
    550550-------------------- 
    551551 
    552 Writing a custom field can be a tricky process sometime, particularly if you 
     552Writing a custom field can be a tricky process sometimes, particularly if you 
    553553are doing complex conversions between your Python types and your database and 
    554554serialization formats. A couple of tips to make things go more smoothly: 
    555555