Tagging architecture on MyBike.JP

1,630 views

Published on

MyBike.JPでのタグ実装の苦労話。

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,630
On SlideShare
0
From Embeds
0
Number of Embeds
539
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Tagging architecture on MyBike.JP

    1. 1. tagging best practice MyBike.JP dev team
    2. 2. e.g.
    3. 3. MyBike.JP
    4. 4. MyBike.JP
    5. 5. MyBike.JP
    6. 6. class Tag(DateTimeModel): tag = models.SlugField(u , unique=True, db_index=True)class TaggedItem(DateTimeModel): tag = models.ForeignKey(Tag) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey(content_type, object_id)
    7. 7. Django ContentTypes Tagpolymonic TaggedItem Bike Component
    8. 8. bucho
    9. 9. buchoBucho
    10. 10. buchoBuchoBUCHO
    11. 11. buchoBuchoBUCHO
    12. 12. http://mybike.jp/bikes/tag/bucho
    13. 13. http://mybike.jp/bikes/tag/buchohttp://mybike.jp/bikes/tag/Bucho
    14. 14. http://mybike.jp/bikes/tag/buchohttp://mybike.jp/bikes/tag/Buchohttp://mybike.jp/bikes/tag/BUCHO
    15. 15. http://mybike.jp/bikes/tag/buchohttp://mybike.jp/bikes/tag/Buchohttp://mybike.jp/bikes/tag/BUCHOhttp://mybike.jp/bikes/tag/
    16. 16. http://mybike.jp/bikes/tag/buchohttp://mybike.jp/bikes/tag/Buchohttp://mybike.jp/bikes/tag/BUCHOhttp://mybike.jp/bikes/tag/→
    17. 17. class Tag(DateTimeModel): tag = models.SlugField(u , unique=True, db_index=True)class TaggedItem(DateTimeModel): tag = models.ForeignKey(Tag) tag_label = models.CharField(max_length=100) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey(content_type, object_id)
    18. 18. class Tag(DateTimeModel): tag = models.SlugField(u , unique=True, db_index=True)class TaggedItem(DateTimeModel): tag = models.ForeignKey(Tag) tag_label = models.CharField(max_length=100) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object = generic.GenericForeignKey(content_type, object_id)
    19. 19. Tag.tag TaggedItem.tag_label
    20. 20. Tag.tag TaggedItem.tag_labelTag.tag
    21. 21. Tag.tag TaggedItem.tag_labelTag.tag
    22. 22. TaggedItem bucho Bucho BUCHO
    23. 23. TaggedItem bucho Bucho BUCHO
    24. 24. TaggedItem bucho Tag Bucho bucho BUCHO
    25. 25. Good
    26. 26. Good
    27. 27. Good
    28. 28. Good→
    29. 29. Bad
    30. 30. Bad
    31. 31. Bad
    32. 32. Bad
    33. 33. Bad→
    34. 34. http://mybike.jp/bikes/tag/
    35. 35. http://mybike.jp/bikes/tag/ …
    36. 36. RIESE&MULLER ( & )http://mybike.jp/bikes/manufacturer/RIESE&MULLER
    37. 37. http://mybike.jp/bikes/manufacturer/RIESE&MULLER
    38. 38. http://mybike.jp/bikes/manufacturer/RIESE&MULLER
    39. 39. http://mybike.jp/bikes/manufacturer/RIESE&MULLER RISE&MULLER
    40. 40. http://mybike.jp/bikes/manufacturer/RIESE&MULLER RISE&MULLER
    41. 41. http://mybike.jp/bikes/manufacturer/RIESE&MULLER RISE&MULLER …
    42. 42. slug regex → [-w]+
    43. 43. slug regex → [-w]+reverse()
    44. 44. %26→URL
    45. 45. %26→URLurls.py &→
    46. 46. urls.py(?P<manufacturer_name>[-w]+)
    47. 47. urls.py(?P<manufacturer_name>[-w]+)(?P<manufacturer_name>[- &w]+)
    48. 48. templates iriencode→<a href=”{{ hoge|iriencode }}”>hoge</a>urls.py URL decode
    49. 49. http://mybike.jp

    ×