GithubHelp home page GithubHelp logo

Comments (10)

idlesign avatar idlesign commented on July 29, 2024

It seems that "activation.key" is not defined or is None for your first example, that's why app couldn't resolve current_item, and having no current_item where couldn't be any title for a page.

However this behaviour for URL-resolving funtion is logical since noone should ever pass None into \w+.
So the only way sitetree could ease your pain is to render empty string in place of sitetree_page_title instead of 500. A fix is soon to come.

Note: "URL as a pattern" should be checked regardless if you use URL patters in URL edit, e.g. for "registration_activate activation.key".

from django-sitetree.

idlesign avatar idlesign commented on July 29, 2024

It seems that your settings.DEBUG is set to True otherwise sitetree_page_title template tag fails silently with empty string for title.

from django-sitetree.

dnogues avatar dnogues commented on July 29, 2024

idlesign,

Thank you for your prompt answer.

Github ate the definition of activation.key

url(r'^activate/(?P\w+)/$',
activate,
name='registration_activate'),

should be

url(r'^activate/(?P-lt-activation_key-gt-\w+)/$',
activate,
name='registration_activate'),

where -lt- and -gt- stand for the opening and closing characters surrounding the variable name

Isn't this a declaration that sitetree would interpret as "activation.key" in the URL field?

from django-sitetree.

idlesign avatar idlesign commented on July 29, 2024

(?P<activation_key>\w+) — is a named regular expression group and it says that URL should be

activate/{any_alphanumeric_characters_or_underscores_here}/

Django tries to resolve a URL for view registration_activate activation.key and since activation.key is None it won't match any URL (None is not an alphanumeric character or underscore), so it won't match a current sitetree item either. And as long as DEBUG param in your settings.py is set to True you'll get an exception, i.e. 500.

from django-sitetree.

dnogues avatar dnogues commented on July 29, 2024

idlesign,

May I ask what would make site tree take something like (?P<category_id>\d+) and convert it into "category.id", but instead not convert something like (?P<activation_key>\w+) into activation.key ?

from django-sitetree.

idlesign avatar idlesign commented on July 29, 2024

No-no, I dare say, that you're taking the whole idea wrong: sitetree won't convert anything, it plays by rules, you defined for it.

When you put in admin URL-pattern registration_activate activation.key sitetree will try to get activation.key variable from template context for the requested page; and then will try to find a URL from those that are defined in your urls.py (and similar) that will match name registration_activate and is able to handle the value passed to it by activation.key.

I hope that answers your question %)

from django-sitetree.

dnogues avatar dnogues commented on July 29, 2024

And that is the request context one defines in the view... I was putting in the template hoping that this would create an "activation" object in my context. But template contexts are defined in the views...

django-registration does not define an "activation" object in the context of activate.html, despite using "activation_id" to name the regular expression in the URL. By naming a regular expression in the URL, one can refer to it in the args and kwargs arguments of the view, and that's all django-registration does with it...

from django-sitetree.

idlesign avatar idlesign commented on July 29, 2024

I've had a look at django-registration and it seems that registration_activate is a stand-in-the-middle view, so the only chance for a user to see your activate.html page is to enter an invalid key.

There is a little sense in defining a sitetree item specifically for stand-in-the-middle pages, because they do not exactly belong to site stucture as a whole, if you catch my meaning.

So for you there are two options, I think:

  1. Not to use sitetree for activate.html (you may harcode the header and not use sitetree_page_title);
  2. Or you can do it a hard way, by overriding activate view so that registration_activate activation.key resolves correctly. extra_context view param seems to be a good starting point.

from django-sitetree.

dnogues avatar dnogues commented on July 29, 2024

I went for option 1.

In my activate.html template instead of this:

{% block page_title %}

{% sitetree_page_title from "root" %}

{% endblock %}

I use this:

{% block page_title %}

Account activation

{% endblock %}

And skip breadcrumbs and menus...

Thank you!! :-)

from django-sitetree.

idlesign avatar idlesign commented on July 29, 2024

You're welcome.

from django-sitetree.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.