示例#1
0
def mod_not(request):
    noti = Noticia2.objects.get(id=3)
    dictionary = model_to_dict(noti, fields=[], exclude=[])
    #form = forms.InformeForm(dictionary)
    if request.method == 'POST':
        form = NoticiaForm(data=request.POST)
        if form.is_valid():
            noti.titulo = form.cleaned_data['titulo'] 
            noti.texto = strip_tags(form.cleaned_data['texto'])
            noti.fecha = form.cleaned_data['fecha']
            noti.save()  
            return HttpResponseRedirect(reverse('noti_index'))
            
    else:
        form = forms.NoticiaForm(dictionary)
    
    context = {
        'noticia_form': form,
    }
    return render_to_response(
        'eventos/modificar_noticia.html',
         context,
         context_instance = RequestContext(request),
    )
示例#2
0
def nueva_noticia(request):
    if request.method == 'POST':
        form = NoticiaForm(data=request.POST)
        if form.is_valid():
            '''
            noti = form.save(commit=False)
            noti.titulo = Alumno.objects.get(pk=st_id)
            informe.maestra = request.user.get_profile().content_object
            informe.texto = strip_tags(informe.texto)
            form.save()  
            '''
            return HttpResponseRedirect(reverse('noti_index'))
            
    else:
        form = NoticiaForm()
    
    context = {
        'noticia_form': form,
    }
    return render_to_response(
        'eventos/nueva_noticia.html',
         context,
         context_instance = RequestContext(request),
    )