Giter Site home page Giter Site logo

marcuswhybrow / django-lineage Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 6.0 307 KB

Lightweight template tags for neater hierarchical navigation

Home Page: https://pypi.python.org/pypi/django-lineage/

License: BSD 3-Clause "New" or "Revised" License

Python 100.00%

django-lineage's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

django-lineage's Issues

re.match problem

There is problem with this line

re.match(path,current_path)

Will get match on 2 urls which are different:

/first/url/
/first/url/but/longer

Why not use path==current_path ?

TypeError:expected string or buffer

I have a link in Django 1.4.13 which points to the reverse() of a CBV, called "jurisdiction_list."

<li class="{% ancestor jurisdiction_list %}"><a href="{% url jurisdiction_list %}"><i class="fa fa-globe fa-fw"></i> Jurisdictions</a></li>

It appears to error out at
/lineage/templatetags/lineage.py in get_path, line 85

            if re.match('/', arg_output):
                return arg_output

The variable arg_output is being resolved (somehow) as a queryset of model objects, although it is pointing to a ListView which should have the variable object_list. That aside, one way to resolve this issue is to make sure you have a string before passing the result to the regex:

    def get_path(self, context):
        # If the singular argument was provided and starts with a forward
        # slash, use it as the path
        if self.arg is not None:
            arg_output = self.arg.resolve(context)
            if isinstance(arg_output, basestring):
                if re.match('/', arg_output):
                    return arg_output

        # Otherwise derive the path from the url tag approach
        return self.url_node.render(context)

There may be something I am missing, and I am certainly confused as to how the result of the parsing of "jurisdiction_list" results in the object_list being returned.

My views.py has something similar to:

class JurisdictionList(ListView):
    model = Jurisdiction
    ....

jurisdiction_list = JurisdictionList.as_view()

Then, my urls.py points to the name & view "jurisdiction_list."

Special case for root URL

Maybe ancestor should make a special case for the root URL (which is defined as an empty RegEx).

For instance, if we have url(r'^$', views.index, name='index'), then {% ancestor 'index' %} will always match, which is not desired.

As a workaround, I can use {% ancestor '/$' %}.

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.