1👍
✅
While you have created a new Room
object, you haven’t assigned it to room
.
Try
room = Room.objects.create(
0👍
Your create room function should look like this
@login_required(login_url='login')
def createRoom(request):
form = RoomForm()
topics = Topic.objects.all()
if request.method == 'POST':
topic_name = request.POST.get('topic')
topic, created = Topic.objects.get_or_create(name=topic_name)
room = Room.objects.create(
host=request.user,
topic=topic,
name=request.POST.get('name'),
assigned=request.user,
status=request.POST.get('status'),
priority=request.POST.get('priority'),
type=request.POST.get('type'),
description=request.POST.get('description'),
)
room.save()
return redirect("created-room-view-function")
context = {'form': form, 'topics': topics, 'room': room}
return render(request, 'room/room_form.html', context)
- [Answered ]-Django: Update object from view, with no model or template
- [Answered ]-Sphinx Readthedocs theme Font-awesome integration
- [Answered ]-What does passing lambda in urlconf in django mean?
Source:stackexchange.com