1. Add ManyToManyField() to models.py them migrate to the database [python] operating_system = models.ManyToManyField(Operating_system, blank=True) [/python] 2. In views.py, use the following to save ManyToManyField...
Category - Computer Inventory Management System
1. Update computer model to include: [python] os_choice = ( ('Windows 10', 'Windows 10'), ('Windows 8', 'Windows 8'), ('Linux', 'Linux'), ) operating_system =...
1. Open forms.py and validate the ComputerForm To prevent saving object with a blank computer name def clean_computer_name(self): # Validates the Computer Name Field computer_name =...
1. In forms.py, create a form to be used for search [python] class ComputerSearchForm(forms.ModelForm): class Meta: model = Computer fields = [‘computer_name’, ‘users_name’] [/python] 2. Import...
1. Create Computer_delete view in views.py def computer_delete(request, id=None): instance = get_object_or_404(Computer, id=id) instance.delete() return redirect("computer_list") 2. Create a url in urls.py that will...