2014-07-26 9 views
6

के साथ `none` url देने वाले wagtail पेज मुझे wagtail पृष्ठों के साथ कुछ परेशानी हो रही है।'लाइव' स्थिति

खोल

>>> Site.get_site_root_paths() 
[(1, u'/home/', u'http://localhost')] 
>>> BlogPage.objects.all()[0] 
<BlogPage: Hello wagtail> 
>>> BlogPage.objects.all()[0].url 
>>> BlogPage.objects.all()[0].full_url 
>>> BlogPage.objects.all()[0].status_string 
'live' 
>>> BlogPage.objects.all()[0].url_path 
u'/blog/hello-wagtail/' 

यह थोड़ी देर के लिए काम किया है से

, मैं वेग्टेल व्यवस्थापक में एक Blog Index Page करने के लिए root से Blog Page ले जाया गया (models.py bellow देखें) और किसी कारण से, पेज मैं से disapeared ले जाया गया व्यवस्थापक इसलिए मैंने ./manage.py sycndb और ./manage.py migrate के साथ फिर से अपना डेटाबेस बनाकर किए गए चरणों को दोहराने का प्रयास किया, फिर से बनाए गए पृष्ठ और अब यूआरएल अब दिखाई नहीं दे रहे हैं।

मैंने क्या देखा है यह देखने के लिए wagtailcore/models.py में ब्रेकपॉइंट जोड़ा। महत्वपूर्ण अनुभाग यहाँ हो रहा है:

@property 
    def url(self): 
     """ 
     Return the 'most appropriate' URL for referring to this page from the pages we serve, 
     within the Wagtail backend and actual website templates; 
     this is the local URL (starting with '/') if we're only running a single site 
     (i.e. we know that whatever the current page is being served from, this link will be on the 
     same domain), and the full URL (with domain) if not. 
     Return None if the page is not routable. 
     """ 
     root_paths = Site.get_site_root_paths() 
     for (id, root_path, root_url) in Site.get_site_root_paths(): 
      if self.url_path.startswith(root_path): 
       return ('' if len(root_paths) == 1 else root_url) + self.url_path[len(root_path) - 1:] 

self.url_path.startswith(root_path) मेरे मामले में सच नहीं है। कि पाश अंदर

चर:

id = {int} 1 
root_path = {unicode} u'/home/' 
root_paths = {list} [(1, u'/home/', u'http://localhost')] 
root_url = {unicode} u'http://localhost' 
self = {Page} Blog 

कि सब के सब का मतलब है कि मेरी बनाए गए पृष्ठों रॉटेबल नहीं हैं। मैं अभी भी अपने पृष्ठ सही तरीके से वेग्टेल व्यवस्थापक से पूर्वावलोकन मोड का उपयोग कर देख सकते हैं, लेकिन मैं क्यों अपने पृष्ठों :(करने के लिए कोई रास्ता है नहीं मिल रहा।

यहाँ मेरी models.py

from django.db import models 

from wagtail.wagtailcore.models import Page, Orderable 
from wagtail.wagtailcore.fields import RichTextField 
from wagtail.wagtailadmin.edit_handlers import FieldPanel, MultiFieldPanel, InlinePanel, PageChooserPanel 
from modelcluster.fields import ParentalKey 


class BlogPage(Page): 
    body = RichTextField() 
    intro = RichTextField() 
    date = models.DateField("Post date") 
    indexed_fields = ('body',) 
    search_name = "Blog Page" 


BlogPage.content_panels = [ 
    FieldPanel('title', classname="full title"), 
    FieldPanel('date'), 
    FieldPanel('intro', classname="full"), 
    FieldPanel('body', classname="full"), 
] 


class LinkFields(models.Model): 
    link_page = models.ForeignKey(
     'wagtailcore.Page', 
     null=True, 
     blank=True, 
     related_name='+' 
    ) 

    panels = [ 
     PageChooserPanel('link_page'), 
    ] 

    class Meta: 
     abstract = True 


class RelatedLink(LinkFields): 
    title = models.CharField(max_length=255, help_text="Link title") 
    panels = [ 
     FieldPanel('title'), 
     MultiFieldPanel(LinkFields.panels, "Link"), 
    ] 

    class Meta: 
     abstract = True 


class BlogIndexPageRelatedLink(Orderable, RelatedLink): 
    page = ParentalKey('main.BlogIndexPage', related_name='related_links') 


class BlogIndexPage(Page): 
    intro = models.CharField(max_length=256) 
    indexed_fields = ('body',) 
    search_name = "Blog Index Page" 


BlogIndexPage.content_panels = [ 
    FieldPanel('title', classname="full title"), 
    FieldPanel('intro', classname="full"), 
    InlinePanel(BlogIndexPage, 'related_links', label="Related links"), 
] 

उत्तर

7

आम तौर पर आप बनाना चाहिए पृष्ठों है मुखपृष्ठ के बच्चों के रूप में। आंतरिक रूप से, इसका मतलब है कि अपने ब्लॉग सूचकांक पेज /home/blog/ के url_path प्राप्त करेंगे, और /home/ के बाद से http://localhost को मैप किया है root_paths सूची में, यह http://localhost/blog/ का एक अंतिम URL दे देंगे।

आप के रूप में देखा है, अगर आप पी बनाते हैं होमपेज के साथ रूट स्तर पर उम्र, वे डिफ़ॉल्ट साइट रिकॉर्ड के बाहर मौजूद होंगे, और इसलिए उनके पास एक रूट करने योग्य यूआरएल नहीं होगा। हालांकि, आप http://localhost/django-admin/ पर Django व्यवस्थापक इंटरफ़ेस के माध्यम से अतिरिक्त साइटें सेट अप कर सकते हैं - उदाहरण के लिए, यदि आप अपने ब्लॉग को http://blog.example.com/ पर होस्ट करना चाहते हैं, तो आप अपने ब्लॉग इंडेक्स पेज पर रूट किए गए डोमेन के लिए साइट एंट्री बनायेंगे।

संबंधित मुद्दे