| Django-generic Áý°è ÀÏ¹Ý °ü·Ã µ¥ÀÌÅÍ¿¡ ´ëÇÑ Annotate () ¹× Áý°è () |
Áö±Ý ´Ù¿î·Îµå |
Django-generic Áý°è ¼øÀ§ ¹× ¿ä¾à
- ƯÇã:
- MIT/X Consortium Lic...
- °Ô½ÃÀÚ À̸§:
- Charles Leifer
- °Ô½ÃÀÚ À¥»çÀÌÆ®:
- http://www.charlesleifer.com/blog/
Django-generic Áý°è ű×
Django-generic Áý°è ¼³¸í
ÀϹÝÀûÀ¸·Î °ü·Ã µ¥ÀÌÅ͸¦À§ÇÑ ÁÖ¼® () ¹× Áý°è () Django-generic-aggregationÀº ÀϹÝÀûÀ¸·Î °ü·Ã µ¥ÀÌÅÍ¿¡ ´ëÇÑ Annotate () ¹× Áý°è ()¸¦ Á¦°øÇÕ´Ï´Ù. examplesyou´Â ºí·Î±× Ç׸ñ¿¡¼ °¡Àå ÁÖ¼®À» °¡Àå ¸¹ÀÌ ÁÖ¼®À» ¿øÇÕ´Ï´Ù. >>>¿¡¼ django.contrib.comments.models import comment >>> django.db.models¿¡¼ °¡Á® ¿À±â >>> Blog.models¿¡¼ BlogEntry °¡Á® ¿À±â >>> generic_aggregation °¡Á® ¿À±â generic_annotate >>> agnotated = generic_annotate (blogentry.objects.all (), comment.content_object, 'id', count) >>> ÁÖ¼®ÀÌ ´Þ¸° Ç׸ñ ... Print Entry.title, Entry.Scorethe °¡Àå ÀαâÀÖ´Â 5 ¹ø° µÎ ¹ø° º£½ºÆ® 4NOBODY ´ñ±Û 0you´Â DJango.db.models °¡Á® ¿À±â ÇÕ°è¿¡¼ºÎÅÍ ¾î¶² Ç׸ñÀ» °¡Á® ¿À´ÂÁö ¾Ë¾Æ ³»°í ½Í½À´Ï´Ù. = food.objects.create (name = 'Apple') # foodrating.Objects.Create (content_object = apple, µî±Þ = 3) µî±ÞÀ» ¸¸µì´Ï´Ù. rating.objects.create (content_object = apple, µî±Þ = 5) rating.objects .create (content_object = apple, µî±Þ = 7) >>> Áý°è = generic_aggregate (food.objects.all (), rating.content_object, 'µî±Þ ", ÇÕ) >>> P rint Aggregate15 >>> Áý°è = generic_aggregate (food.objects.all (), rate.content_Object, 'µî±Þ ", AVG) >>> Print Aggregate5 Å×½ºÆ® - °Å±â¿¡ ´õ ¸¹Àº ¿¹°¡ ÀÖ½À´Ï´Ù. Postgres ¹× SQLite ¿ä±¸ »çÇ×À¸·Î Å×½ºÆ®µÇ¾ú½À´Ï´Ù. ¡¤ ÆÄÀ̽㠡¤ Àå°í
Django-generic Áý°è °ü·Ã ¼ÒÇÁÆ®¿þ¾î