当前位置: 首页>>代码示例>>Python>>正文


Python FlatPage.content方法代码示例

本文整理汇总了Python中django.contrib.flatpages.models.FlatPage.content方法的典型用法代码示例。如果您正苦于以下问题:Python FlatPage.content方法的具体用法?Python FlatPage.content怎么用?Python FlatPage.content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django.contrib.flatpages.models.FlatPage的用法示例。


在下文中一共展示了FlatPage.content方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):
        # create flat page
        page = FlatPage()
        page.url = '/about/'
        page.title = 'About me'
        page.content = 'All about me'
        page.save()

        # add the site
        page.sites.add(Site.objects.all()[0])
        page.save()

        # check new page saved
        all_pages = FlatPage.objects.all()
        self.assertEquals(len(all_pages),1)
        only_page = all_pages[0]
        self.assertEquals(only_page, page)

        # check data correct
        self.assertEquals(only_page.url, '/about/')
        self.assertEquals(only_page.title, 'About me')
        self.assertEquals(only_page.content, 'All about me')

        # get url
        page_url = str(only_page.get_absolute_url())

        # get the page
        response = self.client.get(page_url)
        self.assertEquals(response.status_code, 200)

        # check title and content in response
        self.assertTrue('About me' in response.content)
        self.assertTrue('All about me' in response.content)
开发者ID:jwillet1,项目名称:djangoblog,代码行数:35,代码来源:tests.py

示例2: handle

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def handle(self, *args, **options):

        try:
            site = Site.objects.get()
        except Site.DoesNotExist:
            site = Site()
        if args:
            if len(args) > 1:
                raise CommandError('Command accept at most one parameter.')
            site.domain = args[0]
            site.name = args[0]
        else:
            hostname = get_host_name()
            site.domain = hostname
            site.name = hostname
        site.save()

        try:
            page = FlatPage.objects.get(url='/getting-started/')
            page.sites = [site]
            page.save()
        except FlatPage.DoesNotExist:
            page = FlatPage(url='/getting-started/', title='Getting Started', registration_required=False)
            page.content = 'Go to admin panel to change welcome message!'
            page.save()
            page.sites = [site]
            page.save()
开发者ID:stfc,项目名称:cvmfs-stratum-uploader,代码行数:29,代码来源:init_flatpages.py

示例3: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):
        # create a flat page
        page = FlatPage()
        page.url = '/about/'
        page.title = 'About me'
        page.content = 'All about me'
        page.save()
        page.sites.add(Site.objects.all()[0])
        page.save()

        # check the new page is saved
        all_pages = FlatPage.objects.all()
        self.assertEqual(len(all_pages), 1)
        only_page = all_pages[0]
        self.assertEqual(only_page, page)

        # check the data of the page
        self.assertEquals(only_page.url, page.url)
        self.assertEquals(only_page.title, page.title)
        self.assertEquals(only_page.content, page.content)

        # check the page url
        page_url = only_page.get_absolute_url()
        response = self.client.get(page_url)
        self.assertEquals(response.status_code, 200)
开发者ID:salmanwahed,项目名称:django_blog_ng,代码行数:27,代码来源:tests.py

示例4: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):
        # Create flat page
        page = FlatPage()
        page.url = "/about/"
        page.title = "About me"
        page.content = "All about me"
        page.save()

        # Add the site
        page.sites.add(Site.objects.all()[0])
        page.save()

        # Check new page saved
        all_pages = FlatPage.objects.all()
        self.assertEquals(len(all_pages), 1)
        only_page = all_pages[0]
        self.assertEquals(only_page, page)

        # Check data correct
        self.assertEquals(only_page.url, "/about/")
        self.assertEquals(only_page.title, "About me")
        self.assertEquals(only_page.content, "All about me")

        # Get URL
        page_url = str(only_page.get_absolute_url())

        # Get the page
        response = self.client.get(page_url)
        self.assertEquals(response.status_code, 200)

        # Check title and content in response
        self.assertTrue("About me" in response.content)
        self.assertTrue("All about me" in response.content)
开发者ID:Zna12,项目名称:blog-project,代码行数:35,代码来源:tests.py

示例5: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):
        page = FlatPage()
        page.url = '/about'
        page.title = 'About me'
        page.content = "All about me"
        page.save()

        page.sites.add(Site.objects.all()[0])
        page.save()

        all_pages = FlatPage.objects.all()
        self.assertEqual(len(all_pages), 1)
        only_page = all_pages[0]
        self.assertEqual(only_page, page)

        self.assertEquals(only_page.url, '/about')
        self.assertEquals(only_page.title, 'About me')
        self.assertEquals(only_page.content, 'All about me')

        page_url = reverse(
            'django.contrib.flatpages.views.flatpage',
            kwargs={'url': 'about'}
        )

        response = self.client.get(page_url)
        self.assertEqual(response.status_code, 200)

        self.assertTrue('About me' in response.content)
        self.assertTrue('All about me' in response.content)
开发者ID:dttt,项目名称:blog_tutorial,代码行数:31,代码来源:tests.py

示例6: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):
        page = FlatPage()
        page.url = '/about/'
        page.title = 'about me'
        page.content = 'something about me'
        page.save()

        page.sites.add(Site.objects.all()[0])
        page.save()

        all_pages = FlatPage.objects.all()
        self.assertEquals(len(all_pages),1)
        self.assertEqual(all_pages[0],page)

        p = all_pages[0]
        self.assertEquals(p.url,page.url)
        self.assertEquals(p.title,page.title)
        self.assertEquals(p.content,page.content)

        p_url = p.get_absolute_url()

        r = self.client.get(p_url)
        self.assertEquals(r.status_code,200)
        self.assertTrue(page.title in r.content)
        self.assertTrue(page.content in r.content)
开发者ID:paulw54jrn,项目名称:blog_tutorial,代码行数:27,代码来源:tests.py

示例7: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):

        page = FlatPage()
        page.url = '/about/'
        page.title = 'About me'
        page.content = 'All about me'
        page.save()

        page.sites.add(Site.objects.all()[0])
        page.save()

        all_pages = FlatPage.objects.all()
        self.assertEquals(len(all_pages), 1)
        only_page = all_pages[0]
        self.assertEquals(only_page, page)

        self.assertEquals(only_page.url, '/about/')
        self.assertEquals(only_page.title, 'About me')
        self.assertEquals(only_page.content, 'All about me')

        page_url = only_page.get_absolute_url()

        response = self.client.get(page_url)
        self.assertEquals(response.status_code, 200)

        self.assertTrue('About me' in response.content)
        self.assertTrue('All about me' in response.content)
开发者ID:thanley11,项目名称:tomblog,代码行数:29,代码来源:tests.py

示例8: newpage

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
def newpage(request, url):
    """
    New Flat page wiki view.

    template hardcoded for now
    """

    if not request.user.is_authenticated():
        raise Http404
    
    from urlparse import urlparse
    # if referer then use it or default '/'
    ref = urlparse(request.META.get('HTTP_REFERER', ''))[2]
    # use hidden field if it's there
    ref = request.REQUEST.get('ref', ref)
    if ref == '':
        ref = '/'

    #return render_to_response(DEFAULT_TEMPLATE_NEW,  
    #    RequestContext( request, { 'url': url, 'ref': ref } ))
    
    if request.method == 'POST':
        if request.POST['result'] == 'Cancel':
            return HttpResponseRedirect(ref)
        else:
            form = WikiPageForm(request.POST)
            if form.is_valid():
                try:
                    f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)
                except Http404:
                    f = FlatPage()
                    f.url = str(form.clean()['url'])
                    f.title = form.clean()['title']
                    f.content = str(form.clean()['content'])
                    f.enable_comments = False
                    f.registration_required = False
                    f.save()
                    # need to save get a pk before adding a M2M
                    s = Site.objects.get_current()
                    f.sites.add(s)
                    f.save()
                    return HttpResponseRedirect(f.url)

    else:
        form = WikiPageForm({'url': url, })
        form.ignore_errors = True
        #form.errors().clear()

    response = render_to_response(DEFAULT_TEMPLATE_NEW,  
        RequestContext( request, { 'form': form, 'ref': ref }) )
    #populate_xheaders(request, response, FlatPage, f.id)
    return response
开发者ID:pombredanne,项目名称:django-flatpagewiki,代码行数:54,代码来源:views.py

示例9: test_filmaster_recommends

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_filmaster_recommends(self):
        """
            Test filmaster recommends
        """

        fp = FlatPage()
        fp.url = "filmaster-recommends"
        fp.title = "Title"
        fp.content = "Lorem ipsum"
        fp.save()

        flp = filmaster_recommends()
        flat_page = flp['flat_page']
        self.failUnlessEqual(flat_page.title, "Title")
        self.failUnlessEqual(flat_page.content, "Lorem ipsum")
开发者ID:yangjiandong,项目名称:filmaster,代码行数:17,代码来源:test_templatetags.py

示例10: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):
        page = FlatPage()
        page.url = '/about/'
        page.title = 'About me'
        page.content = 'Some words about me and this not perfect world'
        page.save()

        page.sites.add(Site.objects.all()[0])
        page.save()

        all_pages = FlatPage.objects.all()
        self.assertEqual(len(all_pages), 1)
        only_page = all_pages[0]
        self.assertEqual(only_page, page)

        self.assertEqual(only_page.url, '/about/')
        self.assertEqual(only_page.title, 'About me')
        self.assertEqual(only_page.content, page.content)

        page_url = only_page.get_absolute_url()

        response = self.client.get(page_url)
        self.assertEqual(response.status_code, 200)
开发者ID:ruspython,项目名称:Recipes,代码行数:25,代码来源:tests.py

示例11: main

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
def main():
    applicants = read_results()
    flatpages = FlatPage.objects.filter(url=url)
    if len(flatpages)==0:
        flatpage = FlatPage(url=url)
    elif is_forced:
        flatpage = flatpages[0]
    else:
        print "\nError: old flatpage exists.  Use --force to force overwrite."
        quit()

    template = get_template('result/include/applicant_list.html')
    context = Context({'applicants': applicants})
    flatpage.title = u'ประกาศ'
    flatpage.content = template.render(context)
    flatpage.template_name = 'flatpages/result.html'
    flatpage.save()

    print """.....
Done.
The script only created a flatpage at %s for you.  
You'll have to set the title, its sites, 
and edit other part of the page yourself.""" % (url,)
开发者ID:,项目名称:,代码行数:25,代码来源:

示例12: test_create_flat_page

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
    def test_create_flat_page(self):
        page = FlatPage()
        page.url = '/about/'
        page.title = 'О компании'
        page.content = 'Страница о компании'
        page.save()

        page.sites.add(Site.objects.all()[0])
        page.save()

        all_page = FlatPage.objects.all()
        self.assertEquals(len(all_page), 1)
        only_page = all_page[0]
        self.assertEquals(only_page, page)

        self.assertEquals(only_page.url, '/about/')
        self.assertEquals(only_page.title, 'О компании')
        self.assertEquals(only_page.content, 'Страница о компании')

        page_url = only_page.get_absolute_url()

        response = self.client.get(page_url)
        self.assertContains(response, 'О компании', status_code=200)
        self.assertContains(response, 'Страница о компании')
开发者ID:ilyutoev,项目名称:code-sample,代码行数:26,代码来源:tests.py

示例13: Committee

# 需要导入模块: from django.contrib.flatpages.models import FlatPage [as 别名]
# 或者: from django.contrib.flatpages.models.FlatPage import content [as 别名]
conn = MySQLdb.connect(host='127.0.0.1', user='root', passwd=getpass.getpass(), db='weevil') 
c = conn.cursor()

for id_, year in committees.items():
    c.execute('SELECT introtext FROM jos_content WHERE id={0}'.format(id_))
    for row in c:
        committee = Committee(year=year)
        committee.text = fixtext(row[0])
        committee.save()

for id_, url in flat.items():
    c.execute('SELECT introtext FROM jos_content WHERE id={0}'.format(id_))
    for row in c:
        flatpage = FlatPage(url=url)
        flatpage.content = fixtext(row[0])
        flatpage.save()
        flatpage.sites.add(1)

weevils = {}
c.execute('SELECT id,description FROM jos_categories WHERE section=9;')
for row in c:
    if row[0] in cat:
        i = cat[row[0]]
        weevil = Magazine(issue_number=i)
        weevil.text = fixtext(row[1])
        weevil.cover = covers[i].format(i)
        weevils[i] = weevil
        weevil.save()

c.execute('SELECT catid, alias, title, introtext FROM jos_content WHERE sectionid=6 AND state=1')
开发者ID:Bjwebb,项目名称:Weevil-Website,代码行数:32,代码来源:import.py


注:本文中的django.contrib.flatpages.models.FlatPage.content方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。