Django community: RSS
This page, updated regularly, aggregates Django Q&A from the Django community.
-
ValueError for default value of integerfield in django production
In the production(server) on the command migrate I am getting an error ValueError: Field 'price' expected a number but got ''. But the problem is that the default value of that integer field is not "" its 0 a number. class Product(models.Model): ZKSOKS = [ ('zks', 'Зкс'), ('oks', 'Окс'), ] title = models.CharField(max_length=250, unique=True) price = models.IntegerField(default=0) sort = models.CharField(max_length=250, null=True, blank=True) uraj = models.CharField(max_length=250, null=True, blank=True) age = models.IntegerField(null=True, blank=True) zks = models.CharField(max_length=20, choices=ZKSOKS, null=True, blank=True) description = models.TextField(null=True, blank=True) image = models.ImageField(null=True, blank=True, upload_to='product_img') slug = models.SlugField(unique=True, blank=True) def __str__(self): return self.title def save(self, *args, **kwargs): self.slug = defaultfilters.slugify(unidecode(self.title)) super().save(*args, **kwargs) -
Django REST Framework always return Bad Request but it does log me into the Django admin
I'm using Django 2.1.5 and djangorestframework 3.9.2. The app is deployed using docker. The application works in local but not in production, I have set up ALLOWED_HOSTS = ['*'] and DEBUG = False. So, every request to log in using REST Framework API returns 400 BAD REQUEST (credentials are OK), but if I go to the Django admin, it shows that I successfully logged in (this differs from the API response). And as I said before in local environment the app behaves as expected. Note: I didn't create the initial app, nor I created the docker config files. But I have checked and it seems to be something going on with Django. -
Django query to keep perticular item at first and then apply order_by to rest of the items
Let say we have an Article model. class Article(models.Model): id = int name = char i want to get all the articles but the article with name = "stackoverflow" should be the first item in queryset and apply order_by to rest of the items. eg .order_by("name"). what i've achieved so far is queryset = Article.objects.all().order_by("name") stackoverflow = queryset.get(name="stackoverflow") query = queryset.exclude(name="stackoverflow") articles = [] articles.extend(stackoverflow) articles.extend(query) But this hits the database atleast 5 times. Can we do this in a better way? -
create an appointment app with registered and non registered user in Django
I want to create an appointment app with Django with the following condition: if the user is a patient it will show him a template like this if the user is a doctor or reception it will give him a choice the first the patient is register and show him a template like this : the patient is not registered, it will show him a template like this : this is my fomrs.py class AppointementForm(ModelForm): class meta: model = Appointement_P fields = ('doctor', 'date', 'start_time', 'end_time') class AppointementForm_2(ModelForm): class meta: model = Appointement_P fields = ('patient', 'doctor', 'date', 'start_time', 'end_time') class UserEditForm(forms.ModelForm): class Meta: model = User fields = ('first_name', 'last_name', 'email') GENDER_CHOICES = (('M', 'Male'), ('F', 'Female'),) class ProfileUpdateForm(forms.ModelForm): gender = forms.ChoiceField(choices=GENDER_CHOICES, required=False, widget=forms.RadioSelect) class Meta: model = Profile fields = ('date_of_birth', 'gender', 'phone_number', 'blood_group', 'address', 'photo') and models.py class User(AbstractUser): STATUS_CHOICES = (('paitent', 'paitent'), ('Doctor', 'Doctor'), ('reception', 'reception'), ('temporary', 'temporary')) STATUS_CHOICES_2 = (('yes', 'yes'), ('no', 'no')) type_of_user = models.CharField(max_length=200, choices=STATUS_CHOICES, default='paitent') allowd_to_take_appointement = models.CharField(max_length=20, choices=STATUS_CHOICES_2, default='yes') def is_doctor(self): if self.type_of_user == 'Doctor': return True else: return False class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) date_of_birth = models.DateField(blank=True, null=True) gender = models.CharField(max_length=1, choices=GENDER_CHOICES) phone_number = PhoneNumberField(blank=True) blood_group = models.CharField(choices=BLOOD_GROUPS, max_length=3, … -
How can I constrain a ManyToMany to only associate objects with the same parent universe in a declarative way?
I have two django models that I need to link together many-to-many, but I only want to allow linking between two models if they are "compatible", having the same value for their parent universe. As a toy code example: from django.db import models class Universe(models.Model): pass class Foo(models.Model): universe = models.ForeignKey(Universe, on_delete=models.CASCADE) bars = models.ManyToManyField('Bar', related_name='foos', through='FooBarLinkage') class Bar(models.Model): universe = models.ForeignKey(Universe, on_delete=models.CASCADE) foos = models.ManyToManyField('Foo', related_name='bars', through='FooBarLinkage') class FooBarLinkage(models.Model): foo = models.ForeignKey(Foo, on_delete=models.CASCADE) bar = models.ForeignKey(Bar, on_delete=models.CASCADE) (Note that I'm not trying to use the universes as some kind of security boundary; this is just an attempt to capture and validate an additional detail about the problem domain I'm using these objects to describe.) I know how I'd add this constraint non-portably using SQL, and I could add python validation code that checks this on save, but that requires re-expressing this constraint several times and writing code to handle implementation differences between different databases. How can I instead express this constraint declaratively with the Django ORM? Note that in addition to having the database constraint and python validation automatically generated, an ideal solution would also allow me to implement browser-side javascript admin panel widgets for the foo and bar … -
How to store VideoIntelligence Speech Transcription data in MySQL for best text searching strategy
The following Django/Python implementation provides the results from VideoIntelligence for speech transcription data for a video stored in Google Cloud Storage : video_client = videointelligence.VideoIntelligenceServiceClient() features = [enums.Feature.SPEECH_TRANSCRIPTION] config = videointelligence.types.SpeechTranscriptionConfig( language_code = "en-GB", enable_automatic_punctuation=True, ) context = videointelligence.types.VideoContext( segments=None, speech_transcription_config=config, ) operation = video_client.annotate_video(gs_video_path, features=features, context) Below is the sample output from that operation : [alternatives { transcript: "Word1 Word2 Word3 Word4 Word5 Word6 Word7 Word8 Word9 Word10" confidence: 0.9206268787384033 words { start_time { } end_time { seconds: 2 } word: "Word1" } words { start_time { seconds: 2 } end_time { seconds: 2 nanos: 200000000 } word: "Word2" } words { start_time { seconds: 2 nanos: 200000000 } end_time { seconds: 2 nanos: 300000000 } word: "word3" } And so on .... How should I store them on my PostGreSQL database for best access strategy to answer search operations such as : Find Word1 Find Word2 Word3 Find Word3 Word4 Word5 Find Word7 Word8 Word9 Word10 Find Word8 Word10 Which will correspondingly return the timestamp of Word1, Word2, Word3 & Word7, None. Should I store all transcript as a single entity and timestamps for words seperately ? Should I store all words separately and in the case of … -
creating user-profile using DRF
i want to creating an api for user registration & user-profile using drf, i'm using my custom user model and also created profile model but i'm getting a TypeError: Field 'id' expected a number but got <django.contrib.auth.models.AnonymousUser object at 0x7f8d6a2a7220> error below is my code snippet #profile-model class Profile(models.Model): user = models.OneToOneField(CustomUser, on_delete=models.CASCADE) school_name = models.CharField(max_length=255) address = models.TextField() badge = models.ImageField(upload_to='assets/badge', blank=True, null=True) school_type = models.CharField(max_length=50, choices=Type) gender = models.CharField(max_length=20, choices=Gender) level = models.CharField(max_length=40, choices=Level) state = models.CharField(max_length=100) date_established = models.DateTimeField(blank=True, null=True) curriculum = models.CharField(max_length= 255) ###profile-serializer class schoolProfileSerializer(serializers.ModelSerializer): parser_classes = (MultiPartParser, FormParser, ) id = serializers.IntegerField(source='pk', read_only=True) email = serializers.CharField(source='user.email', read_only=True) username = serializers.CharField(source='user.username', read_only=True) user = serializers.CharField(source='user.username', read_only=True) badge = Base64Imagefield(max_length=None, use_url=True) date_established = serializers.DateField(format=None,input_formats=None) class Meta: model = Profile fields = ( 'email', 'id', 'username', 'school_name', 'address', 'badge', 'gender', 'level', 'website', 'clubs', 'school_phone_number', 'school_type' ) def create(self, validated_data, instance=None): if 'user' in validated_data: user = validated_data.pop('user') else: user = CustomUser.objects.create(**validated_data) profile = Profile.objects.update_or_create(user=user, **validated_data) return profile ##profile-apiView class CreateProfileView(generics.CreateAPIView): parser_classes = (MultiPartParser,) serializer_class = schoolProfileSerializer queryset = Profile.objects.all() permission_classes = [permissions.AllowAny] def perform_create(self, serializer): serializer.save(user=self.request.user) ###user-registration apiView class RegistrationAPIView(APIView): permission_classes = [AllowAny] serializer_class = RegistrationSerializer def post(self, request, format=None): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) serializer.save() return Response( … -
why im getting thsi adsense warning
whenever I'm inspecting my Django websites this warning shows up why I'm getting this warning on my website? what does it mean? show_ads_impl_fy2019.js:343 Non-ASCII characters in origin. (anonymous) @ show_ads_impl_fy2019.js:343 -
Different outputs reading the same pdf file on different machines (with python textract.process())
I wrote a program (part of a django web app) that's extracting text from pdf file using textract.process(path_to_file). I managed to get it to work fine on my local machine (outputs are consistent - for different pdf files I'm always getting similar outputs that I'm using later in the process.). When I deployed the code to production, the outputs are different. Lines extracted from pdf are displayed in different order on my local pc and on production server (checked on the same version of python - only gcc is 1 version lower, but i don't think it's the case). Have anyone had similar problem with textract? import textract text_lines = textract.process(filepath).decode('utf-8').split('\n') for i in range(0, len(text_lines)): print(f'{i}, {text_lines[i]}') -
Microsoft 365 ics file issue while sending last name with ','
From my django application I'm sending emails to customers. Gmail, outlook are working fine but in Outlook 365 if the last name contains ',' it is breaking and showing as '/' in mail view and also in ics file. Is outlook 365 cannot parse ',' in first name and last name? -
Download generated excel file using xslxwriter on Python(Django)
I am working with Python using the Django framework, at this moment I am generating some reports in Excel, for that I use the xslxwriter library, the user tries to download the file from the platform, I do not get the download and instead it The answer is strange characters, I think that's the Excel file, anyway I don't know how to make that file download. This snippet is the one that is supposed to download the file workbook.close() output.seek(0) response = HttpResponse(output.read(), content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet") response['Content-Disposition'] = "attachment; filename=test.xlsx" output.close() return response This is the response I get from the frontend Thank you very much in advance. -
TypeError: create_superuser() missing 1 required positional argument: 'username'
I am using Django REST Framework and Django for creating a user auth endpoint. I now have the following error, whenever I try to create a super user. Here is my code: from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager from django.contrib.auth.models import UserManager from django.db import models import time # Create your models here. class MyAdmin(BaseUserManager): def create_user(self, username, first_name, last_name, email, password, **kwargs): if(not email): raise ValueError("No Email Provided!") user = self.model(first_name, last_name, email, **kwargs) user.is_admin = False user.is_superuser = False user.is_staff = False user.is_active = True user.set_password(password) user.save() return user def create_superuser(self, username, first_name, last_name, email, password, **kwargs ): kwargs.setdefault('is_staff', True) kwargs.setdefault('is_superuser', True) kwargs.setdefault('is_active', True) if(kwargs.get('is_staff') is not True): raise ValueError("Super User must be a staff in order to be in!") if(kwargs.get('is_superuser') is not True): raise ValueError("User must be a SuperUser!") if(kwargs.get('is_active') is not True): raise ValueError("Super User must be active!") user = self.model(email= email) user.is_admin = True user.is_superuser = True user.is_staff = True user.is_active = True user.set_password(password) user.save() return user class MyUser(AbstractBaseUser): first_name = models.CharField(max_length= 200, blank= False) last_name = models.CharField(max_length= 200, blank= False) email = models.EmailField(unique= True, blank= False) phone_number = models.IntegerField() company_name = models.CharField(max_length= 200, blank= False) date_joined = models.DateTimeField(auto_now= True) last_login = models.DateTimeField(auto_now= True, null= False) … -
Commenting on a comment django
I am currently working on a blog app with django handling the backend. I want users to be able to comment on comments .. for this I tried using two generic views for the same view class like PostListView(CreateView, ListView) which is kind of weird. But I kept on getting integrity errors for the id of the posts. Is there any better way to implement this functionality?? Thanks in advance. -
How do you make sync_to_async work in a one to one model in django?
I made a model for users of my website which contains a one to one field with the model user. I'm using the model because I was intstructed to make it but now i cannot use it to send messages in my chat app as it isn't sync_to_async. Is there a way to make the function async? Or is it possible to make it so changes to to member model affect the changes to user model. Model.py: class Member(TimeStamped): user = models.OneToOneField(User,on_delete=models.CASCADE) username=models.CharField(max_length=200,unique=True,default="") email=models.CharField(max_length=200,default="") password=models.CharField(max_length=200,default="") profile_pic = models.ImageField(default='uploads/default.png') def __str__(self): return self.username[:80] The code that doesn't work with the member model. If im just using the normal user model it works. consumers.py: from channels.generic.websocket import AsyncJsonWebsocketConsumer import json from django.contrib.auth import get_user_model User = get_user_model() async def send_message(self,message): await self.channel_layer.group_send( "tribe_chatroom_1", { "type": "chat.message", "profile_image": self.scope["user"].member.profile_pic.url, "username": self.scope["user"].member.username, "user_id": self.scope["user"].member.id, "message": message, } ) async def chat_message(self, event): """ Called when someone has messaged our chat. """ # Send a message down to the client print("TribeChatConsumer: chat_message from user #" + str(event["user_id"])) await self.send_json( { "profile_image": event["profile_image"], "username": event["username"], "user_id": event["user_id"], "message": event["message"], }, ) -
Django question on assigning the created news/team to the user who created it
please help me with one question, if possible. I have a profile model that has a OneToOneField to User and there is a team field in the Profile model, there is also a Team model with a name, tag, etc. I would like to ask how to make the user who creates the team immediately be in it, so that the team field of the Profile model is assigned this team automatically, so that he is its creator and captain immediately. Maybe someone can help, explain, throw a banal example for understanding. The creation was done like this, in a separate application. But I don't understand how to give the browser the created tim. models.py from django.db import models from django.contrib.auth.models import User from slugify import slugify from django.urls import reverse class BaseModel(models.Model): objects = models.Manager() class Meta: abstract = True class Profile(BaseModel): user = models.OneToOneField( User, on_delete=models.CASCADE, null=True, blank=True ) nickname = models.CharField(max_length=30, unique=True, null=True) team = models.ForeignKey('Team', on_delete=models.SET_NULL, blank=True, null=True) def save(self, *args, **kwargs): super(self.__class__, self).save(*args, **kwargs) if self._state.adding is True: Profile.objects.create() def __str__(self): return self.nickname class Meta: verbose_name = "Автор" verbose_name_plural = "Авторы" class Team(BaseModel): name = models.CharField('Название', max_length=50) tag = models.CharField('Тег', max_length=16, unique=True) slug = models.SlugField(unique=True, … -
Django delete records that sum up to a given value
Is there a simple way to delete records from a table that sum up to a given value? I have created a fintech app used to manage loan repayments and share holders in the company. Some shareholders would like to repay loans by their shares being deducted. How can I put a script that whenever the app user enters the share value to be deducted, the random share records of an individual aggregating or annotating to that input value are the only ones deleted? What i have tried in views.py `class ShareLoanProgressPaymentView(View, BaseObject): def post(self, *args, **kwargs): member_id = self.get_memberobject(kwargs['id']) loan = self.get_object(kwargs['id'])[0] _paid = self.request.POST['paid'] #number of shares to be deducted totals1 = Share.objects.filter(member_id=loan.member_id)[:(int(_paid)/2)].values_list('id', flat =True) totals = Share.objects.filter(member_id=loan.member_id)[:int(_paid)].values_list('id', flat =True) #totals = Share.objects.values('member_id')[int(_paid):].values_list('id', flat =True) while (int(_paid)) >= 0: Share.objects.filter(id__in=list(totals1)).delete() _paid = int(_paid) - 1 break` This seems to be deleting records basing on id. What I am trying to achieve is delete records that sum up to a given value(entry from form) -
Django Crispy Forms Layout Not Working Inside forms.Modelform
I've gotten CrispyForms to load a custom layout when using a form inside the generic CreateView, as shown below: class editEvent(UpdateView): model = Event fields = [field.name for field in model._meta.fields if field.name not in 'organization'] template_name = 'event_edit_modal.html' def get_success_url(self): org = self.request.user.profile.organization.url_name messages.success(self.request, 'Success: event updated.') return reverse('manage', kwargs={'org_name':org}) def get_form(self): form = super().get_form() form.fields['location'].queryset = Location.objects.filter(organization=Organization.objects.get(url_name=self.request.user.profile.organization.url_name)) form.fields['event_group'].queryset = EventGroup.objects.filter(organization=Organization.objects.get(url_name=self.request.user.profile.organization.url_name)) form.fields['register_start'].widget = DateTimePickerInput() form.fields['register_end'].widget = DateTimePickerInput() form.fields['start'].widget = DateTimePickerInput() form.fields['end'].widget = DateTimePickerInput() form.helper = FormHelper() form.helper.add_input(Submit('submit', 'Update', css_class='btn-primary')) form.helper.layout = Layout( Row( Column('name', css_class='col-8'), Column('event_group', css_class='col-4'), ), 'location', Row( Column('start'), Column('end'), ), Row( Column('register_start'), Column('register_end'), ), 'details', 'team_event', Row( Column('min_team_members'), Column('max_team_members'), ), ) return form However, inside a different form I'm needing to render the CrispyForms layout inside a forms.Modelform. However, for some reason the layout is being loaded. The help_texts, loaded by Django are loading, but the FormHelper layout is not: class organizationForm(forms.ModelForm): allowed_email_domains = forms.CharField(max_length=40) owner_email = forms.EmailField(max_length=254) owner_first_name = forms.CharField(max_length=60) owner_last_name = forms.CharField(max_length=60) owner_password = forms.CharField(widget=forms.PasswordInput()) confirm_owner_password = forms.CharField(widget=forms.PasswordInput()) class Meta: model = Organization fields = ['name', 'url_name', 'about_text'] def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['allowed_email_domains'].help_text = 'Optionally restrict users joining your organization to certain email domains. Example input: college.edu (do not include @ symbol)' … -
value is not in range with pandas
here is my code : import pandas as pd tmp_data=pd.read_csv("../data/geo/public.geo_commune.csv",sep=';') #id;created;uuid;modified;name;geohash_file;gps_lat_file;gps_long_file;geohash_bing;gps_lat_bing;gps_long_bing;geohash_goog;gps_lat_goog;gps_long_goog;code_insee;code_cadastre;code_postal;departement;region;code_postal2 print(tmp_data[tmp_data['id'] == 6217]) communes = [ Commune( id = tmp_data.loc[row]['id'], uuid = tmp_data.loc[row]['uuid'], name = tmp_data.loc[row]['name'], geohash_file = tmp_data.loc[row]['geohash_file'], gps_lat_file = tmp_data.loc[row]['gps_lat_file'], gps_long_file = tmp_data.loc[row]['gps_long_file'], code_insee = tmp_data.loc[row]['code_insee'], code_postal = tmp_data.loc[row]['code_postal'], code_postal2 = tmp_data.loc[row]['code_postal2'], ) for row in tmp_data['id'] ] Commune.objects.bulk_create(communes) I have this error : Traceback (most recent call last): File "/home/bussiere/.local/share/virtualenvs/GeoTransport-6Rxd3Krq/lib/python3.7/site-packages/pandas/core/indexes/range.py", line 351, in get_loc return self._range.index(new_key) ValueError: 6217 is not in range The above exception was the direct cause of the following exception: Traceback (most recent call last): File "importPandasGeo.py", line 34, in for row in tmp_data['id'] File "importPandasGeo.py", line 34, in for row in tmp_data['id'] File "/home/bussiere/.local/share/virtualenvs/GeoTransport-6Rxd3Krq/lib/python3.7/site-packages/pandas/core/indexing.py", line 895, in getitem return self._getitem_axis(maybe_callable, axis=axis) File "/home/bussiere/.local/share/virtualenvs/GeoTransport-6Rxd3Krq/lib/python3.7/site-packages/pandas/core/indexing.py", line 1124, in _getitem_axis return self._get_label(key, axis=axis) File "/home/bussiere/.local/share/virtualenvs/GeoTransport-6Rxd3Krq/lib/python3.7/site-packages/pandas/core/indexing.py", line 1073, in _get_label return self.obj.xs(label, axis=axis) File "/home/bussiere/.local/share/virtualenvs/GeoTransport-6Rxd3Krq/lib/python3.7/site-packages/pandas/core/generic.py", line 3739, in xs loc = index.get_loc(key) File "/home/bussiere/.local/share/virtualenvs/GeoTransport-6Rxd3Krq/lib/python3.7/site-packages/pandas/core/indexes/range.py", line 353, in get_loc raise KeyError(key) from err KeyError: 6217 but this line works well : print(tmp_data[tmp_data['id'] == 6217]) and it gaves me : id created uuid ... departement region code_postal2 1795 6217 2020-01-08 17:20:08.091659+01 78DA163B1494401CBD6832AF048406FF257 ... NaN NaN NaN [1 rows x 20 columns] -
Django Admin Panel Custom header for some of the tables under the app name header
In the Django Admin panel, all the models(database tables) are displayed under the App name header. I need to separate out some of the tables under the app name. In the attached Image we can see the App name "SR" as a separator for the two tables which are present in the same "SR" application. I need to add two more header under the "SR" and add add two different tables under the two headers. Example: "SR" is the main application name(Main header name), "Sr1" is the one header under the "SR" app. In that "Sr1" i will add "Sr Choices" model present in the attached screenshot. and "Sr2" is another header under the "SR" app. need to display rest of the models present in the "SR" application. Is there any way to customize the admin panel based on my requirement. or Is any there any options in the existing djnago admin panel to satisfy my requirements. -
Creating a pgadmin server (for viewing database) from django app
I am creating a django project where I need to link pgadmin viewer with my app. Currently I am starting a pgamin server seprately and then using " > in the html page i have linked the server. Is there a way to start the server inside django itself and link it? -
How to implement bulk deletion in Django Rest Framework
Could someone explain how this could be achieved? Somehow passing in ids to the delete request and somehow delete instances using the ids. -
Django Channels - Real time Notifications
Suppose, if user is online, websocket connection is created and user will get all the realtime notification. But, if user went offline, websocket connection breaks, then if any realtime notification has to be delivered during offline period, will it be again delivered if user comes online again(means when websocket connection is made again of that user)?? -
Does the pre ping feature in SqlAlchemy db pools automatically reconnect and send the SQL command in case the pre ping check fails?
I want some clarification on how the pre ping feature exactly works with SqlAlchemy db pools. Let's say I try to make a SQL query to my database with the db pool. If the db pool sends a pre ping to check the connection and the connection is broken, does it automatically handle this? By handling I mean that it reconnects and then sends the SQL query? Or do I have to handle this myself in my code? Thanks! -
Is there any library like arch unit for Django?
I've been searching for a library or tool to test my Django project architecture, check the dependencies, layers, etc. like Arch Unit for Java. But until now, I didn't find anything. I even don't know if is viable doing these kinds of tests in Python/Django projects. I know that Django itself already checks for cyclic dependencies. -
Django: Can I edit other profile info while logging in different user?
the below codes are from views.py, there's no error in that. It just that the code below can only edit the info of the 'logged in' user. What I want is to edit other user info using 'admin user' what I know is editing a data depends on "instance=request.user" from "form = UserEditForm(request.POST, instance=request.user)" can I change the "request.user" to the user I wanted to edit the info without login it?? Take the 'elton' username from the below image of dashboard as example. I'm logged in as another user but I wanted to edit the 'elton' row without login it. Is that possible? dashboard data def edit_profile(request): if 'established' in request.session: return redirect('bhome') elif not 'logged_in' in request.session: return redirect('login') else: if request.method == 'POST': form = UserEditForm(request.POST, instance=request.user) email = request.POST['email'] palotype = request.POST['palotype'] suffix = request.POST['suffix'] first_name = request.POST['first_name'] middle_name = request.POST['middle_name'] last_name = request.POST['last_name'] birth_date = request.POST['birth_date'] region = request.POST['region'] city = request.POST['city'] barangay = request.POST['barangay'] unitno = request.POST['unitno'] floorno = request.POST['floorno'] bldgname = request.POST['bldgname'] housebldgno = request.POST['housebldgno'] streetname = request.POST['streetname'] villagedistrict = request.POST['villagedistrict'] mobileno = request.POST['mobileno'] landline = request.POST['landline'] context= {'email': email, 'palotype':palotype, 'suffix':suffix, 'first_name':first_name, 'middle_name':middle_name, 'last_name':last_name, 'birth_date':birth_date, 'region':region, 'city':city, 'barangay':barangay, 'unitno':unitno, 'floorno':floorno, 'bldgname':bldgname, 'housebldgno':housebldgno, 'streetname':streetname, …