이것은 긴 게시물이므로 나와 함께 곰. 이전 모델에서 작성한 많은 코드를 다시 작성해야한다는 것을 깨달았습니다.클래스 기반 또는 함수 기반 뷰를 사용해야합니까?
내 모델은 다음과 같이 : 최후의 수단으로 만들고 subqequent 정의 모델의 메소드를 호출
class Word(models.Model):
'''Word table for word, and frequency data'''
language = models.ForeignKey(Language)
name = models.CharField(max_length=50)
frequency = models.IntegerField(default=0)
rank = models.IntegerField(default=0)
def __unicode__(self):
value = u'%s' % (self.name)
return value
def wn_lookup(self):
'''Calls the wordnet CLI for self'''
...breaks up the output and returns the definitions as a list of tuples
def wiktionary_lookup(self, wiktionary_prefix, driver):
...looks up the definition of the word on wiktionary
returns data as a list
def define(self, driver, choice, ask_input):
...Prints out a lot of options and asks the user to choose
what they want as a definition
It then creates objects and calls other methods on a
subsequent definitions model
하는 것으로.
데이터 입력을 반자동으로 처리하는 데 많은 사용자 입력이 필요한 메소드가있는 몇 가지 모델이 있습니다. 나는 이걸 어리석은 짓을했다고 믿는다. 나는 실제로 그것들을보기에 추가해야만한다. 그러나 나는 그것을 어떻게하는지에 대해 약간 혼란 스럽다.
- 클래스 기반 또는 기능 기반보기를 사용해야합니까?
- 나는이 모든보기에 대해 실제로 양식과 템플릿을 작성해야한다고 생각하십니까?
- 모델에있는 모든 것을 그대로두고 뷰에 넣지 않아도 될 가능성이 있습니까?