def create_object(self): pagename = clean_name(self.kwargs["original_slug"]) content = "<p>Describe %s here</p>" % pagename if "template" in self.request.GET: try: p = Page.objects.get(slug=self.request.GET["template"]) content = p.content except Page.DoesNotExist: pass return Page(name=url_to_name(self.kwargs["original_slug"]), content=content)
def create_object(self): pagename = clean_name(self.kwargs['original_slug']) content = '<p>Describe %s here</p>' % pagename if 'template' in self.request.GET: try: p = Page.objects.get(slug=self.request.GET['template']) content = p.content except Page.DoesNotExist: pass return Page(name=url_to_name(self.kwargs['original_slug']), content=content)
def is_valid(self, bundle, request=None): errors = {} pagename = bundle.data.get('name') if pagename: if pagename != clean_name(pagename): errors['name'] = ['Pagename cannot contain underscores or ' 'a / character surrounded by spaces. Please replace ' 'underscores with spaces and remove spaces surrounding the' ' / character.' ] print 'ERROS', errors return errors
def is_valid(self, bundle, request=None): errors = {} pagename = bundle.data.get("name") if pagename: if pagename != clean_name(pagename): errors["name"] = [ "Pagename cannot contain underscores or " "a / character surrounded by spaces. Please replace " "underscores with spaces and remove spaces surrounding the" " / character." ] print "ERROS", errors return errors