django.shortcuts.render

Here are the examples of the python api django.shortcuts.render taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

8474 Examples 7

3 Source : views.py
with MIT License
from 0xFreddox

def read_file(request):
    f = open('static/log.txt', 'r')
    file_contents = f.read()
    if file_contents.find("space") > 0:
        f.write('\n')
    f.close()
    args = {'result' : file_contents }
    return render(request, "service/SpyActive.html", args)

3 Source : admin_views.py
with GNU Affero General Public License v3.0
from 17thshard

def index(request):
    usage = shutil.disk_usage(settings.MEDIA_ROOT)
    total_space_str = "{:.2f} Gb".format(usage.total / 1024**3)
    used_space_str = "{:.2f} Gb".format(usage.used / 1024**3)
    free_space_str = "{:.2f} Gb".format(usage.free / 1024**3)
    return render(request, 'palanaeum/admin/admin_index.html',
                  {'used_space': usage.used, 'available_space': usage.free,
                   'total_space': usage.total, 'total_space_str': total_space_str,
                   'free_space_str': free_space_str, 'used_space_str': used_space_str})


@user_passes_test(lambda u: u.is_superuser, login_url="auth_login")

3 Source : admin_views.py
with GNU Affero General Public License v3.0
from 17thshard

def related_sites_list(request):
    related_sites = RelatedSite.objects.all()
    return render(request, 'palanaeum/admin/related_sites.html', {'related_sites': related_sites})


@user_passes_test(lambda u: u.is_superuser)

3 Source : admin_views.py
with GNU Affero General Public License v3.0
from 17thshard

def related_site_edit(request, site_id: int=None):
    if site_id is not None:
        related_site = get_object_or_404(RelatedSite, pk=site_id)
    else:
        related_site = RelatedSite()

    if request.method == 'POST':
        form = RelatedSiteForm(request.POST, files=request.FILES, instance=related_site)
        if form.is_valid():
            form.save(commit=True)
            messages.success(request, _('Related site updated successfully.'))
            return redirect('admin_related_sites')
    else:
        form = RelatedSiteForm(instance=related_site)

    return render(request, 'palanaeum/admin/related_site_edit.html', {'form': form, 'related_site': related_site})


@user_passes_test(lambda u: u.is_superuser)

3 Source : admin_views.py
with GNU Affero General Public License v3.0
from 17thshard

def related_site_delete(request, site_id: int=None):
    related_site = get_object_or_404(RelatedSite, pk=site_id)
    if request.method == 'POST':
        related_site.delete()
        messages.success(request, _('Related site deleted successfully'))
        return redirect('admin_related_sites')

    return render(request, 'palanaeum/admin/delete_related_site_confirm.html', {'related_site': related_site})


@user_passes_test(lambda u: u.is_superuser)

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def remove_event(request, event_id):
    """
    Display a confirmation question, then remove the event.
    """
    event = get_object_or_404(Event, pk=event_id)

    if request.method == 'POST':
        event.delete()
        messages.success(request, _('Event has been deleted successfully.'))
        logging.getLogger('palanaeum.staff').info("%s has removed event %s.", request.user,
                                                  event.id)
        return redirect(reverse('index'))

    return render(request, 'palanaeum/staff/delete_event_confirm.html', {'event': event})


@staff_member_required(login_url='auth_login')

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def remove_entry(request, entry_id):
    """
    Display a confirmation question, then remove the entry.
    """
    entry = get_object_or_404(Entry, pk=entry_id)

    if request.method == 'POST':
        entry.delete()
        messages.success(request, _('Entry has been successfully deleted.'))
        logging.getLogger('palanaeum.staff').info("%s has removed entry %s.", request.user,
                                                  entry.id)
        return redirect('view_event_no_title', entry.event_id)

    return render(request, 'palanaeum/staff/delete_entry_confirm.html', {'entry': entry})


@staff_member_required(login_url='auth_login')

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def move_entry(request, entry_id):
    """
    Move an entry from one event to another.
    """
    entry = get_object_or_404(Entry, pk=entry_id)

    if request.method == 'POST':
        new_event = get_object_or_404(Event, pk=request.POST['event_id'])
        entry.order = Entry.objects.filter(event=new_event).order_by('-order').first().order + 1
        entry.event = new_event
        entry.save()
        messages.success(request, _("Entry moved successfully."))
        return redirect('view_event_no_title', new_event.id)

    events = Event.all_visible.all()
    return render(request, 'palanaeum/staff/move_entry.html', {'events': events, 'entry': entry})

@staff_member_required(login_url='auth_login')

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def choose_source_type(request, event_id):
    """
    Display a page where users select what type of sources they want to upload.
    """
    event = get_object_or_404(Event, pk=event_id)
    return render(request, 'palanaeum/staff/choose_source_type.html', {'event': event})


@login_required(login_url='auth_login')

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def upload_audio_page(request, event_id):
    """
    Display a page with Fine Uploader that will upload the AudioSources.
    """
    event = get_object_or_404(Event, pk=event_id)
    if request.user.is_staff:
        limit = get_config('audio_staff_size_limit')
    else:
        limit = get_config('audio_user_size_limit')
    readable_limit = "{:4.2f} MB".format(limit)
    return render(request, 'palanaeum/staff/upload_audio_page.html',
                  {'event': event, 'file_size_limit': limit * 1024 * 1024,
                   'readable_limit': readable_limit})


@login_required(login_url='auth_login')

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def upload_images_page(request, event_id):
    """
    Display a page with Fine Uploader that will upload the ImageSources.
    """
    event = get_object_or_404(Event, pk=event_id)
    limit = get_config('image_size_limit')
    readable_limit = "{:4.2f} MB".format(limit)
    return render(request, 'palanaeum/staff/upload_images_page.html',
                  {'event': event, 'file_size_limit': limit * 1024 * 1024,
                   'readable_limit': readable_limit})


@csrf_exempt

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def sort_entries_page(request, event_id):
    event = get_object_or_404(Event, pk=event_id)
    entries_ids = Entry.objects.filter(event=event).values_list('id', flat=True)
    entries = Entry.prefetch_entries(entries_ids, show_unapproved=True)
    entries = sorted(entries.values(), key=lambda e: e.order)
    return render(request, 'palanaeum/staff/sort_entries.html',
                  {'event': event, 'entries': entries, 'sources': list(event.sources_iterator())})


@staff_member_required(login_url='auth_login')

3 Source : staff_views.py
with GNU Affero General Public License v3.0
from 17thshard

def staff_cp(request):
    """
    Display a page with summary of all unapproved suggestions etc.
    """

    return render(request, 'palanaeum/staff/staff_cp.html', {'page': 'index'})


@staff_member_required(login_url='auth_login')

3 Source : views.py
with GNU Affero General Public License v3.0
from 17thshard

def index(request):
    """
    Draw the home page.
    """
    page_length = UserSettings.get_page_length(request)
    newest_events = Event.all_visible.exclude(entries=None).prefetch_related('entries', 'tags')[:page_length]

    params = {'newest_events': newest_events}
    params.update(index_stats_and_stuff())

    return render(request, 'palanaeum/index.html', params)


def about(request):

3 Source : views.py
with GNU Affero General Public License v3.0
from 17thshard

def about(request):
    """
    Display the about page.
    """
    page = AboutPage.objects.order_by('-date').first()
    params = {"about_page": page}
    params.update(index_stats_and_stuff())
    return render(request, 'palanaeum/about.html', params)


def events(request):

3 Source : views.py
with GNU Affero General Public License v3.0
from 17thshard

def show_collection_list(request):
    """
    Displays a list of user collections owned by current user.
    """
    collections = UsersEntryCollection.objects.filter(user=request.user)

    return render(request, 'palanaeum/collections/collection_list.html', {'collections': collections})


def show_collection(request, collection_id):

3 Source : views.py
with GNU Affero General Public License v3.0
from 17thshard

def untranscribed_snippets(request):
    """
    Displays a list of untranscribed snippets that aren't marked as not transcribable.

    Sorts by event.
    """
    visible_events = Event.all_visible.all()
    visible_sources = AudioSource.all_visible.filter(event__in=visible_events)
    snippets = Snippet.all_visible.filter(entry=None, optional=False, source__in=visible_sources)\
        .prefetch_related('source')

    sources = defaultdict(int)
    for snippet in snippets:
        sources[snippet.source] += 1

    sources = [(source, count) for source, count in sources.items()]
    sources.sort(key=lambda source_count: source_count[0].event.date)

    return render(request, 'palanaeum/waiting_for_transcription.html', {'sources': sources})

3 Source : tagging.py
with GNU General Public License v3.0
from 2019agriculture

def tagging(request):
	if(request.method == "POST"):
		# entity1 = request.POST.get("entity1")
		# entity2 = request.POST.get("entity2")
		# relation = request.POST.get("relation")
		# statement = request.POST.get("statement")
		post = json.loads(request.body)
		post_id = testDataCollection.insert_one(post)
		collection.delete_many( {'entity1Pos':post.get('entity1Pos') , 'entity1':post.get('entity1') ,'entity2Pos':post.get('entity2Pos'),'entity2':post.get('entity2Pos'),'relation':post.get('relation'),'statement':post.get('statement')})
		return JsonResponse({'code':200})
	else:
		while(True):
			documents_count = collection.count()
			rint = random.randint(0,documents_count-1)
			result = collection.find_one(skip = rint )
			print(result)
			if(len(result) == 7 ):
				return render(request,'taggingSentences.html',{"result": result})

3 Source : views.py
with MIT License
from 2ik

    def get(self, request, pk):
        post = Post.objects.get(id=pk)
        bound_form = TestForm(instance=post)
        return render(request, 'blog/post_update.html', {'form': bound_form, 'post': post})

    def post(self, request, pk):

3 Source : views.py
with MIT License
from 2ik

    def post(self, request, pk):
        post = Post.objects.get(id=pk)
        bound_form = TestForm(request.POST, instance=post)

        if bound_form.is_valid():
            new_post = bound_form.save()
            return redirect(new_post)
        return render(request, 'blog/post_update.html', {'form': bound_form, 'post': post})


class PostView(View):

3 Source : views.py
with MIT License
from 3bru

def home(request):
    posts=Posts.objects.all()
    return render(request, 'home.html',{
        'posts':posts,
    })
def content(request, id):

3 Source : views.py
with MIT License
from 3bru

def content(request, id):
    content = Posts.objects.get(id=id)
    return render(request, 'content.html' ,{
    'content':content,
    })

def about(request):

3 Source : views.py
with MIT License
from a1401358759

def archive_month(request, year, month):
    is_arch_month = True

    articles = Article.objects.filter(publish_time__year=year, publish_time__month=month, status=BlogStatus.PUBLISHED)  # 当前日期下的文章列表
    page_num = request.GET.get("page") or 1
    page_size = request.GET.get("page_size") or 5
    articles, total = paginate(articles, page_num=page_num, page_size=page_size)

    new_post = get_popular_top10_blogs('tmp_new_post')
    classification = get_classifications('tmp_classification')
    tag_list, music_list = get_tags_and_musics('tmp_tags', 'tmp_musics')  # 获取所有标签,并随机赋予颜色
    ads_imgs = get_carousel_imgs('tmp_ads_imgs', CarouselImgType.ADS)  # 广告轮播图
    date_list = get_date_list('tmp_date_list')

    return render(request, 'blog/index.html', locals())


def classfiDetail(request, classfi):

3 Source : views.py
with MIT License
from a1401358759

def tagDetail(request, tag):
    is_tag, articles, total = True, [], 0
    temp = Tag.objects.filter(name=tag).first()
    if temp:
        articles = temp.article_set.filter(status=BlogStatus.PUBLISHED)
    page_num = request.GET.get("page") or 1
    page_size = request.GET.get("page_size") or 5
    articles, total = paginate(articles, page_num=page_num, page_size=page_size)

    new_post = get_popular_top10_blogs('tmp_new_post')
    classification = get_classifications('tmp_classification')
    tag_list, music_list = get_tags_and_musics('tmp_tags', 'tmp_musics')  # 获取所有标签,并随机赋予颜色
    ads_imgs = get_carousel_imgs('tmp_ads_imgs', CarouselImgType.ADS)  # 广告轮播图
    date_list = get_date_list('tmp_date_list')

    return render(request, 'blog/index.html', locals())


def about(request):

3 Source : views.py
with MIT License
from a1401358759

def about(request):
    """
    关于我
    """
    new_post = get_popular_top10_blogs('tmp_new_post')
    comments = get_cache_comments(request.path)
    page_num = request.GET.get("page") or 1
    comments, total = paginate(comments, page_num=page_num)
    classification = get_classifications('tmp_classification')
    tag_list, music_list = get_tags_and_musics('tmp_tags', 'tmp_musics')  # 获取所有标签,并随机赋予颜色
    ads_imgs = get_carousel_imgs('tmp_ads_imgs', CarouselImgType.ADS)  # 广告轮播图
    date_list = get_date_list('tmp_date_list')

    return render(request, 'blog/about.html', locals())


def archive(request):

3 Source : views.py
with MIT License
from a1401358759

def archive(request):
    """
    文章归档
    """
    archive = get_archieve('tmp_archive')
    new_post = get_popular_top10_blogs('tmp_new_post')
    classification = get_classifications('tmp_classification')
    tag_list, music_list = get_tags_and_musics('tmp_tags', 'tmp_musics')  # 获取所有标签,并随机赋予颜色
    ads_imgs = get_carousel_imgs('tmp_ads_imgs', CarouselImgType.ADS)  # 广告轮播图
    date_list = get_date_list('tmp_date_list')

    return render(request, 'blog/archive.html', locals())


class RSSFeed(Feed):

3 Source : views.py
with MIT License
from a1401358759

def message(request):
    """
    主人寄语
    """
    own_messages = OwnerMessage.objects.all()
    own_message = random.sample(list(own_messages), 1)[0] if own_messages else ""  # 随机返回一个主人寄语
    date_list = get_date_list('tmp_date_list')
    classification = get_classifications('tmp_classification')
    new_post = get_popular_top10_blogs('tmp_new_post')
    tag_list, music_list = get_tags_and_musics('tmp_tags', 'tmp_musics')  # 获取所有标签,并随机赋予颜色
    ads_imgs = get_carousel_imgs('tmp_ads_imgs', CarouselImgType.ADS)  # 广告轮播图
    return render(request, 'blog/message.html', locals())


def love(request):

3 Source : views.py
with MIT License
from a1401358759

def love(request):
    from django.contrib.auth import authenticate

    name = request.POST.get('name')
    pw = request.POST.get('pw')
    user = authenticate(username=name, password=pw)
    if not user:
        return render(request, "blog/404.html")
    return render(request, "blog/love.html")


@require_GET

3 Source : views.py
with MIT License
from a1401358759

def links(request):
    """
    友情链接
    """
    links = get_links('tmp_links')
    random.shuffle(links)  # 友情链接随机排序
    new_post = get_popular_top10_blogs('tmp_new_post')
    classification = get_classifications('tmp_classification')
    tag_list, music_list = get_tags_and_musics('tmp_tags', 'tmp_musics')  # 获取所有标签,并随机赋予颜色
    ads_imgs = get_carousel_imgs('tmp_ads_imgs', CarouselImgType.ADS)  # 广告轮播图
    date_list = get_date_list('tmp_date_list')
    return render(request, 'blog/links.html', locals())


def add_comments_view(request):

3 Source : views.py
with MIT License
from a1401358759

def ownmessage_list_view(request):
    """
    主人寄语列表
    """
    messages = OwnerMessage.objects.order_by("-id")
    ownmessage_list, total = paginate(
        messages,
        request.GET.get('page') or 1
    )

    return render(request, 'manager/ownmessage_list.html', {
        "active_classes": ['.blog', '.ownmessage_list'],
        "params": request.GET,
        "data_list": ownmessage_list,
        "total": total,
    })


@login_required

3 Source : function_based.py
with MIT License
from AACEngineering

def user_index(request):
    context = {
        'users': User.objects.filter(is_superuser=False)
    }
    return render(request, 'users.html', context)


@user_passes_test(lambda u: u.is_superuser)

3 Source : function_based.py
with MIT License
from AACEngineering

def superuser_index(request):
    context = {
        'users': User.objects.filter(is_superuser=True)
    }
    return render(request, 'users.html', context)


@staff_member_required

3 Source : function_based.py
with MIT License
from AACEngineering

def permissions_index(request):
    context = {
        'views': get_views()
    }
    return render(request, 'permissions_list.html', context)


@permission_required('perm.does_not_exist')

3 Source : views.py
with MIT License
from aahnik

def index(request):
    # NOTE PUT ABSOLUTE PATH OF homePage.yaml here
    with open('__PUT ABSOLUTE PATH OF homePage.yaml here__', 'r') as file:
        homePageElements = yaml.full_load(file)
    stats = {
        'forks': 10,
        'choices': '100%',
        'participants': 200,
        'questions': '24/7'
    }
    team = TeamMember.objects.order_by('title')
    context = {'hpe': homePageElements, 'team': team, 'stats': stats}
    return render(request, 'home/index', context)


def opnsrc(request):

3 Source : views.py
with MIT License
from aahnik

def index(request):
    latest_question_list = Question.objects.order_by('-pub_date')
    context = {'latest_question_list': latest_question_list}
    return render(request, 'poll/index', context)

    # to:LEARN add pagination


def results(request, question_id):

3 Source : views.py
with MIT License
from aahnik

def results(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    return render(request, 'poll/results', {'question': question})


def vote(request, question_id):

3 Source : views.py
with MIT License
from aahnik

def vote(request, question_id):
    question = get_object_or_404(Question, pk=question_id)
    try:
        selected_choice = question.choice_set.get(pk=request.POST['choice'])
    except (KeyError, Choice.DoesNotExist):
        # Redisplay the question voting form.
        return render(request, 'poll/vote', {
            'question': question,
            'error_message': "You didn't select a choice.",
        })
    else:
        selected_choice.votes += 1
        selected_choice.save()
        # Always return an HttpResponseRedirect after successfully dealing
        # with POST data. This prevents data from being posted twice if a
        # user hits the Back button.
        return HttpResponseRedirect(reverse('poll:results', args=(question.id,)))

3 Source : views.py
with MIT License
from aaronspindler

def main_dashboard(request):
    GOOGLE_API_KEY = settings.GOOGLE_API_KEY
    try:
        houses = House.objects.filter(user=request.user)
        member_of_houses = House.objects.filter(members=request.user)
        invitations = Invitation.objects.filter(target=request.user.email)
        inquiries_received = Inquiry.objects.filter(room__house__user=request.user).filter(status='O')
        return render(request, 'dashboard/main_dashboard.html', {'houses': houses, 'member_of_houses': member_of_houses, 'invitations': invitations, 'inquiries_received': inquiries_received, 'GOOGLE_API_KEY': GOOGLE_API_KEY})
    except Exception:
        pass
    return render(request, 'dashboard/main_dashboard.html', {'GOOGLE_API_KEY': GOOGLE_API_KEY})

3 Source : views.py
with MIT License
from aaronspindler

def dog(request):
    image = get_dog_image()
    return render(request, 'eggs/dog.html', {'image': image})


def get_dog_image():

3 Source : views.py
with MIT License
from aaronspindler

def garbageday_edit(request, house):
    housemodel = get_object_or_404(House, pk=house)
    garbageday = housemodel.garbageday_set.first()
    if request.user != housemodel.user:
        raise Http404
    if request.method == 'POST':
        garbageday.last_garbage_day = datetime.datetime.strptime(request.POST['LastGarbageDay'], '%Y-%m-%d')
        garbageday.next_garbage_day = datetime.datetime.strptime(request.POST['NextGarbageDay'], '%Y-%m-%d')
        garbageday.save()
        return redirect(housemodel.get_absolute_url())
    else:
        return render(request, 'garbageday/garbageday_edit.html', {'house': housemodel, 'garbageday': garbageday})

3 Source : views.py
with MIT License
from aaronspindler

def house_detail(request, pk):
    house = get_object_or_404(House, pk=pk)
    GOOGLE_API_KEY = settings.GOOGLE_API_KEY
    is_member = False
    if request.user in house.members.all():
        is_member = True
    if request.user.id == house.user.id:
        is_member = True

    try:
        rooms = Room.objects.filter(house=house)
        return render(request, 'houses/house_detail.html', {'rooms': rooms, 'house': house, 'is_member': is_member, 'GOOGLE_API_KEY': GOOGLE_API_KEY})
    except Exception:
        pass

    return render(request, 'houses/house_detail.html', {'house': house, 'is_member': is_member, 'GOOGLE_API_KEY': GOOGLE_API_KEY})


class house_edit(LoginRequiredMixin, generic.UpdateView):

3 Source : views.py
with MIT License
from aaronspindler

def supportus(request):
    key = settings.STRIPE_KEY
    return render(request, 'main/supportus.html', {'key': key})


def verificationfeatures(request):

3 Source : views.py
with MIT License
from aaronspindler

def sandbox(request):
    if request.method == 'POST':
        print(request.POST)
        formset = BillFormset(request.POST)
        if formset.is_valid():
            for form in formset:
                print(form.cleaned_data)
        else:
            print('invalid')
    formset = BillFormset()
    return render(request, 'main/sandbox.html', {'formset': formset})

3 Source : views.py
with MIT License
from aaronspindler

def room_saved(request):
    saved_rooms = RoomLike.objects.filter(user=request.user)
    return render(request, "rooms/room_saved.html", {'saved_rooms': saved_rooms})


# PK is the primary key for the room
@login_required(login_url="account_login")

3 Source : views.py
with MIT License
from aaronspindler

def room_add_photo(request, pk):
    room = get_object_or_404(Room, pk=pk)
    if room.user == request.user:
        if request.method == 'POST':
            for file in request.FILES.getlist('files'):
                image = RoomImage()
                image.room = room
                image.user = request.user
                image.image = file
                image.save()

            return redirect('room_detail', pk=room.id)
        return render(request, 'rooms/room_add_photo.html', {'room': room})
    raise Http404


# PK is for the primary key of the photo that is getting deleted
@login_required(login_url="account_login")

3 Source : views.py
with GNU General Public License v3.0
from abaoMAO

    def get(self, request):
        user = request.user
        if user.is_authenticated:
            answer_sheets = AnswerSheet.objects.filter(judge=user.id).exclude(is_active=False)
            return render(request, "score.html", {
                "answer_sheets": answer_sheets,
            })
        else:
            return render(request, "user_login.html")


class AnswerSheetView(View):

3 Source : views.py
with GNU General Public License v3.0
from abaoMAO

    def get(self, request, as_code):
        user = request.user
        if user.is_authenticated:
            answer_sheet = AnswerSheet.objects.get(id=as_code)
            questionnaire = answer_sheet.questionnaire
            questions = questionnaire.question_set.all()
            return render(request, "answer_sheet.html", {
                "answer_sheet": answer_sheet,
                "questionnaire": questionnaire,
                "questions": questions,
            })
        else:
            return render(request, "user_login.html")

    def post(self, request, as_code):

3 Source : views.py
with GNU General Public License v3.0
from abaoMAO

    def post(self, request, as_code):
        user = request.user
        if user.is_authenticated:

            answer_sheets = AnswerSheet.objects.filter(judge=user.id).exclude(is_active=False)
            return render(request, "score.html", {
                "answer_sheets": answer_sheets,
            })
        else:
            return render(request, "user_login.html")

3 Source : views.py
with GNU General Public License v3.0
from abaoMAO

    def post(self, request):
        login_form = LoginForm(request.POST)
        if login_form.is_valid():
            user_name = request.POST.get("username", "")
            pass_word = request.POST.get("password", "")
            user = authenticate(username=user_name, password=pass_word)
            if user is not None:
                if user.is_active:
                    login(request, user)
                    return HttpResponsePermanentRedirect(reverse('index'))
                else:
                    return render(request, "user_login.html", {"msg": "邮箱未激活"})
            else:
                return render(request, "user_login.html", {"msg": "用户名或密码错误"})
        else:
            return render(request, "user_login.html", {"login_form": login_form})


class RegisterView(View):

3 Source : views.py
with MIT License
from abrookins

def signup(request):
    if request.method == 'POST':
        form = UserCreationForm(request.POST)
        if form.is_valid():
            form.save()
            username = form.cleaned_data.get('username')
            raw_password = form.cleaned_data.get('password1')
            user = authenticate(username=username, password=raw_password)
            login(request, user)
            return redirect('/')
    else:
        form = UserCreationForm()
    return render(request, 'account/signup.html', {
        'form': form,
        'login_url': '/accounts/login'
    })

See More Examples