#djangomodelrelation #relation #onetoonerelation #django #djagomodels #allinonecode #djangoforeighnkey #djangocustomeusercreationform
This all in one Python Django Course video will help you learn Django from scratch with examples. This Python Django Tutorial is ideal for both beginners as well as professionals who want to master the Django Framework. Below are the topics covered in this Python Web Development Django Tutorial video
Why learn Python Django?
Django, a popular & high level python web framework, is Flat out amazing. Below are few of the reasons.
Instagram, Facebook, Disqus, Pinterest, NASA, The Washington Post and other top companies use Python with Django. For web developers, this means that mastering Python and its popular advanced frameworks like Django should ensure you’re able to find work or even build your own product or service as a startup.
Python is an ideal option for bootstrappers and startups because of its quick deployment and—as mentioned earlier—lesser amount of required code next to Java, C, and PHP among others.
Python Django framework supports the use of human-readable website URLs, which isn’t only helpful from the actual user’s perspective, but also to search engines, which use the keywords in the URL when ranking sites.
Django prevents a number of common security mistakes better than say, PHP does.
Moreover, average salary of a Django professional is $117,000 / year in US alone as reported by Indeed.com
For more information, Please write back to us at [email protected] or call us at IND: 7622858519 (toll free)
code:
from django.shortcuts import render
from sqlalchemy.sql.functions import user
from .forms import *
from .models import *
def register_fun(request):
if request.method == 'POST':
user_form = user_register_form(request.POST)
regstr_form = register_form(request.POST)
if user_form.is_valid() and regstr_form.is_valid():
users = user_form.save()
print('only user is saved...')
rg = regstr_form.save(commit=False)
rg.user = users
regstr_form.save()
print('Registration Success...')
else:
print('form is not valid...')
else:
user_form = user_register_form()
regstr_form = register_form()
context = {
'form1': user_form,
'form2': regstr_form,
}
return render(request, 'account/register.html', context)
forms.py:
from django import forms
from .models import *
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class user_register_form(forms.ModelForm):
username = forms.EmailField()
password = forms.PasswordInput()
class Meta:
model = User
fields = ['username', 'password', ]
class register_form(forms.ModelForm):
class Meta:
model = register_model
fields = ['usrname', 'name', 'phone_number', 'age']