Hello!, change the " of the fields of the Meta class to ' in the class Busines..(forms.ModelForm)
El mié., 14 ago. 2019 a las 12:38, Kean (<[email protected]>) escribió: > Hi, > > New to Django, I'm trying to create a form which means user can update in > the browser and it gets stored in the database, however my form wont appear > in the browser. > > please see setup: > > URLS.py > > path('Business register/Business management/Admin/Add new business', > views.addnewbusiness, name='addnewbusiness'), > > MODELS > > class Businessownercreate(models.Model): > Creator = models.CharField(max_length=20) > Micro_Small_Medium = models.CharField(max_length=6) > Business_Name = models.CharField(max_length=20) > Owner_Firstname = models.CharField(max_length=20) > Owner_Surname = models.CharField(max_length=20) > Companies_House_Number = models.CharField(max_length=8) > Address_Line_1 = models.CharField(max_length=30) > Address_Line_2 = models.CharField(max_length=30) > Town = models.CharField(max_length=20) > City = models.CharField(max_length=20) > County = models.CharField(max_length=20) > Postcode = models.CharField(max_length=10) > Email = models.EmailField(max_length=50) > Phone = models.CharField(max_length=15) > Mobile = models.CharField(max_length=15) > Created_date = models.DateTimeField('date published') > > def __unicode__(self): > return self.Business_Name > > def __str__(self): > return self.Companies_House_Number > return self.Business_name > > FORMS.py > > class Businessownercreate(forms.ModelForm): > > class Meta: > model = Businessownercreate > fields = ["Creator", "Micro_Small_Medium", "Business_Name", > "Owner_Firstname", > "Owner_Surname", "Companies_House_Number", "Address_Line_1", > "Address_Line_2", > "Town", "City", "County", "Postcode", "Email", "Phone", "Mobile", > "Created_date" > ] > > VIEWS.py > > def addnewbusiness(request): > if request == "POST": > form = Businessownercreate(request.POST) > if form.is_valid(): > form.save() > > return HttpResponseRedirect('/Business register/Business > management/Admin/Add new business/business overview') > else: > form = Businessownercreate() > > return render(request, 'businessownercreate.html') > > > TEMPLATES. > > {% load static %} > > <!-- Compiled and minified CSS --> > <link rel="stylesheet" href=" > https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css > "> > > <!-- Compiled and minified JavaScript --> > <script src=" > https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js > "></script> > > <nav> > <div class="nav-wrapper"> > <a href="/" class="brand-logo">Billntrade</a> > <ul id="nav-mobile" class="right hide-on-med-and down"> > <li><a href="/Business register/Business management/Admin/Add > new business/Business overview">business overview</a></li> > <li><a href="/Business register/Business management/Admin/Add new > business/Back">Back</a></li> > <li><a href="/Business register/Business management/Admin/Add > new business/account">{{user.username}}</a></li> > </a></li> > </ul> > </div> > </nav> > > > <div class="container"> > <br> > > <form action="/Business register/Business management/Admin/Add new > business" method="POST"> > {% csrf_token %} > {{form.as_p}} > > > <button class="btn" type = "submit">create</button> > </form> > > Please can anyone help, I can't seem to get anything other than the button > to appear? > > Best, > > K > > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/5b9b7ce1-1161-439d-b485-516b89cb7ee0%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/5b9b7ce1-1161-439d-b485-516b89cb7ee0%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAEkprU37ZPRVur4fyt_CyDLKnQidT8BikoUbAQDhXUQyddiKQ%40mail.gmail.com.

