>>> Employee.objects.filter(firstName__contains='bo') | Employee.objects.filter(salary__lte='2000')
<QuerySet [<Employee: Employee object (1)>]>
>>>
>>> from django.db.models import Q
>>> Employee.objects.filter(Q(firstName__contains='bo') | Q(salary__lte='2000'))
<QuerySet [<Employee: Employee object (1)>]>
# forms.py
from django import forms
class UserRegistrationForm(forms.Form):
firstName = forms.CharField()
lastName = forms.CharField()
email = forms.CharField()
# urls.py
from .views import display, onsubmit
urlpatterns = [
path('hello/', display, name='n_index'),
path('onsubmit/', onsubmit, name='n_onsubmit'),
]
# forms.py
from django import forms
from .models import Employee
class UserRegistrationForm(forms.ModelForm):
class Meta:
model= Employee
fields = '__all__'
$ ls fbvApp/templates/fbvApp/
create.html index.html update.html
# models.py
from django.db import models
class Student(models.Model):
# urls.py
from cbvApp.views import GreetingView
urlpatterns = [
path('', GreetingView.as_view())
]
# urls.py
from cbvApp.views import GreetingView
urlpatterns = [
path('', GreetingView.as_view(msg='hi'))
]
$ ls cbvApp/templates/cbvApp/
student_confirm_delete.html student_detail.html student_form.html student_list.html
# models.py
from django.db import models
from django.urls import reverse
$ ls cbvApp/templatetags/
custFilters.py __init__.py
from django import template
register = template.Library()
@register.filter(name='extradash')