0
내 장고 앱에 적합한 모델을 만들려고합니다. 나는 사용자가 그 사용자에게 묶여있는 하나 이상의 (또는 그 이상의) 재생 목록에 URL을 저장할 수있는 무언가를 만들려고 노력하고있다. 이것을 구현하기 전에 이것이 내 models.py를 구조화하는 가장 좋은 방법인지 확인하고자한다.models.py를 구조화하는 올바른 방법은 무엇입니까?
class UserProfile(models.Model):
user = models.ForeignKey(User, primary_key=True) #what is the difference between ForeignKey and OneToOne? Which one should I use?
Playlist = models.CharField('Playlist', max_length = 2000) #1 user should be able to have multiple playlists and the default playlist should be "Favorites"
def __unicode__(self):
return self.User
class Videos(models.Model):
Video_url = models.URLField('Link to video', max_length = 200, null=True, blank=True)
Playlist = models.ManyToManyField(Playlist) #this should connect to the playlists a user has. A user should be able to save any video to any plalist, so perhaps this should be ManyToMany?
def __unicode__(self):
return self.Video_url
차이 OneToOne http://stackoverflow.com/questions/5870537/whats-the-difference-between-django-onetoonefield-and-foreignkey – iMom0
@ iMom0 무엇 다른 질문들에 대해서? 이것이 내가 가능하게하고 싶은 바른 길로 설정되어 있다고 생각합니까? – sharataka