Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
Overwriting nested serializer's create method throws TypeError: create() got multiple values for keyword argument
I want to send data to my API. My data structure is nested. So I am trying to overwrite the create method following the docs and SO. When sending data it gives me the following error: TypeError: create() got multiple values for keyword argument 'graph' My data structure looks like this: { "project": "project1", "name": "Graph1", "description": "Graph belongs to Projekt1", "nodes": [ { "id": 2, "name": "Node1 of Graph 1", "graph": 3 } ] } Her is what I am trying in my serializer (which is pretty standard I assume): class GraphSerializer(serializers.ModelSerializer): nodes = NodeSerializer(many=True) class Meta: model = Graph fields = ('project', 'name', 'description', 'nodes', ) def create(self, validated_data): nodes_data = validated_data.pop('nodes') graph = Graph.objects.create(**validated_data) print(graph) for node_data in nodes_data: Node.objects.create(graph=graph,**node_data) return graph The error is in the for loop. When I debug though and print graphit give me back just one Graph (Graph1). So I don't understand why I should get a multiple values error. Here is more info if needed: Node serializer class NodeSerializer(serializers.ModelSerializer): id = serializers.IntegerField(required=False) class Meta: model = Node fields = ('id', 'name', 'graph', ) My models class Graph(models.Model): project = models.ForeignKey(Project, on_delete=models.CASCADE) name = models.CharField(max_length=120, blank=True) description = models.CharField(max_length=400, blank=True) def __str__(self): … -
allowing spaces and numbers in Django fields
I want to allow spaces and numbers in the field, I changed the form forms.CharField to forms.RegexField and it didnt work. I found similar questions: Here, Here and other questions, but none of them works good. alphanumeric_underscore = RegexValidator(r'^[0-9a-zA-Z]*$') list_of_templates = get_template_database_names() existing_database = forms.ModelChoiceField( queryset=TemplateDatabase.objects.all(), label='Name des Templates') new_database = forms.CharField(label='Name von Datenbank ' 'auf Basis des Templates', max_length=255, validators=[alphanumeric_underscore]) I can use numbers in the name, but it cannot begin or end with numbers. but by using space its not working -
django 2.2.3-Django 404 error ('Page not found') after runserver
My project is named 'tweetme', and when I runserver I get this error. Using the URLconf defined in tweetme.urls, Django tried these URL patterns, in this order: ^admin/ ^static/(?P<path>.*)$ The empty path didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. urls.py file: from django.conf.urls import url, include from django.contrib import admin from django.conf import settings from django.conf.urls.static import static urlpatterns = [ url(r'^admin/', admin.site.urls), ] if settings.DEBUG: urlpatterns += (static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)) I expect to shows: the install worked successfully! Congratulation but its shows me: Page not found at/ -
Return data based on model flag for OnetoOne Nested Serializer
I am using a nested serializer for onetoone mapping for a model offer. But i want the nested serializer to only return data if the fllag in the model instance of nested serializer is set to true. I guess to_representation will not work here as it will receive an object instance rather than queryset. Model : class Offers(models.Model) : brand = models.CharField(max_length=100,blank=True,null=True) hospital = models.OneToOneField('hospital.Providers',to_field='hospital_id',on_delete=models.SET_NULL, related_name='hospital_offer',blank=True,null=True) validity = models.PositiveIntegerField(default=0) terms = models.CharField(max_length=500,blank=True,null=True) discount = models.PositiveIntegerField(default=0) logo = models.CharField(max_length=100,blank=True,null=True) active = models.BooleanField(default=True) created_date = models.DateTimeField(auto_now_add=True) Serializer : class ProviderOffersSerializer(serializers.ModelSerializer) : class Meta : model = Offers fields = ('brand','id') class ProviderSerializer(serializers.ModelSerializer): hospital_offer = ProviderOffersSerializer(read_only=True) network = NetworkSerializer(read_only=True) class Meta: model = Providers fields = ('hospital_id','hospital_name','hospital_offer','pincode','network') Now ProviderSerializer should return data for offer only if active is True. Any help will be appreciated. -
Django. When adding an image, create a folder corresponding to the object id
I created a model, it has a line for the image: photo_1 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True) photo_2 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True) photo_3 = models.ImageField(upload_to='photos/%Y/%m/%d/', blank=True) In the example, if I add an image, a folder is created with the date of adding I wish that when add an image, create a folder with the "id" of the object. Please tell me the solutions! Thanks and sorry for my english! -
Please Help me to fix this issue
I'm learning python Django. I have been trying to create a custom user model and it is working but the issue I have is that whenever I visit any user's profile through the Django admin I get this error Exception Value: 'date_joined' cannot be specified for UserProfile model form as it is a non-editable field. Check fields/fieldsets/exclude attributes of class UserAdminModel. Here is how my model is looking like. class UserProfile(AbstractBaseUser, PermissionsMixin): """ A model for authors and readers.""" first_name = models.CharField(max_length=255) last_name = models.CharField(max_length=255) username = models.CharField(max_length=255, unique=True) email = models.EmailField(max_length=255, unique=True) password = models.CharField(max_length=255) is_active = models.BooleanField(default=True) is_staff = models.BooleanField(default=False) date_joined = models.DateTimeField(auto_now_add=True) REQUIRED_FIELDS = ['email', 'password'] USERNAME_FIELD = 'username' objects = UserProfileManager() def __str__(self): return self.username also my serialiser looks like this class UserProfileSerializer(ModelSerializer): """ Serializers user profile model. """ def create(self, validated_data): password = validated_data.pop('password', None) instance = self.Meta.model(**validated_data) if password is not None: instance.set_password(password) instance.save() return instance class Meta: model = UserProfile fields = ('id', 'first_name', 'last_name', 'username', 'email', 'is_staff', 'password') extra_kwargs = { "is_staff": { "read_only": True }, } -
Django CMS multi-line field
Is it possible to make multi-line field on this page, because it's really uncomfortable when you have to scroll to see the whole thing. -
PyCharm not recognizing models
I am writing unit tests for my project but when I run tests file it says apps.products.models.Category.DoesNotExist: Category matching query does not exist. and it does not recognize in tests.py file. Though I have already included installed apps in the settings PROJECT_APPS = [ 'apps.core', 'apps.products ', ] INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'rest_framework', 'rest_framework.authtoken', 'django_filters', ] + PROJECT_APPS I am importing like this from apps.products.models import Category and that model is not detected I have init file in my directory. Any help please) -
How to override the field value for modelformset in CreateView?
I use different qwerysets for modelformset of the same model. The first filter for grouping values from queryset I define in forms.py class SkillCreateFrameworkForm(SkillBaseCreateForm): def __init__(self, *args, **kwargs): super(SkillCreateFrameworkForm, self).__init__(*args, **kwargs) self.fields['technology'].queryset = Technology.objects.filter(group__name="Framework") class SkillCreatePLanguageForm(SkillBaseCreateForm): def __init__(self, *args, **kwargs): super(SkillCreatePLanguageForm, self).__init__(*args, **kwargs) self.fields['technology'].queryset = Technology.objects.filter(group__name="Programming language") The next step is to filter out the values that are already bound to the user being edited. To do this, in get_context_data I get a list of all the technologies that the user already has. employee_current_technology = Technology.objects.filter(skill__employee__id=self.kwargs['pk']) get_context_data def get_context_data(self, **kwargs): context = super(SkillTestCreateView, self).get_context_data(**kwargs) employee_current_technology = Technology.objects.filter(skill__employee__id=self.kwargs['pk']) context['formset_framework'] = SkillFrameworkFormSet() context['formset_planguage'] = SkillPLanguageFormSet() context['tech_group'] = Techgroup.objects.all() return context How do I now apply a filter to context['formset_framework'] that excludes technologies that the user already has? Smt like context['formset_framework'] = SkillFrameworkFormSet().field['technology'] not in employee_current_technology <-- ??? -
how to process submit on django-tables2 with a class View with FilterView mixin
I have a django-tables2 FilterView. The filter is templated in a form: {% if filter %} <form action="" method="get" class="form form-inline"> {% bootstrap_form filter.form layout='inline' %} {% bootstrap_button 'filter' %} </form> {% endif %} I have added a checkbox field to each row, and I have the table in a form: <form action="table_selection" method="get" class="form form-inline"> {% csrf_token %} {% render_table table 'django_tables2/bootstrap.html' %} <button class="btn btn-primary red" type="submit" >Submit Rows</button> </form> When I submit, I get logging messages like: GET /three_pl/threepl_fulfilments_filter/table_selection?csrfmiddlewaretoken=... &select_row=198&select_row=158&select_row=159 so the select_rows are very interesting. But I am lost with the class view, I can't grapple with how to process the form submission. This is my view: class FilteredThreePLFulfimentsView(SingleTableMixin,FilterView): table_class = ThreePL_order_fulfilmentsTable model = ThreePL_order_fulfilments template_name = "three_pl/ThreePLFulfilmentsFilter.html" #three_pl/templates/three_pl/ThreePLFulfilmentsFilter.html filterset_class = ThreePLFulfilmentsFilter -
how can i modified field is recorded, in django.form or django.model
I want to record the model field when they are be modified, who modifid them; the olg field and the new field. I do it in them ModelForm.clean, to find which field be modified, and record them. class SynthesisStepForm(BootstrapModelForm): class Meta: model = SynthesisStep fields = ('title', 'version', 'condition', 'yield_rate', 'testing', 'stype') widgets = { 'testing': forms.Textarea(attrs={'rows': '4', 'cols': '100', 'style': 'width:auto;'}), 'condition': forms.Textarea(attrs={'rows': '4', 'cols': '100', 'style': 'width:auto;'}) } def clean(self): """ :return: """ update_fields = ('title', 'version', 'condition', 'yield_rate', 'testing', 'stype') cleaned_data = super(BootstrapModelForm, self).clean() update_note = supervisory_update_fields(self, cleaned_data, update_fields) self._update_note = update_note return cleaned_data def supervisory_update_fields(form_obj, cleaned_data, update_fields): """ :param form_obj: :param cleaned_data: :param update_fields: :return: """ update_note = '' if form_obj.instance.pk: # new instance only changed_data = form_obj.changed_data for data in changed_data: if data in update_fields: try: old_field = eval('form_obj.instance.{0}'.format(data)) new_field = cleaned_data[data] if old_field != new_field: update_note = update_note + '{2} is modified , from "{0}" to "{1}"\n'.format(old_field, new_field, data) except Exception as e: pass return update_note I want to take it more efficiency,and can ues it in model.save and form.save -
How to add new user in admin page in django?
I am trying to add user in admin page in django. Whenever I register in my site form it adds itself but whenever I try to add it in admin page, it gave me the error message. NotImplementedError at /admin/auth/user/add/ UNKNOWN command not implemented for SQL SAVEPOINT "s6856_x1" C:\Users\Bilal\Envs\trial\lib\site-packages\djongo\sql2mongo\query.py in parse handler = self.FUNC_MAP[sm_type] -
Nested object dipslayed in main object django
I have problem with nested objects in Django. I would like not return to main response nested objects. Actually I have reponse: [ { "display_name": "Link1", "link": "http://facebook.com", "sub_links": [ { "display_name": "Link3", "link": "http://vk.com" }, { "display_name": "Link2", "link": "http://google.com" } ] }, { "display_name": "Link2", "link": "http://google.com", "sub_links": [] }, { "display_name": "Link3", "link": "http://vk.com", "sub_links": [] } ] and I would like receive: [ { "display_name": "Link1", "link": "http://facebook.com", "sub_links": [ { "display_name": "Link3", "link": "http://vk.com" }, { "display_name": "Link2", "link": "http://google.com" } ] } ] My viewset: class LinksViewSet(ReadOnlyModelViewSet): queryset = Links.objects.all() serializer_class = LinksSerializer permission_classes = (AllowAny, ) pagination_class = None My serializer: class SubLinksSerializer(serializers.ModelSerializer): class Meta: model = Links fields = ('display_name', 'link', ) class LinksSerializer(serializers.ModelSerializer): sub_links = SubLinksSerializer(many=True, read_only=True) class Meta: model = Links fields = ('display_name', 'link', 'sub_links') I really don't know how should I do it. What is more I tried find solution in documentation Django. -
Django view testing: Should status code be tested separately from template used?
I've created a test for one of my views. The function: Asserts if the status code is 200 Asserts if the template was used Best practice wise, should these tests be kept separate? I'm concerned that I'm violating SRP (Single Responsibility Principle) by giving this function multiple assertions. The code works as is, this is merely an opinion question (sorry if this question should be somewhere else). def test_contacts_GET(self): response = self.client.get(self.contacts_url) request = self.client.get(self.contacts_url) self.assertEqual(request.status_code, 200) self.assertTemplateUsed(response, 'crm/contacts.html') All tests are passing as is. Thank you in advance for your time. -
Url for custom method in django apiview
I am new in Django and I am bit confused in Django apiview for custom method. In ApiView, How can I create a custom method and How to call from axios. For example Here is my View class TimeSheetAPIView(APIView): @action(methods=['get'], detail=False) def getbytsdate(self, request): return Response({"timesheet":"hello from getbydate"}) def get(self,request,pk=None): if pk: timesheet=get_object_or_404(TimeSheet.objects.all(),pk=pk) serializer = TimeSheetSerializer(timesheet) return Response({serializer.data}) timesheet=TimeSheet.objects.all() serializer = TimeSheetSerializer(timesheet,many=True) return Response({"timesheet":serializer.data}) Here is my URL=> url(r'^timesheets_ts/(?P<pk>\d+)/$', TimeSheetAPIView.as_view()), url(r'^timesheets_ts/', TimeSheetAPIView.as_view()), Normally my url would be like=> api/timesheet_ts/ this one will get all of my records. So my question is how can I setup URL for getbytsdate or getbyname or other some kind of custom get method? and how can I call? I tried like this way=> url(r'^timesheets_ts/getbytsdate/(?P<tsdate>[-\w]+)/$', TimeSheetAPIView.as_view()), and I called like that api/timesheets_ts/getbytsdate/?tsdate='test' Its not work. So please can u explain for the custom method in apiview and url setting? -
Delete file when file download is complete on Python x Django
I can download the file with the following code(Python x Django). file = open(file_path, 'w') file.write(text) file.close() if os.path.exists(file_path): with open(file_path, 'rb') as fsock: filename = urllib.parse.quote(filename) response = HttpResponse() response['content_type'] = 'text/plain' response['Content-Disposition'] = "attachment; filename='{}'; filename*=UTF-8''{}".format(filename,filename) response.write(fsock.read()) return response The file to download is generated before downloading. At this time, is it possible to implement deletion of files when downloading is complete? -
"Hashes did not match" during deploying cookiecutter django with wagtail
I have been trying to deploy my Django/Wagtail project that is created with Cookiecutter Django using docker to a Digital Ocean droplet that I created using the command docker-machine create.The problem is that all the static files have the error Hashes did not match even after I use ./manage.py collectstatic I've tried to google it but cannot find any reference regarding this error. django_1 | INFO 2019-07-28 10:24:52,920 etag 8 140528735497544 css/project.css: Hashes did not match django_1 | INFO 2019-07-28 10:24:52,925 etag 8 140528735497544 images/favicons/favicon.ico: Hashes did not match django_1 | INFO 2019-07-28 10:24:52,929 etag 8 140528735497544 js/project.js: Hashes did not match django_1 | INFO 2019-07-28 10:24:52,932 etag 8 140528735497544 sass/project.css.map: Hashes did not match django_1 | INFO 2019-07-28 10:24:52,936 etag 8 140528735497544 sass/project.css: Hashes did not match Below is my static setting in base.py # STATIC # ------------------------------------------------------------------------------ STATIC_ROOT = str(ROOT_DIR("staticfiles")) STATIC_URL = "/static/" STATICFILES_DIRS = [str(APPS_DIR.path("static"))] STATICFILES_FINDERS = [ "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder", ] -
Limit the amount of logins Django server
I need limit traffic to Django server, but I don't know about that problem. I need be provided some keyword to to solve that problem. Thanks -
How can I generate QR code in django project?
Can anyone guide me to generate QR code in django project? I want to generate Qr code by taking data from postgres database and display it in the template? -
what is the route_class replacement?
I'm following a tutorial about GraphQL subscriptions with Django. But on routing channels does not have "route_class" member. But I can't found why. Anyone knows how to use channels routing? class Suscription(ObjectType): count_seconds = Int(up_to=Int()) def resolve_count_seconds(root, info, up_to=5): return Observable.interval(1000).map(lambda i: "{0}".format(i))\ .take_while(lambda i: int(i) <= up_to) ROOT_SCHEMA = graphene.Schema(query=Query, mutation=Mutation, suscription=Suscription) #urls from channels.routing import route_class # route_class does not exists from graphql_ws.django_channels import GraphQLSubscriptionConsumer channel_routes = [ route_class(GraphQLSubscriptionConsumer, path='subscriptions') ] -
python - Django ORM retrieve parent model with filtered children model
I have the following models in Django: class Gasto(models.Model): monto = models.DecimalField(default=0,decimal_places=2, max_digits=10) nombre = models.CharField(max_length=30) informacion = models.TextField(blank=True, default="") numero_cuotas = models.PositiveSmallIntegerField(default=1) es_compartido = models.BooleanField(default=False) es_divisible = models.BooleanField(default=False) contrato = models.ForeignKey(Contrato, on_delete=models.PROTECT) class Cuota_Gasto(models.Model): monto = models.DecimalField(default=0,decimal_places=2, max_digits=10) fecha = models.DateField() gasto = models.ForeignKey(Gasto, related_name='cuotas',on_delete=models.DO_NOTHING) factura_rendida = models.ForeignKey(Factura, on_delete=models.DO_NOTHING, null=True, related_name='gasto_rendido') factura_liquidada = models.ForeignKey(Factura, on_delete=models.DO_NOTHING, null=True, related_name='gasto_liquidado') From now on: 'Gasto' will be called Expense, and 'Cuota_Gasto' will be called Share. Expense is the parent model and Share is the children, with a 1..N relationship. I want to retrieve each Expense with its Shares, BUT only those Shares that meet certain conditions. Is this possible? I could get each expense with ALL shares by using related_name and reverse relantionship, for example: { "monto": "-500.00", "nombre": "RRR", "informacion": "Extra", "numero_cuotas": 1, "es_compartido": true, "cuotas": [ { "id": 16, "nombre": "RRR", "informacion": "Extra", "contrato": 3, "monto": "-500.00", "fecha": "07/07/2019", "gasto": 4, "factura_rendida": null, "factura_liquidada": 12 } ] } But I can't get to the query that allows me to exclude the shares i don't want. I was thinking about something like this: Gasto.objects.distinct().filter(cuotas__fecha__lte = date) Even though that query is not correct. I hope someone can help me. Thanks -
Using a personal module with Django
I have created a Python project and stored it as a module with the following file structure - rrs |--main.py |--Pack1 |-- |-- . . |--Pack2 |-- |-- . . Now, I am serving this project through Django. I created a separate django project with just one home app. I have placed the rrs folder inside my home app as I want the home view to access the main.py in the rrs folder myproject |-----home |---views.py |---rrs |--- . . |-----website |----settings.py |--- . . Now when I run the server it throws an error saying no module name Pack1 found. How would I fix this? -
Persisting data _somewhere_ in real-time game
I am building a game where users solve math problems in order to move. Up is one problem, right is another, down is another, and so on. When the user sends an answer to the server, the server needs to check if not only the answer is correct, but what direction of movement the answer corresponds to. In order to do this I would need to persist the data somewhere after initial creation. I thought about using a database but this would be overkill, I think, and the game is very intense and fast and real-time (values would be changing constantly -- I would imagine a database would be too slow for this game). Does anyone have any suggestions? Thanks in advance. -
How to resolve recursion error in python django urls.py
I'm pretty new to django and working on a project from https://github.com/mkaykisiz/DjangoS3Browser/ where I'm ending up with recursion error after adding "url(r'^' + settings.S3_BROWSER_SETTINGS + '/', include('djangoS3Browser.s3_browser.urls'))," line to url.py URL.py from django.conf.urls import url, include from django.conf.urls.static import static from djangoS3Browser.s3_browser import settings from djangoS3Browser.s3_browser import views import sys urlpatterns = [ url(r'^get_folder_items/(.+)/(.+)/$', views.get_folder_items, name='get_folder_items'), url(r'^upload/$', views.upload, name='upload'), url(r'^create_folder/$', views.create_folder, name='create_folder'), url(r'^download/$', views.download, name='download'), url(r'^rename_file/$', views.rename_file, name='rename_file'), url(r'^paste_file/$', views.paste_file, name='paste_file'), url(r'^move_file/$', views.move_file, name='move_file'), url(r'^delete_file/$', views.delete_file, name='delete_file'), url(r'^' + settings.S3_BROWSER_SETTINGS + '/', include('djangoS3Browser.s3_browser.urls')), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) Settings.py: AWS_ACCESS_KEY_ID = "" AWS_SECRET_ACCESS_KEY = "" AWS_STORAGE_BUCKET_NAME = "" AWS_S3_ENDPOINT_URL = "" AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False S3_BROWSER_SETTINGS = "djangoS3Browser" AWS_EXPIRY = 60 * 60 * 24 * 7 control = 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIRY, AWS_EXPIRY) AWS_HEADERS = {'Cache-Control': bytes(control, encoding='latin-1')} TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [], 'APP_DIRS': True, 'OPTIONS': { 'libraries': {'s3-load': 'djangoS3Browser.templatetags.s3-tags',}, 'context_processors': ["django.contrib.auth.context_processors.auth",'django.contrib.messages.context_processors.messages',] } } ] SECRET_KEY = 'y130-j9oz4r5aoamn_n=+s-*7n)*3^s$jmf4(qw6ik28()g^(n' DEBUG = True ALLOWED_HOSTS = ['*'] ROOT_URLCONF= 'djangoS3Browser.s3_browser.urls' LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' STATIC_URL = '{}/static/'.format(AWS_S3_ENDPOINT_URL) STATIC_ROOT = '/static/' INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'djangoS3Browser', ] WSGI_APPLICATION = 'djangoS3Browser.s3_browser.wsgi.application' MIDDLEWARE = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ) Actual result: … -
Django: NoReverseMatch 1 pattern(s) tried: ['PUTData/(?P<pk>[0-9]+)/$']
So I'm doing my first project using django showing examples of REST API methods like POST, GET, PUT, and DELETE through a made up database of first name, last name, and e-mail. I've been successful with POST and GET but now I am having trouble with PUT. So I have three functions. First, a simple def function that shows all inputs of information so far. Second a class based function that lists the information in a specific order. And third, another class based function that shows the detail of that specific information. All functions work but now when I am linking the two html files together I am getting a error. I've tried a number of different ids when wanting to link to that specific information but they are just not working. But here is my models.py: class Information(models.Model): """Placeholder code that the viewer will be seeing.""" info_id = models.AutoField(primary_key=True,unique=True) first_name = models.CharField(max_length=200) last_name = models.CharField(max_length=200) e_mail = models.CharField(max_length=200) date_added = models.DateTimeField(auto_now_add=True) def __str__(self): """Return information.""" return f"Info ID: {self.info_id}, First Name: {self.first_name}, Last Name: {self.last_name}, E-mail: {self.e_mail}" Here is my forms.py: class NameForm(forms.ModelForm): class Meta: model = Information fields = ['info_id', 'first_name', 'last_name', 'e_mail'] labels = {'first_name': 'First Name:', …