diff --git a/README.md b/README.md index 00d5626..932db0d 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ Clonning instagram with python django and react and react native python manage.py migrate python manage.py makemigrations (생성한 모델, 어플레키에션 필드들을 변경시) + python manage.py makemigrations && python manage.py migrate python manage.py createsuperuser (장고 슈퍼유저 생성) @@ -220,4 +221,9 @@ urlpatterns = [ > 정규표현식 - https://regex101.com/ -- https://suwoni-codelab.com/django/2018/03/24/Django-Url-function/ \ No newline at end of file +- https://suwoni-codelab.com/django/2018/03/24/Django-Url-function/ + +> django-taggit + +- https://github.com/alex/django-taggit +- https://django-taggit.readthedocs.io/en/latest/ diff --git a/config/settings/base.py b/config/settings/base.py index 490edc0..0150b2a 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -69,6 +69,7 @@ 'allauth.account', 'allauth.socialaccount', 'rest_framework', # REST Framework + 'taggit' # Tags for the photos ] LOCAL_APPS = [ 'limstagram.users.apps.UsersAppConfig', diff --git a/limstagram/images/migrations/0005_image_tags.py b/limstagram/images/migrations/0005_image_tags.py new file mode 100644 index 0000000..902c7a5 --- /dev/null +++ b/limstagram/images/migrations/0005_image_tags.py @@ -0,0 +1,20 @@ +# Generated by Django 2.0.7 on 2018-08-15 12:32 + +from django.db import migrations +import taggit.managers + + +class Migration(migrations.Migration): + + dependencies = [ + ('taggit', '0002_auto_20150616_2121'), + ('images', '0004_auto_20180801_2310'), + ] + + operations = [ + migrations.AddField( + model_name='image', + name='tags', + field=taggit.managers.TaggableManager(help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), + ), + ] diff --git a/limstagram/images/models.py b/limstagram/images/models.py index a9c0f7c..8cc11ac 100644 --- a/limstagram/images/models.py +++ b/limstagram/images/models.py @@ -1,5 +1,6 @@ from django.db import models from limstagram.users import models as user_models +from taggit.managers import TaggableManager # Create your models here. class TimeStampedModel(models.Model): @@ -17,6 +18,7 @@ class Image(TimeStampedModel): location = models.CharField(max_length=140) caption = models.TextField() creator = models.ForeignKey(user_models.User, null=True, on_delete=models.CASCADE, related_name='images') + tags = TaggableManager() @property def like_count(self):