diff --git a/sample_taggit/admin.py b/sample_taggit/admin.py new file mode 100644 index 00000000..47f03fdd --- /dev/null +++ b/sample_taggit/admin.py @@ -0,0 +1,4 @@ +from django.contrib import admin +from .models import Post + +admin.site.register(Post) diff --git a/sample_taggit/migrations/0001_initial.py b/sample_taggit/migrations/0001_initial.py new file mode 100644 index 00000000..676f5102 --- /dev/null +++ b/sample_taggit/migrations/0001_initial.py @@ -0,0 +1,43 @@ +# Generated by Django 5.0.6 on 2024-06-24 12:35 + +import taggit.managers +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ( + "taggit", + "0006_rename_taggeditem_content_type_object_id_taggit_tagg_content_8fc721_idx", + ), + ] + + operations = [ + migrations.CreateModel( + name="Post", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("title", models.CharField(max_length=200)), + ( + "tags", + taggit.managers.TaggableManager( + help_text="A comma-separated list of tags.", + through="taggit.TaggedItem", + to="taggit.Tag", + verbose_name="Tags", + ), + ), + ], + ), + ] diff --git a/sample_taggit/migrations/__init__.py b/sample_taggit/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sample_taggit/models.py b/sample_taggit/models.py new file mode 100644 index 00000000..8263cf97 --- /dev/null +++ b/sample_taggit/models.py @@ -0,0 +1,9 @@ +#!/usr/bin/env python3 +from django.db import models + +from taggit.managers import TaggableManager + + +class Post(models.Model): + title = models.CharField(max_length=200) + tags = TaggableManager(blank=True) diff --git a/sample_taggit/settings.py b/sample_taggit/settings.py index bf42c9ed..0cc0de84 100644 --- a/sample_taggit/settings.py +++ b/sample_taggit/settings.py @@ -37,6 +37,8 @@ "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", + "taggit", + "sample_taggit", ] MIDDLEWARE = [ diff --git a/sample_taggit/temlates/index.html b/sample_taggit/temlates/index.html new file mode 100644 index 00000000..56777fc5 --- /dev/null +++ b/sample_taggit/temlates/index.html @@ -0,0 +1,6 @@ + +