Category : Django

Email When you create a Form class, the most important part is defining the fields of the form. Each field has custom validation logic, along with a few other hooks.   ‘Field‘, ‘CharField‘, ‘IntegerField‘, ‘DateField‘, ‘TimeField‘, ‘DateTimeField‘, ‘DurationField‘, ‘RegexField‘, ‘EmailField‘, ‘FileField‘, ‘ImageField‘, ‘URLField‘, ‘BooleanField‘, ‘NullBooleanField‘, ‘ChoiceField‘, ‘MultipleChoiceField‘, ‘ComboField‘, ‘MultiValueField‘, ‘FloatField‘, ‘DecimalField‘, ‘SplitDateTimeField‘, ‘GenericIPAddressField‘, ‘FilePathField‘, ‘SlugField‘, ‘TypedChoiceField‘, ‘TypedMultipleChoiceField‘, ..

Read more

Django Model Field Reference list     Field Default Widget Description AutoField N/A An IntegerField that automatically increments according to available IDs. BigIntegerField NumberInput A 64-bit integer, much like an IntegerField except that it is guaranteed to fit numbers from -9223372036854775808 to 9223372036854775807 BinaryField N/A A field to store raw binary data. It only supports bytes assignment. Be aware that this field ..

Read more

Emailfrom django.db import models from django.forms import ModelForm from django.contrib.auth.models import User from django.core.exceptions import ValidationError class Type(models.Model): id = models.AutoField(primary_key=True, db_column=u’id’) type = models.CharField(max_length=200) def __unicode__(self): return self.type class Category(models.Model): id = models.AutoField(primary_key=True, db_column=u’id’) category = models.CharField(max_length=200) def __unicode__(self): return self.category class Client(models.Model): id = models.AutoField(primary_key=True, db_column=u’id’) name = models.CharField(max_length=200,) ico = models.CharField(max_length=20,) vat ..

Read more

Email                    PS C:UsersnaikADesktopelearingelearningsigma> python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, dqsadmin, login, register, sessions Running migrations: Applying dqsadmin.0009_mainmenu_currentdate…Traceback (most recent call last): File “manage.py”, line 15, in <module> execute_from_command_line(sys.argv) File “C:UsersnaikAAppDataLocalProgramsPythonPython37-32libsite-packagesdjangocoremanagement__init__.py”, line 381, in execute_from_command_line utility.execute() File “C:UsersnaikAAppDataLocalProgramsPythonPython37-32libsite-packagesdjangocoremanagement__init__.py”, line 375, in execute ..

Read more

EmailDjango Dropdown populate from mongodbdatabases view.py def adminsubmenu(request): mainmenu_name= Mainmenu.objects.all() mainmenuname = request.GET.get(‘mainmenu_name’) return render(request, ‘admin_super/home/submainmenu.html’,{‘mainmenu_name’:mainmenu_name}) html page   <formclass=”forms-sample”action=”method=”POST”> <divclass=”form-group”> <labelfor=”exampleFormControlSelect2″>Select Main Menu</label> <selectclass=”form-control”id=”exampleFormControlSelect2″> {% for name in mainmenu_name %} <optionvalue=”{{ name.id }}”>{{ name.mainmenu_name }}</option> {% endfor %} </select> </div>   <divclass=”form-group”> <labelfor=”exampleInputCity1″>sub Main menu</label> <inputtype=”text”class=”form-control”id=”exampleInputCity1″placeholder=”Location”> </div> {% csrf_token %}   <buttontype=”submit”class=”btn btn-success mr-2″>Submit</button> ..

Read more

Emailstep1: view.py       def adminmainmenu(request): if request.method ==’POST’: form=Mainmenu_post(request.POST) if form.is_valid(): new_item_text = request.POST[‘mainmenu_name’] Mainmenu.objects.create(mainmenu_name=new_item_text) else: new_item_text =” return render(request, ‘admin_super/home/mainmenu.html’) step2: models.py from django.db import models   class Mainmenu(models.Model): mainmenu_name = models.CharField(max_length=300) currentdate= models.DateField()   class Meta: model=Mainmenu fields=[‘title’] step3: form.py from django import forms from dqsadmin.models import Mainmenu   class Mainmenu_post(forms.Form): mainmenu_name ..

Read more