Working on tag import
parent
3b0270c402
commit
d4dc37e430
|
@ -6,6 +6,7 @@ from django.contrib.auth.models import User
|
||||||
|
|
||||||
from snipts.models import Comment, Snipt
|
from snipts.models import Comment, Snipt
|
||||||
from taggit.models import Tag, TaggedItem
|
from taggit.models import Tag, TaggedItem
|
||||||
|
from taggit.utils import parse_tags
|
||||||
|
|
||||||
conn = MySQLdb.connect(host='localhost', user='root', passwd='root', db='sniptold')
|
conn = MySQLdb.connect(host='localhost', user='root', passwd='root', db='sniptold')
|
||||||
cursor = conn.cursor()
|
cursor = conn.cursor()
|
||||||
|
@ -98,11 +99,8 @@ def snipts():
|
||||||
public=public,
|
public=public,
|
||||||
created=created,
|
created=created,
|
||||||
)
|
)
|
||||||
|
for t in parse_tags(tags):
|
||||||
tags = tags.split(',')
|
snipt.tags.add(t)
|
||||||
for t in tags:
|
|
||||||
snipt.tags.add(t.strip())
|
|
||||||
|
|
||||||
snipt.save()
|
snipt.save()
|
||||||
|
|
||||||
print 'Done with snipts'
|
print 'Done with snipts'
|
||||||
|
|
|
@ -9,7 +9,6 @@ class CommentInline(admin.TabularInline):
|
||||||
allow_add = False
|
allow_add = False
|
||||||
|
|
||||||
class SniptAdmin(admin.ModelAdmin):
|
class SniptAdmin(admin.ModelAdmin):
|
||||||
readonly_fields = ('user',)
|
|
||||||
list_display = ('title', 'slug', 'user', 'lexer', 'public', 'created', 'modified',)
|
list_display = ('title', 'slug', 'user', 'lexer', 'public', 'created', 'modified',)
|
||||||
search_fields = ('title', 'user__username', 'tags', 'lexer', 'id',)
|
search_fields = ('title', 'user__username', 'tags', 'lexer', 'id',)
|
||||||
ordering = ('created',)
|
ordering = ('created',)
|
||||||
|
|
|
@ -0,0 +1,96 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
import datetime
|
||||||
|
from south.db import db
|
||||||
|
from south.v2 import SchemaMigration
|
||||||
|
from django.db import models
|
||||||
|
|
||||||
|
class Migration(SchemaMigration):
|
||||||
|
|
||||||
|
def forwards(self, orm):
|
||||||
|
|
||||||
|
# Deleting field 'Snipt.old_tags'
|
||||||
|
db.delete_column('snipts_snipt', 'old_tags')
|
||||||
|
|
||||||
|
|
||||||
|
def backwards(self, orm):
|
||||||
|
|
||||||
|
# Adding field 'Snipt.old_tags'
|
||||||
|
db.add_column('snipts_snipt', 'old_tags', self.gf('django.db.models.fields.CharField')(default='', max_length=255), keep_default=False)
|
||||||
|
|
||||||
|
|
||||||
|
models = {
|
||||||
|
'auth.group': {
|
||||||
|
'Meta': {'object_name': 'Group'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '80'}),
|
||||||
|
'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
|
||||||
|
},
|
||||||
|
'auth.permission': {
|
||||||
|
'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
|
||||||
|
'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
|
||||||
|
},
|
||||||
|
'auth.user': {
|
||||||
|
'Meta': {'object_name': 'User'},
|
||||||
|
'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
|
||||||
|
'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
|
||||||
|
'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
|
||||||
|
'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
|
||||||
|
'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
|
||||||
|
'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
|
||||||
|
'username': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '30'})
|
||||||
|
},
|
||||||
|
'contenttypes.contenttype': {
|
||||||
|
'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
|
||||||
|
'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
|
||||||
|
},
|
||||||
|
'snipts.comment': {
|
||||||
|
'Meta': {'object_name': 'Comment'},
|
||||||
|
'comment': ('django.db.models.fields.TextField', [], {}),
|
||||||
|
'created': ('django.db.models.fields.DateTimeField', [], {}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||||
|
'snipt': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['snipts.Snipt']"}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||||
|
},
|
||||||
|
'snipts.snipt': {
|
||||||
|
'Meta': {'object_name': 'Snipt'},
|
||||||
|
'code': ('django.db.models.fields.TextField', [], {}),
|
||||||
|
'created': ('django.db.models.fields.DateTimeField', [], {}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'key': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'lexer': ('django.db.models.fields.CharField', [], {'max_length': '50'}),
|
||||||
|
'modified': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
|
||||||
|
'public': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
|
||||||
|
'slug': ('django.db.models.fields.SlugField', [], {'max_length': '50', 'db_index': 'True'}),
|
||||||
|
'stylized': ('django.db.models.fields.TextField', [], {}),
|
||||||
|
'title': ('django.db.models.fields.CharField', [], {'max_length': '255'}),
|
||||||
|
'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']"})
|
||||||
|
},
|
||||||
|
'taggit.tag': {
|
||||||
|
'Meta': {'object_name': 'Tag'},
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'name': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
|
||||||
|
'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '100', 'db_index': 'True'})
|
||||||
|
},
|
||||||
|
'taggit.taggeditem': {
|
||||||
|
'Meta': {'object_name': 'TaggedItem'},
|
||||||
|
'content_type': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taggit_taggeditem_tagged_items'", 'to': "orm['contenttypes.ContentType']"}),
|
||||||
|
'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
|
||||||
|
'object_id': ('django.db.models.fields.IntegerField', [], {'db_index': 'True'}),
|
||||||
|
'tag': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'taggit_taggeditem_items'", 'to': "orm['taggit.Tag']"})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
complete_apps = ['snipts']
|
|
@ -11,7 +11,6 @@ class Snipt(models.Model):
|
||||||
title = models.CharField(max_length=255)
|
title = models.CharField(max_length=255)
|
||||||
slug = models.SlugField()
|
slug = models.SlugField()
|
||||||
tags = TaggableManager()
|
tags = TaggableManager()
|
||||||
old_tags = models.CharField(max_length=255)
|
|
||||||
|
|
||||||
lexer = models.CharField(max_length=50)
|
lexer = models.CharField(max_length=50)
|
||||||
code = models.TextField()
|
code = models.TextField()
|
||||||
|
|
Loading…
Reference in New Issue