Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Authenticate restframework User in python
So, i new in django and djangorestframework. i followed their tutorial in their page. http://www.django-rest-framework.org/tutorial/4-authentication-and-permissions/ in that tutorial, you can login as django user from djangorestframework api login page. my question is, if i want to make a CLI or GUI application and using requests module to post a content to the API, but the API must be loggged in first. how i do that? -
Django: server global settings in
I don't know what I changed in previous django project when I run any new project without setting any thing in urlpatterns it shows error instead of original Django running I already tried uninstalling pycharm to deleting the project nothing works -
Not Found: /resources/demos/style.css in Django when connected to server
The Error Message that I keep getting I cannot for the life of me seem to figure out where to fix the error that I am receiving. I looked through each individual file and directory and google half a dozen times. I believe that I have to change something in the settings.py file. Any help would be greatly appreciated. -
Image not saving in UserProfileForm (Django)
I have a model form to update the user profile and everything is saving correctly except of them image. If I use admin it updates fine but when I use my form it just stays as the default profile image. Here is my form: class EditProfileForm(forms.ModelForm): birth_date = forms.DateField(label='birth_date', input_formats=['%Y-%m-%d']) class Meta: model = UserProfile fields = ( "image", "bio", "location", "birth_date", ) Here is my model: class UserProfile(models.Model): user = models.OneToOneField(User) bio = models.TextField(max_length=500, blank=True) location = models.CharField(max_length=30, blank=True) birth_date = models.DateField(null=True, blank=True) image = models.ImageField(upload_to='profile_image', blank=True) def __str__(self): return self.user.username def create_profile(sender, **kwargs): if kwargs['created']: user_profile = UserProfile.objects.create(user=kwargs['instance']) post_save.connect(create_profile, sender=User) Here is my view: def edit_profile(request): instance = get_object_or_404(UserProfile, user=request.user) if request.method == 'POST': form = EditProfileForm(request.POST, instance=instance) if form.is_valid(): instance = form.save(commit=False) instance.user = request.user instance.save() return redirect('/') else: form = EditProfileForm(instance=request.user) return render(request, 'edit_profile.html', {'form': form}) And here is my html: {% extends 'base.html' %} {% block content %} <h1>Edit Profile</h1> <form method='POST' action=''>{% csrf_token %} {{ form.as_p }} <button type="submit" class="btn btn-outline-success">Save</button> </form> </body> {% endblock %} -
Django CSRF Error fixed on page refresh in multi-page form?
I have two forms on two pages, one leads to the other. When "Submit" is pressed on page 1 it is supposed to take you to the form on page 2. Page 2 fails with "CSRF verification failed. Request aborted." With the reason being "CSRF cookie not set." The weird part is that if I go directly to Page 2, it loads fine. Or, if I refresh page 2 after getting the 403, it works fine. What gives? I am using the most recent version of Django, I am using render in all my views and {% csrf_token %} in all my form tags. Why would a refresh be fixing the 403 error? No login or authentication is happening between the forms. In fact, I don't even do anything with the data submitted in page 1 (yet). Relevant code is as follows: Page 1 Template: <div class=""> <div class=""> <h1>Page 1</h1> <p>What's up?</p> <form action="{% url 'core:getPageTwo' %}" method="post"> {% csrf_token %} {{ form }} <input class="yellow_button" type="submit" value="Submit"> </form> </div> </div> Page 2 View: def getPageTwo(request): form = SomeForm() context = {'form' : form} return render (request, 'core/page_two.html', context) Page 2 Template: <div class=""> <div class=""> <h1>Page 2</h1> <form … -
Why does Django Admin shows empty dropdown on foreign key field to multi-heritance model?
I have the following models: class BaseModel(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) class Meta: abstract = True class Content(BaseModel): title = models.CharField(max_length=2000) class Document(Content): file = models.FileField() reading_time = models.IntegerField() class DocumentView(BaseModel): document = models.ForeignKey(Document, on_delete=models.CASCADE) viewed_on = models.DateTimeField(auto_now=True) Everything works as expected, except that in the Django Admin, editing a DocumentView model, the Document dropdown doesn't get selected with the saved Document. Regarding the Admin, I use it in the default way: admin.site.register(DocumentView) -
Many-to-one relationship in Django
I'm new to django thus the question. This is my Location object, class Location(models.Model): country = models.CharField(max_length=255) city = models.CharField(max_length=255, unique=True) latitude = models.CharField(max_length=255) longitude = models.CharField(max_length=255) And this is my modified User object class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True, max_length=255) mobile = PhoneNumberField(null=True) username = models.CharField(max_length=255, null=True) full_name = models.CharField(max_length=255, blank=True, null=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_active = models.BooleanField(default=False) is_mobile_verified = models.BooleanField(default=False) location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True) This is the User Registration API view class RegisterView(views.APIView): def post(self, request): serializer = UserSerializer(data=request.data) if serializer.is_valid(): user = serializer.save() subject = "Please Activate Your FootTheBall Account!" token = self._generate() link = HOST + PREFIX + str(user.id) + SUFFIX + token message = 'Please use the following link to activate your account.\n\n{}'.format(link) from_email = settings.EMAIL_HOST_USER to_list = [user.email, 'soumasish@foottheball.com'] send_mail(subject, message, from_email, to_list, fail_silently=True) Token.objects.create(user=user, token=token) return Response(serializer.data, status=status.HTTP_201_CREATED) else: return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST) And this is the relevant url url(r'^register/$', RegisterView.as_view(), name='register') Now I want to modify this endpoint to take a location id as a path param and then add the logic in my UserCreation function that the user is added to the location as described by the id. Can someone help me do this ? -
Django Modal For User Login/Register - Form Render Issue
I'm trying to create a login/register modal based on the JS/Bootstrap here: https://www.creative-tim.com/product/login-and-register-modal I'm just looking for guidance as I'm having an issue displaying the form inputs on my modal. The modals will pop up fine upon click, yet the form inputs are not appearing. If i visit the page accounts/sign_in or accounts/sign_up and click on one of the buttons, then i do get the popup with the form inputs (for the most part). Thus, i think i must be improperly handling the render in my login_form view. I created this 'login_form' view following some guidance from this post here //views.py def login_form(request): signup_form = UserCreationForm() login_form = AuthenticationForm() context = {"signup_form": signup_form, "login_form": login_form} return render(request, 'layout2.html', context) and my url's: //urls.py app_name = "accounts" urlpatterns = [ url(r'sign_in/$', views.login_form, name='sign_in'), url(r'sign_up/$', views.login_form, name='sign_up'), this is the relevant modal code in my layout2.html file: <div class="form loginBox"> <form method="POST" action="{% url 'accounts:sign_in' %}"> {% csrf_token %} <input type="hidden" name="form_name" value="login_form"> {{ login_form.as_p }} <input type="submit" onclick="loginAjax()"> </form> </div> </div> </div> <div class="box"> <div class="content registerBox" style="display:none;"> <div class="form"> <form method="POST" html="{:multipart=>true}" data-remote="true" accept-charset="UTF-8"> {% csrf_token %} <input type="hidden" name="form_name" value="signup_form"> {{ signup_form.as_p }} <input type="submit" onclick="loginAjax()"> </form> </div> Not … -
Django query to use output of one queryset value in another iteratively
I have one Organization model in which for each organization, I have to find it's parent organization's id. I can able to get the parent org's id for a single organization using this piece of code, child = Organization.objects.filter(name='XYZ').first() parent = Organization.objects.filter(lft__lt=child.lft, rgt__gt=child.rgt, tree_id=child.tree_id).order_by('depth').last() print child, parent.id But I want the same for each organization (for each org, I want it's parent id).. If I do in a for loop, there should be an n number of db queries generated. Is there any way to get the output in a single db query? -
Equivalent of using if .. else as an expression in the Django Template Language
In Python, there are two ways to use if and else: either for Boolean flow control, in which case it is used with colons and indentation, or as an expression on a single line as described in https://www.pythoncentral.io/one-line-if-statement-in-python-ternary-conditional-operator/. As far as I can tell, the Django Template Language's {% if %} ... {% else %} ... {% endif %} tags are equivalent to the former. However, I was wondering if I could somehow implement the latter to refactor the code below: <form action="" method="post">{% csrf_token %} {% for field in form %} {% if field.name == "checkin_type" %} <div class="auto-submit"> {{ field.errors }} {{ field.label_tag }} {{ field }} </div> {% else %} <div> {{ field.errors }} {{ field.label_tag }} {{ field }} </div> {% endif %} {% endfor %} <input type="submit" value="Send message" /> </form> Here I am looping over the fields of the form and adding a particular class, "auto-submit", to the enclosing <div> element of a particular field ("checkin_type"). I'd like to refactor this along the lines of the following 'pseudocode': <form action="" method="post">{% csrf_token %} {% for field in form %} <div class="{% if field.name=='checkin_type'%}auto-submit{% else %}{% endif %}"> {{ field.errors }} {{ field.label_tag }} {{ … -
Saving and query one to many in django
I'm new to django thus this question. This is my location model, class Location(models.Model): country = models.CharField(max_length=255) city = models.CharField(max_length=255, unique=True) latitude = models.CharField(max_length=255) longitude = models.CharField(max_length=255) This is the location serializer, class LocationSerializer(serializers.ModelSerializer): id = serializers.IntegerField(read_only=True) class Meta: model = Location fields = ('id', 'country', 'city', 'logitude', 'latitude') And this is my User model, which has many-to-one relation with the location. class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField(unique=True, max_length=255) mobile = PhoneNumberField(null=True) username = models.CharField(max_length=255, null=True) full_name = models.CharField(max_length=255, blank=True, null=True) is_staff = models.BooleanField(default=False) is_superuser = models.BooleanField(default=False) is_active = models.BooleanField(default=False) is_mobile_verified = models.BooleanField(default=False) location = models.ForeignKey(Location, on_delete=models.SET_NULL, null=True) I have 3 questions. 1. In my Location create view, I want to grab an ip address from a POST request, query and API to get his location - check if the location already exists, if not then create it. How do I do it? Here's my LocationCreate View class LocationView(views.APIView): def post(self, request): client = geoip2.webservice.Client(int(MAXMIND_USERID), MAXMIND_LICENSE) response = client.insights(request.data['ip_address']) serializer =LocationSerializer(country=response.country.name, city=response.city.name, latitude=response.location.latitude, longitude=response.location.longitude) 2. In the user registration view, I want the URL to contain the location id and add the user to that location. Here's my User registration view, class RegisterView(views.APIView): def post(self, request): serializer = UserSerializer(data=request.data) if … -
Can't seem to update external javascript files in Django
Hello Everyone I'm trying to solve a beginner Django problem with what I think might be caching on a Django website. I would like to reload the javascript files when the page is loaded, but every time I load the page I get an old cached version. I've cleared both the firefox browser cache (through options/privacy and security) and deleted then recopied the static files into a static file directory using 'manage.py collectstatic --clear'. The old files that are loaded do not currently exist in the filesystem anymore so this has lead me to believe that there is serverside caching involved. The trouble is happening site-wide. OS:Windows 10 64-bit My directory structure: `enter code hereMode LastWriteTime Length Name ---- ------------- ------ ---- d----- 11/6/2017 4:28 PM adminPanel d----- 11/6/2017 4:28 PM blog d----- 12/4/2017 3:58 PM common d----- 11/6/2017 4:28 PM contactme d----- 11/6/2017 4:28 PM DataEntry d----- 11/6/2017 4:28 PM demoscene d----- 11/6/2017 4:28 PM errors d----- 11/6/2017 4:28 PM footer d----- 11/6/2017 4:28 PM headerFrame d----- 11/6/2017 4:28 PM Include d----- 11/6/2017 4:28 PM Lib d----- 11/6/2017 4:28 PM libraries d----- 11/6/2017 4:28 PM links d----- 2/22/2018 5:40 PM MagicFighter d----- 11/6/2017 4:28 PM movies d----- 11/9/2017 4:37 … -
change JSON elasticsearch query to python
I have been using basic queries in python for elasticsearch like this: from elasticsearch import Elasticsearch from elasticsearch_dsl import Search es = Elasticsearch() def someView(request): s = Search().query("regexp", title_en="someword.*") response = s.execute() I would like to combine a query to check if someword exists in either of the fields "title_en" or "text_en" Any idea how to accomplish this? In this link I saw an example of a bool query using JSON, but I don´t understand how something similar could be done with python code. { "query": { "bool" : { "must" : { "term" : { "user" : "kimchy" } }, "filter": { "term" : { "tag" : "tech" } }, "must_not" : { "range" : { "age" : { "gte" : 10, "lte" : 20 } } }, "should" : [ { "term" : { "tag" : "wow" } }, { "term" : { "tag" : "elasticsearch" } } ], "minimum_should_match" : 1, "boost" : 1.0 } } } -
Django temporary view
In my Django Project user is redirect to specific template with content: "Thanks for your registration" def success_signup(request): """Account created with success.""" return render(request, "account/success.html") when he register new account with success. I want to make this template/view temporary. I.E When the user/somebody go to "account/success.html" again should be redirected to the homepage instead of the success.html template. Unfortunately, I can not find this in the documentation. Thanks in advance! -
Error W005 URL namespace isn't unique
'Copied this code from the Django tutorial into my app's urls.py file... from django.urls import path from . import views app_name = 'polls' urlpatterns = [ path('', views.index, name='index'), path('<int:question_id>/', views.detail, name='detail'), path('<int:question_id>/results/', views.results, name='results'), path('<int:question_id>/vote/', views.vote, name='vote'), ] When I start my server it produces the following error... (urls.W005) URL namespace 'polls' isn't unique. You may not be able to reverse all URLs in this namespace I've tried using some other name besides 'polls' but with the same result. What am I doing wrong? -
Django modelformset_factory with edit link
I'm very new with Django I'm creating a form with modelformset_factory to display and edit the most commonly edited items of the object. However, I need to create an edit link that will take me to an edit page that allows me to edit everything about that instance but I can't get the template to render. My relevant code is: views.py def sleep_list(request): #index include_fields = 'name, fin, mrn, dateOfService, studyType, status' sleep_formset = modelformset_factory(SleepStudy, fields='__all__', widgets={ 'name': forms.TextInput(attrs={'class': 'name'}), 'dateOfService': forms.DateInput(attrs={'class': 'date'}), 'fin': forms.TextInput(attrs={'class': 'number'}), 'mrn': forms.TextInput(attrs={'class': 'number'}), 'studyType': forms.Select(attrs={'class': 'name'}), 'status': forms.Select(attrs={'class': 'name'}), }, can_delete=True, can_order=True, extra=0) if request.method == 'POST': sleep_studies = sleep_formset(request.POST, request.FILES) if sleep_studies.is_valid(): sleep_studies.save() return redirect('index') else: sleep_studies = sleep_formset() return render(request, 'sleep/index.html', {'sleep_studies': sleep_studies}) def sleep_patient_update(request, pk): studies = SleepStudy.objects.all() patient = get_object_or_404(SleepStudy, pk = pk) form = NewSleepPatientForm(request.POST or None, instance = patient) if form.is_valid(): form.clean() form.save(commit=True) return redirect('index') return render(request, 'sleep/sleep_patient_edit.html', {'form':form, 'studies':studies}) urls.py url(r'^sleep\$', views.sleep_list, name='sleep_list'), url(r'^sleep_patient/edit/(?P<pk>\d+)$', views.sleep_patient_update, name='update'), forms.py class NewSleepPatientForm(forms.ModelForm): class Meta: model = SleepStudy fields = '__all__' index.html code snippet <form method="POST">{% csrf_token %} {% if sleep_studies %} {{ sleep_studies.management_form }} {% for study in sleep_studies %} {{ study.id }} <tr> <td> {{ study.ORDER.as_hidden}} {{ study.DELETE}} </td> … -
Look for value by external key in django
I have a query since I have 2 models called Sale and Detail My models class Sale(models.Model): client = models.CharField(max_length=300, verbose_name='Cliente') date = models.DateField(auto_now_add=True) description = models.CharField(max_length=300, blank=True, verbose_name='Detalle del pedido') total = models.DecimalField(decimal_places=2, max_digits=7, verbose_name='Total de la venta') def __str__(self): return '{}'.format(self.id) class Detail(models.Model): product = models.ForeignKey(Producto,on_delete=models.CASCADE,verbose_name='Producto') quantity = models.IntegerField(verbose_name='Cantidad') price = models.DecimalField(decimal_places=2, max_digits=7, verbose_name='Precio unitario') subtotal = models.DecimalField(decimal_places=2, max_digits=7, verbose_name='Subtotal') sale = models.ForeignKey(Venta,on_delete=models.CASCADE, related_name='detalleventa', verbose_name='Venta') def __str__(self): return '{} - {}'.format(self.sale,self.product) where the Detail is related to 2 models that are Sale and Product as you can see Model Product class Producto(models.Model): name = models.CharField(max_length=30,unique=True,verbose_name='Nombre de Producto:') price = models.DecimalField(decimal_places=2, max_digits=7, verbose_name='Precio de Producto:') category = models.ForeignKey(Categoria,on_delete=models.CASCADE,verbose_name='Categoría:') def __str__(self): return self.name My question is: can I, through ajax, access the value of each product when it is selected with its respective external key in the Detail form? My form: class DetailForm(forms.ModelForm): class Meta: model = Detail fields = [ 'product', 'quantity', 'price', 'subtotal', ] labels = { 'product':'Producto', 'quantity':'Cantidad', 'price':'Prec.Unit.', 'subtotal':'Subtotal', } widgets = { 'product':forms.Select(attrs={'class':'form-control'}), 'quantity':forms.NumberInput(attrs={'class':'form-control cantidad'}), 'price':forms.NumberInput(attrs={'class':'form-control-plaintext', 'placeholder':'0.00','readonly':True}), 'subtotal':forms.NumberInput(attrs={'class':'form-control-plaintext subtotal', 'placeholder':'0.00','readonly':True}), } DetalleFormSet = inlineformset_factory(Sale, Detail, form=DetailForm, extra=1) In the details form, I have the product as an external key and my question is whether through … -
Django conditional post-save signal
Trying to trigger a post-save signal when a certain boolean in the model is True. To clear things up, my current receiver is @receiver(post_save, sender=Activity, dispatch_uid="create_feed_receiver") I wanna be able to do something like this: @receiver(post_save, sender=(Activity, boolean =True) dispatch_uid="create_feed_receiver") Is there any way to achieve this. Appreciate your help. -
Is gunicorn required for django to serve REST?
Will the django itself not serve the REST calls from web server (Nginx). Why is Gunicorn required if django itself could do that. -
Django get custom queryset into ListView
I have a listview that I access in a pretty bog standard way to return all metaobjects. #url url(r'^metaobject/$', MetaObjectList.as_view(),name='metaobject_list'), #ListView class MetaObjectList(ListView): model = MetaObject I've recently added a search form that I want to scan my objects (I've got about 5 fields but I've simplified the example). What I'd like to do is re-use my MetaObjectList class view with my specific subset. I am guessing I need to override the get_queryset method but I'm not clear in how I get the queryset from my FormView into the listview. I mucked around a bit with calling the as_view() in the formveiw's form_valid function with additional parameters but couldn't get it to work and it seemed hacky anyway. class SearchView(FormView): template_name = 'heavy/search.html' form_class = SearchForm #success_url = '/thanks/' def form_valid(self, form): #build a queryset based on form searchval=form.cleaned_data['search'] list = MetaObject.objects.filter(val=search) #where to from here? I also looked at trying to post the data from the form view over to the listview but that seemed like I'd need to re-write the form logic into the listview. I'm on python 3.x and django 1.11. -
Click on cancel button to return to the previous page
I have a cancel button and I need in a template to get the url of the previous page, so in case user click cancel to go back. Previous page, usually, is a list or detail page. In case of detail, I have the object, so it easier to go back, but what I do in case of a list page, also how do I know the previous is detail or list page. -
DjangoCMS - Placeholders in templates do not show up in django cms structure view
I'm using djangoCMS to add CMS functionality in my website templates but the placeholders i have placed on the placed are not showing up, i have defined my CMS_TEMPLATES IN MY settings.py and put the {% load cms_tags sekizai_tags sorl_thumbnail %} on my base.html and also added {% load cms_tags sekizai_tags %} on my other templates that expand the base.html, but when i log into djangoCMS admin and visit my pages i find no placeholders in my structure view. what could be the problem here? -
Django Autocomplete create two row / How to remove repeated
my first question is : How can i remove the repeated text in autocomplete field ? i used distinct() for autocomplete view but it didnt work and second : when i create new choice when it is not exists among the list it add two rows: first is the name which i entered and the other is the id ! and when i submit the form there is two row in db . one is the name which i created with null other fields and the other row is the id instead of the name i create with the form fields which i submited ! these are my codes : models.py : class Stocks(models.Model): user=models.ForeignKey(User, null=True) name=models.CharField(max_length=128,verbose_name=_('stockname')) number=models.CharField(blank=True,null=True,max_length=64,verbose_name=_('number')) suffix=models.CharField(blank=True,null=True,max_length=12,verbose_name=_('uffix')) comment=models.CharField(blank=True,null=True,max_length=264,verbose_name=_('comment')) def __str__(self): return str(self.name) class Meta: verbose_name=_('Stock') verbose_name_plural=_('Stocks') def get_absolute_url(self): return reverse('BallbearingSite:mystocks' ) forms.py : class StocksForm(forms.ModelForm): class Meta(): model=Stocks fields=('name','number','suffix','brand','comment','price') widgets = { 'name': autocomplete.ModelSelect2(url='stock_autocomplete') } def clean_name(self): return self.cleaned_data['comment'].upper() views.py: #stock view is for saving form in db def stock(request): stocks_form=StocksForm(None) if request.method == "POST": stocks_form =StocksForm(data=request.POST) if stocks_form.is_valid(): instance=stocks_form.save() instance.user=request.user instance.save() messages.success(request,"Registered Successfuly" ,extra_tags="savestock") else: messages.error(request, "ERROR!") else: stocks_form=StocksForm() return render(request,'BallbearingSite/stock.html',{'stocks_form':stocks_form}) #AUTOCOMPLETE class StocksAutocomplete(autocomplete.Select2QuerySetView): def get_queryset(self): if not self.request.user.is_authenticated(): return Stocks.objects.none() qs = Stocks.objects.all().distinct() #distinct doesnt work … -
How do I bind my range slider input field value to the correct input field in my html table?
I am using Django formsets. I have a range slider inside my html table body. When I move the slider, it updates the last text box in the table correctly (using javascript to do that). What I would like it to do is for the first slider to update the first text box, the second to update the second text box and so on. This is what my html tbody looks like <tbody class="product-instances"> {% csrf_token %} {{ evawform.management_form }} {% for form in evawform %} {{ form.id }} <tr> <td>{{form.criterion}}</td> <td><input type="range" min="1" max="100" value="1" class="slider" onchange="updateTextInput(this.value);"></td> <td><input type="text" id="textinput{{forloop.counter}}" value="1"></td> <td>{{form.updated_by}}</td> </tr> {% endfor %} </tbody> This is what my javascript function looks like. function updateTextInput(val) { document.getElementById('textinput{{forloop.counter}}').value = val; } Could you please help me out? Thanks! -
In Django, how to make selecting a drop-down option automatically submit a form?
I'm trying to implement a form which pre-populates fields based on another field. As a starting point, I'd like to make the form 'auto-submit' when an option from a drop-down menu is selected. I've tried the following template: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script> $(".auto-submit").change(function() { $(this).closest("form").submit(); }); </script> <form action="" method="post">{% csrf_token %} {% for field in form %} {% if field.name == "checkin_type" %} <div class="auto-submit"> {{ field.errors }} {{ field.label_tag }} {{ field }} </div> {% else %} <div> {{ field.errors }} {{ field.label_tag }} {{ field }} </div> {% endif %} {% endfor %} <input type="submit" value="Send message" /> </form> where the view is based on Django's generic CreateView: from django.views import generic from .models import CheckIn class CheckInCreate(generic.CreateView): model = CheckIn fields = '__all__' and the models are from django.db import models from django.urls import reverse class CheckInType(models.Model): title = models.CharField(blank=True, max_length=255) description = models.TextField(blank=True) def __str__(self): return self.title class CheckIn(models.Model): checkin_type = models.ForeignKey(CheckInType, null=True, on_delete=models.CASCADE) title = models.CharField(blank=True, max_length=255) description = models.TextField(blank=True) notes = models.TextField(blank=True) # Scheduling requested_date = models.DateField(blank=True, null=True) completed_date = models.DateField(blank=True, null=True) def get_absolute_url(self): return reverse('checkin-detail', kwargs={'pk': self.id}) def save(self, *args, **kwargs): if self.checkin_type: if not self.title: self.title = self.checkin_type.title if not self.description: self.description …