'Get PageForm for the Page model and modify its fields depending on
the request.'

def get_form(self, request, obj=None, **kwargs):

    language = get_language_from_request(request, obj)
    form_cls = self.get_form_class(request, obj)
    form = super(PageAdmin, self).get_form(request, obj, form=form_cls, **kwargs)
    for field in form.base_fields.keys():
        form.base_fields[field] = copy.deepcopy(form.base_fields[field])
    if ('language' in form.base_fields):
        form.base_fields['language'].initial = language
    if ('page_type' in form.base_fields):
        if (('copy_target' in request.GET) or ('add_page_type' in request.GET) or obj):
            del form.base_fields['page_type']
        elif (not Title.objects.filter(page__parent__reverse_id=PAGE_TYPES_ID, language=language).exists()):
            del form.base_fields['page_type']
    if ('add_page_type' in request.GET):
        del form.base_fields['menu_title']
        del form.base_fields['meta_description']
        del form.base_fields['page_title']
    if obj:
        title_obj = obj.get_title_obj(language=language, fallback=False, force_reload=True)
        if (('site' in form.base_fields) and (form.base_fields['site'].initial is None)):
            form.base_fields['site'].initial = obj.site
        for name in ('slug', 'title', 'meta_description', 'menu_title', 'page_title', 'redirect'):
            if (name in form.base_fields):
                form.base_fields[name].initial = getattr(title_obj, name)
        if ('overwrite_url' in form.base_fields):
            if title_obj.has_url_overwrite:
                form.base_fields['overwrite_url'].initial = title_obj.path
            else:
                form.base_fields['overwrite_url'].initial = ''
    else:
        for name in ('slug', 'title'):
            form.base_fields[name].initial = u''
        if (('target' in request.GET) or ('copy_target' in request.GET)):
            target = (request.GET.get('copy_target') or request.GET.get('target'))
            if ('position' in request.GET):
                position = request.GET['position']
                if ((position == 'last-child') or (position == 'first-child')):
                    form.base_fields['parent'].initial = request.GET.get('target', None)
                else:
                    sibling = self.model.objects.get(pk=target)
                    form.base_fields['parent'].initial = sibling.parent_id
            else:
                form.base_fields['parent'].initial = request.GET.get('target', None)
        form.base_fields['site'].initial = request.session.get('cms_admin_site', None)
    return form
