2

Actually I am learning python flask Navigation, I installed all the necessary packages successfully, these are some of the packages,

app$ venv/bin/easy_install  flask-restful
app$ venv/bin/easy_install  Flask-bootstrap
app$ venv/bin/easy_install  Flask-Navigation

but when I am tring to import

   from flask_nav import Nav
         or
   from flask_nav.elements import Navbar, View

getting error,

>>>from flask_nav import register_renderer
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'flask_nav'

I am using ubuntu-14.02 and Python 3.4.3. How do i fix this error, any solution.

Hari Rama
  • 61
  • 1
  • 1
  • 10

3 Answers3

0

According to Flask-Navigation documentation, you should be importing Navigation and not Nav

from flask import Flask
from flask.ext.navigation import Navigation

app = Flask(__name__)
nav = Navigation(app)

You might be confusing Flask-Navigation with Flask-Nav which is installed under the package name flask-nav.

From the documentation, here are some differences between Flask-Nav to Flask-Navigation:

Flask-Nav owes a some good core ideas to Flask-Navigation, which is about a year older and the first place the author looked before deciding to write Flask-Nav. In defense of the reimplementation. Here are some key differences:

  • Flask-Navigation rolls all element types into a single Item class, which serves as label, view and link element. This makes it a little hard to extend.
  • The HTML generation in Flask-Navigation is done inside the package itself, while Flask-Nav uses a more complete, external solution.
  • Navigational structure creation and rendering are separate in Flask-Nav (see Renderer). This allows for more than one way of rendering the same navbar, allowing other packages (such as Flask-Bootstrap) to supply renderers as well.
  • Some technical choices were deemed a little strange and have been avoided (BoundTypeProperty)
  • While Flask-Navigation uses signals and hooks to regenerate navigation bars on every request, Flask-Nav achieves dynamic behaviour by lazily instantiating naviigation bars when they are needed and at the last possible moment.
Forge
  • 6,538
  • 6
  • 44
  • 64
  • yes, @Forge you correct. i was confused with both packages because of there name, thanks for your link (documentation) – Hari Rama Mar 01 '16 at 12:53
0

I got answer, along with $ flask_virtual/bin/easy_install Flask-Navigation

we need to install flask-nav too to get access of

from flask_nav import Nav
from flask_nav.elements import Navbar, View

so use $ venv/bin/easy_install --upgrade flask-nav

Hari Rama
  • 61
  • 1
  • 1
  • 10
0

In my case, only this form of importing worked:

from flask_navigation import Navigation

See: https://stackoverflow.com/a/50696358/7969193

Laura Corssac
  • 1,217
  • 1
  • 13
  • 23