'Django / Create HTMl file from a form

In my Models.py

class Scenes(models.Model):
    name = models.SlugField('Scene name', max_length=60,unique=True)
    description = models.TextField(blank=True)

I have submitted the form in Views.py (simplified version)

def add_scenes(request): 
  form = sceneForm(request.POST, request.FILES)
   if form.is_valid():
            scenes=form.save(commit=False)
            form.save()
        return HttpResponseRedirect('add_scenes?submitted=True')
   return render(request,'scenes3d/add_scenes.html',
        {'form':form, 'submitted':submitted})

What I would like is : after the form is submitted, a new html is created which would be defined in urls.py with the slug name of my form.

path('<str:slug>',views.newpage, name="newpage"),   

Is it the right way to achieve that ?



Solution 1:[1]

Here is what I have found. There is no creation, just a way to declare new page inside urls.py

urls.py

 path('newpage/<slug:scene_slug>',views.newPage,name='newPage'),

views.py

def newPage (request, scene_slug):
    sceneToRender = Scenes.objects.get(name=scene_slug)
    return render(request,'scenes3d/new_scene.html',
        {"scene" :sceneToRender, }
    )

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 fransua