django本地语言词典应用程序中的同义词和反义词
很抱歉这个问题,但我在为本地语言制作字典应用程序时遇到了问题,所以我不需要英语字典,我的问题是同义词,我不知道如何在我的模型中实现它django本地语言词典应用程序中的同义词和反义词,django,dictionary,Django,Dictionary,很抱歉这个问题,但我在为本地语言制作字典应用程序时遇到了问题,所以我不需要英语字典,我的问题是同义词,我不知道如何在我的模型中实现它 from django.db import models from django.utils import timezone from django.contrib.auth.models import User from django.core.urlresolvers import reverse # Create your models here. cl
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
# Create your models here.
class Voca(models.Model):
name = models.CharField(max_length=200, unique=True)
def __str__(self):
return self.name
def get_absolute_url(self):
return reverse("voca:detail", kwargs={"id": self.id, "name": self.name})
class Defination(models.Model):
voca = models.ForeignKey(Voca, related_name='definations')
defination = models.CharField(max_length=500)
example = models.CharField(max_length=500)
etymology = models.CharField(max_length=500)
author = models.ForeignKey(User, default=1)
created = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
class Meta:
ordering = ('created',)
def __str__(self):
return 'Defination given by {} on {}'.format(self.author, self.voca)
class Synonym(models.Model):
words = models.ManyToManyField(Voca, blank=True, related_name='synonyms')
我想为用户添加单词,同义词,反义词的定义到数据库本身,因为它是一种俚语,所以如果我能得到任何帮助,特别是对反义词和同义词,我会非常感激。。。谢谢我的建议是删除
同义词
模型,并在您的定义
模型中添加字段
class Defination(models.Model):
voca = models.ForeignKey(Voca, related_name='definations')
...
synonyms = models.ManyToManyField(Voca, related_name='synonyms')
antonyms = models.ManyToManyField(Voca, related_name='antonyms')
这个答案太好了,我再次来到这里。非常感谢,你真的帮了我这个忙。