You are on page 1of 1
eae Cee Peete Ce re censure that individuals receiv Pencen es en) ores neat) vl. information bout an arial whi ne "00g: made! contains information spect to dogs sich a whether hey have been sned. The “oneToOneiet4 inthe “Dog ve lions ne “Aninat* and Deg model so that each ‘Anda instance with exact one v wn migrations 0 for hese mode, iango wil cet cig key in the “009° model that refer ania adel Tis lationship ens nation “Ania instances deleted its corresponding "Oo instance wl tod 6g instance i automaticaly deleted when the “Anat i : ith er eect) eres Coane) ne ‘Animal and ‘Bop mode ach “Animal in cign key in the *Bog* model : m — nati an “Andnal* instance is deleted, allo its associated “Dog” if deleted. The “on.deLete argument in the “Faretgnkey” Sets the “CASCADE* option so th ne “Bag” instar sticaly deleted when the *Antmat are associa ango ‘Andnat” model with 7 fields including ‘name’ and “age Sete rane = node! ae) rent erect) breed = model ere an) re re) en en) ene 0 ecation = models oer) ample, the “aninat* model has 7 fells: ‘ane’, epectes’, “breed”, “age ‘gender’, ‘weight’, and ‘Location’. The “nane® and ‘age field are bath required for th model. The ‘name fields a “chanLe14* with a maximum length o ‘age’ fila ica positive integer fee The other fields such a: “specie, “breed weight’, and “Leeation’ are also defined as ‘ChanFuele® and “FLoatiete’, re ith variout masimnum lengthe and constraints a= nese When you ran migrations to cre ble fo this mode, Django wil ts renee) eee ore at) er eens en) een 0 ‘ecation = models onan) eens are) pe ne \nax_Length=50) date of birth = model re) Rita Sent i fs eieaaeee reste eaten foe rete ater Bio or does ange deft or xa nyou use the "CharFeta® type, Django wil autor tea chara column inthe data fault maxim length of '208° chara vcan s different maximum length forthe fel usr rgumen nilaly, when you use the *PosdtsverntegerFseld” type. Dian a post Intager column in the database By default the fed wil al rom ‘8 2147483647", You can specify a different range of values sing the *min.vatue and BooteantSe16" type crea lean column inthe database that stores “Taw ¢ False default, the field allows *NULL* value nse the default value of 4 using the “aefautt argument DateFsetd’ type crates a date column inthe database that stores date values. B defout lows WIL? values. You can specly the eariest a ‘ 4 will accept using the “ain. vatue® and Ywax_vatue’ argu FloatF ete type er ng-point nu mn inthe databa aul ne field allows "MLL valve n specify the precision of the field using th ju samples ofthe default be of Das pes. When ,ou use thes fields in you ,ou can customize the 19 orgumen hem, such a5 max.tength, “default, “min_value’,‘maxvatue’, etc. Th ° ne-tune the behavior of your models to match your specific needs light fd inthe Animal medal dol with the "wetght* field set to have a defauit valve hs example the “eight fed has a default value of 0,0" specie wing the “deft argument. This means that you create anew ‘ania isan yng a “weight” fd, Django wl aomstially use the defaut value of 9.6" fc thas can spac ay value you want a th dato for tho “weight fl, depending on you needs. For example, you could speci “erautts0.0° if you want the dea ° Witte ide the save method of the Animal mode [Ey tees an example of how you can method ofthe “anunat* mode Sent res arr prenernel covery cores rover peer 0 preneene rey ne ees Serre reves nt rare ners Seater np, the “eave” method af the : n oventidden, The custom ‘from django ci> inport aodels eres mer) ene ee eect) seerneennter eee) + “date_adnintstered’: a date field tha! ne was administered anima: 2 foreign key that inks the nto an “Antaat® instance + ‘adninstration_route’: a character fed of administration (9.0 mation ab [Eve tho vaccination model to wt hows the next vaccination due day assuming a © capycose Vaccination. objeets.att(" method. F reriods fr diferent vaccines: ca ens) eee cme emt.) eeerenan Seaerentnar ner nrnretnt ire rer Stet Nemercen his updated v he fan expiration pertea fied fom ea “Vaccination” instance to calcula ation date for that vaccin ‘expiration_period’ field should be a postive integer that represents the number of da n then calculates the expiration date for each vaccine by adding the th the new ex Note thatthe updated function assumes thatthe “expiration_period” field is present inthe ‘Vacetnation* model i need to a node and ensure tat its Bh tees an sample ofa Django “vaccine mod to mak theists eee poeenernpenre ett ry peeree reser \aute_now_adé-True) ‘expiration_period”, and ‘ereated.at*. The “ field is a “DateTinerieta tha autor and tie when a new instance ofthe ‘Vaccine’ mod seated, defines an “ordering attribute that specific 7 model shoul fed. The *ordering* atvibute is set to °C With this setup, when you query fr “Vacesne” instances using the ‘Vacetne. objects. a1lO) " instances wll be returned inthe order specified by the Terdering* attribute with

You might also like