• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /var/www/html/cnasolution/site/application/views/question.php
Line: 191
Function: _error_handler

File: /var/www/html/cnasolution/site/application/controllers/Questions.php
Line: 419
Function: view

File: /var/www/html/cnasolution/site/index.php
Line: 315
Function: require_once

I want to to make a website where a user gives some value and based on it more fields are created. Like for

 
{% csrf_token %}

If the user gives input as 8 ,then eight fields are added in admin of Django

 class watched(models.Model):     watched = models.BooleanField(default = False)  

Then create a webpage for marking which episodes have been watched and not.

Download script demo [LINK]
Download script demo [LINK 2] Download script demo [LINK 2]

To make such thing possible (adding dynamic number of episodes to tv serie) you have to create a model - Episode which objects you will create and link to a serie through the form that you mensioned. Model can't have the dynamic number of fields (due to database structure). The dynamic number of form windows on the front-end is lesser problem and can be achieved though jinja+ajax combination. Here's how a django part would look like if I understood your idea correctly:

class Series(models.Model):     title = models.CharField()    # some more attributes  class Episode(models.Model):     title = models.CharField()    # some more attributes    series = models.ForeignKey(Series, on_delete=models.CASCADE) 

The last line makes a connection between Episode and a Serie more on that here: https://docs.djangoproject.com/en/3.0/topics/db/examples/many_to_one/ Then you make AddSerieForm and AddEpisodeForm model forms and in a smart way put them onto your site. I can see It will require some js and jinja skills. But once you've learned them they become very easy to implement, also they are quite helpful.

see demo
  • 24
Reply Report