from django.db import models
class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField()
class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
from django import forms
from mysite.polls.models import Poll, Choice
class PollForm(forms.ModelForm):
class Meta:
model = Poll
class ChoiceForm(forms.ModelForm):
class Meta:
model = Choice
exclude = ('poll',)
<form action="{{url}}" method="post">
{{pollform}}
{{choiceform}}
{{pollform}}
</form>
form = MyFormClass(prefix='some_prefix')
form = MyFormClass(request.POST, prefix='some_prefix')
Если этот код добавляю в settings.py: 'DIRS': [os.path.join(BASE_DIR, 'templates/'), "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/django/contrib/admin/templates/"] - все робит норм