Skip to content

Commit

Permalink
django-taggit
Browse files Browse the repository at this point in the history
  • Loading branch information
shing100 committed Aug 15, 2018
1 parent 4d6b3c1 commit b9c2e6c
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 1 deletion.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (장고 슈퍼유저 생성)


Expand Down Expand Up @@ -220,4 +221,9 @@ urlpatterns = [
> 정규표현식
- https://regex101.com/
- https://suwoni-codelab.com/django/2018/03/24/Django-Url-function/
- 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/
1 change: 1 addition & 0 deletions config/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
'allauth.account',
'allauth.socialaccount',
'rest_framework', # REST Framework
'taggit' # Tags for the photos
]
LOCAL_APPS = [
'limstagram.users.apps.UsersAppConfig',
Expand Down
20 changes: 20 additions & 0 deletions limstagram/images/migrations/0005_image_tags.py
Original file line number Diff line number Diff line change
@@ -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'),
),
]
2 changes: 2 additions & 0 deletions limstagram/images/models.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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):
Expand Down

0 comments on commit b9c2e6c

Please sign in to comment.