CS50W - Lecture 3 - Django
Why Stack Overflow recommends it
Stack Overflow users link it when they are following the CS50W Django tutorial and need to reference the exact lecture step, such as the tasks app, forms or session handling.
Recommended by 1 people across 1 different months, 2020 to 2021.
What it is
Lecture 3 of Harvard's CS50W web programming course, covering Django from first principles. It walks through web apps and HTTP, routes, templates, a tasks app, forms and sessions, with live coding by the CS50 instructor.
What people said
Recommends Jake Wainberg · 2020-07 · Stack Overflow · on “How do I use 'Django Forms' to process user input?”
Admittedly, I am also new to Django, but instead of making forms yourself with input fields, Django has its own way of making forms that I would recommend. In order to make a form using Django, you have to create a new class, such as: class edit_name(forms.Form): new_name = forms.CharField(label="Enter Your New Name") Then, in your views.home function (or wherever you want the form), you can add a line generating a blank form, like so: form=edit_name() And then in your context, add 'form': form That way in your HTML file, instead of writing all the input, you just have to do {{ form }} and Django will automatically generate the form for you. Now, in order to receive the data this form provid
Cites Rebel Poet · 2020-08 · Stack Overflow · on “append to request.sessions[list] in Django”
Something is bugging me. I'm following along with this beginner tutorial for django (cs50) and at some point we receive a string back from a form submission and want to add it to a list: [this video] def add(request): if 'tasklist' not in request.session: request.session['tasklist'] = [] if request.method == 'POST': form_data = NewTaskForm(request.POST) if form_data.is_valid(): task = form_data.cleaned_data['task'] request.session['tasklist'] += [task] return HttpResponseRedirect(reverse('tasks:index')) I've checked the type of request.session['tasklist'] and python shows it's a list. The task variable is a string. So why doesn't request.session['tasklist'].append(task) work properly? I can see i
Cites Ziad Alian · 2021-01 · Stack Overflow · on “Django project template doesn't exist”
I'm following this lecture [this video] and i got stuck at minute 29 when he changed HttpResponse to render and added the html file. it didn't work for me