These are chat archives for django/django

10th
Feb 2018
:]
@elcolie
Feb 10 2018 02:58

@diegocastrum Not sure that this is what you want or not. I would manually make it myself rather than reuse from 3rd party. I have never used django-forms-builder. Right now I store the widgets in Django database as an instance let says I have class with the following

    widget = models.CharField(max_length=10, choices=...)
    value = models.CharField(...)
    css = models.CharField(...)

I would hack render() method and let it read my instance and iterate through the queyset of it.

Diego Castro
@diegocastrum
Feb 10 2018 06:44

Oh in that way! That sounds good @elcolie, seems to be a nice way to do that. Now I understand what you mean. We'll think about it!

Thank you so much!!

Hasan-Ahmad
@Hasan-Ahmad
Feb 10 2018 18:50

hey guys. I am making a todo application and want to know how to delete all the fields in a model through a button in the template. Here is what i tried doing but nothing would happen:

def check_todos(request):
    todos = Todo.objects.all()
    if request.method == 'POST':
        if todos:
            for todo in todos:
                todo.delete()
    return render(request, 'home.html', {'todos': todos})

Please @ me if you have an answer.

Roel
@roelzkie15
Feb 10 2018 22:49

@Hasan-Ahmad

Every queryset has a delete() method now

def check_todos(request):
    todos = Todo.objects.all()
    if request.method == 'POST':
        if todos:
            todos.delete()
    return render(request, 'home.html', {'todos': todos})