Ejemplo n.º 1
0
def update(request, id):
    ws = get_object_or_404(WebStatus, pk=id, user=request.user)
    form = WebStatusForm(instance=ws)
    if request.method == 'POST':
        form = WebStatusForm(request.POST, instance=ws)
        if form.is_valid():
            ws = form.save()
        return render(request, 'webstatus/create.html', {'form': form, 'post': True})
    return render(request, 'webstatus/create.html', {'form': form})
Ejemplo n.º 2
0
def create(request):
    form = WebStatusForm()
    datestr = "%s-%s-%s" % (datetime.today().year, datetime.today().month, datetime.today().day)
    if request.method == "POST":
        form = WebStatusForm(request.POST)
        if form.is_valid():
            ws = form.save(commit=False)
            ws.user = request.user
            ws.save()
            return HttpResponseRedirect(reverse('webstatus_list'))
    return render(request, 'webstatus/create.html', {'form': form, 'datestr': datestr})