есть проблема: делал форму по рецепту, не выводит ничегоforms.py
from django import forms
from schoolproj.people.models import Man
class ManEdit(forms.ModelForm):
class Meta:
model = Man
fields = ('birthdate', 'home_number', 'mob_number', 'photo', 'skype', 'vkend')
def save(self):
obj = super(ManEdit, self).save(commit=False)
obj.save
return obj
edit_profile.html
{% extends "base.html" %}
{% load cms_tags sekizai_tags i18n %}
{% block base_content %}
{% if man.authenticated %}
{% csrf_token %}
{{ form }}
{% endif %}
{% endblock %}
views.py
from django.http import HttpResponseRedirect
from django.views.generic.simple import direct_to_template
from schoolproj.people.forms import ManEdit
from django.shortcuts import get_object_or_404
from schoolproj.people.models import Man
@login_required
def man_edit(request):
item = get_object_or_404(request.user)
form = ManEdit(request.POST or None, instance=item)
context = {'item':item, 'form':form}
if request.method == 'POST' and form.is_valid():
form.save(request.user)
return HttpResponseRedirect('/man/%s' % request.man.id)
return direct_to_template(request, 'edit_profile.html', context)
Updated 2 Sept. 2012, 22:34 by igel-feuermann.