Two different problems here.

For your import of contactForm, please try the relative import like:
from contact.forms import contactForm
> contact is your app name

try the (absolute_import)[1] too if you're python2.

[1] https://docs.python.org/2/library/__future__.html

Let us know if this works

On 02/17/2015 01:30 PM, Petar Pilipovic wrote:
Maybea this can help you, a bref info :
I made a contact app, I have defined app url in mine url root project, then i made a forms.py file, i have defined form in it, then i have made contact.html where I have defined contact.html form which mine app will render, I have then go to views.py an imported contactForm class. Afther that I have defined connection between contact.html page and navbar.html, collected static, run server and bam error occur. I just can not explain to mine self how come he can not import contactForm, and how com he can not render havbar.html, error pop's out line 15. On Tuesday, February 17, 2015, Petar Pilipovic <iamr...@gmail.com <mailto:iamr...@gmail.com>> wrote:
> Hello, I can not do it wright now I am not at home.
> As for mine forms.py, it is in mine contact app. I have two apps in mine root project, one off them is contact.
> I will send you more info as soon as posible.
> Tank you.
>
>
> On Tuesday, February 17, 2015, aRkadeFR <cont...@arkade.info <mailto:cont...@arkade.info>> wrote:
>> Hello :)
>>
>> Can you dump us the layout of your files?
>> Where is your forms.py?
>>
>> Thanks
>>
>> On 02/17/2015 06:36 AM, Petar Pilipovic wrote:
>>
>> Hello all, I am trying to build and e_commerc django app, but I have encounter an confusing error.
>> Mine Error is:
>> Environment:
>>
>> Request Method: GET
>> Request URL: http://127.0.0.1:8000/
>> Django Version: 1.7.4
>> Python Version: 2.7.6
>> Installed Applications:
>> ('django.contrib.admin',
>>  'django.contrib.auth',
>>  'django.contrib.contenttypes',
>>  'django.contrib.sessions',
>>  'django.contrib.messages',
>>  'django.contrib.staticfiles',
>>  'profiles')
>> Installed Middleware:
>> ('django.contrib.sessions.middleware.SessionMiddleware',
>>  'django.middleware.common.CommonMiddleware',
>>  'django.middleware.csrf.CsrfViewMiddleware',
>>  'django.contrib.auth.middleware.AuthenticationMiddleware',
>>  'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
>>  'django.contrib.messages.middleware.MessageMiddleware',
>>  'django.middleware.clickjacking.XFrameOptionsMiddleware')
>>
>> Template error:
>> In template /home/petarp/Documents/Udemy/Learn_Django/static/templates/navbar.html, error at line 15
>>    cannot import name contactForm
>> 5 : <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
>>
>>    6 :             <span class="sr-only">Toggle navigation</span>
>>
>>    7 :             <span class="icon-bar"></span>
>>
>>    8 :             <span class="icon-bar"></span>
>>
>>    9 :             <span class="icon-bar"></span>
>>
>>    10 :           </button>
>>
>>    11 :           <a class="navbar-brand" href="#">Bootstrap theme</a>
>>
>>    12 :         </div>
>>
>>    13 :         <div id="navbar" class="navbar-collapse collapse">
>>
>>    14 :           <ul class="nav navbar-nav">
>>
>>    15 :             {% url 'home' as home %}
>>
>>    16 :            {% url 'about' as about %}
>>
>>    17 :            {% url 'contact' as contact %}
>>
>> 18 : <li {% if request.path == home %} class="active" {%endif%}><a href="{% url 'home' %}">Home</a></li>
>>
>> 19 : <li {% if request.path == about %} class="active" {%endif%}><a href="{% url 'about' %}">About</a></li>
>>
>> 20 : <li {% if request.path == contact %} class="active" {%endif%}><a href="{% url 'contact' %}">Contact</a></li>
>>
>>    21 :             <li class="dropdown">
>>
>> 22 : <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
>>
>>    23 :               <ul class="dropdown-menu" role="menu">
>>
>>    24 :                 <li><a href="#">Action</a></li>
>>
>>    25 :                 <li><a href="#">Another action</a></li>
>>
>> Traceback:
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response >> 111. response = wrapped_callback(request, *callback_args, **callback_kwargs) >> File "/home/petarp/Documents/Udemy/Learn_Django/source/profiles/views.py" in home
>>   7.     return render(request, tempalte, context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/shortcuts.py" in render
>>   50.     return HttpResponse(loader.render_to_string(*args, **kwargs),
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
>>   178.         return t.render(context_instance)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
>>   148.             return self._render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in _render
>>   142.         return self.nodelist.render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
>>   844.                 bit = self.render_node(node, context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
>>   80.             return node.render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
>>   126.         return compiled_parent._render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in _render
>>   142.         return self.nodelist.render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
>>   844.                 bit = self.render_node(node, context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
>>   80.             return node.render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/loader_tags.py" in render
>>   150.                 return template.render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
>>   148.             return self._render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in _render
>>   142.         return self.nodelist.render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/base.py" in render
>>   844.                 bit = self.render_node(node, context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/debug.py" in render_node
>>   80.             return node.render(context)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/template/defaulttags.py" in render >> 444. url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app) >> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse >> 551. return iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)) >> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _reverse_with_prefix
>>   415.             self._populate()
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate >> 303. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args)) >> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in callback
>>   231.         self._callback = get_callable(self._callback_str)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/utils/lru_cache.py" in wrapper
>>   101.                     result = user_function(*args, **kwds)
>> File "/home/petarp/.virtualenvs/e_udemy/local/lib/python2.7/site-packages/django/core/urlresolvers.py" in get_callable
>>   97.             mod = import_module(mod_name)
>> File "/usr/lib/python2.7/importlib/__init__.py" in import_module
>>   37.     __import__(name)
>> File "/home/petarp/Documents/Udemy/Learn_Django/source/contact/views.py" in <module>
>>   3. from .forms import contactForm
>> Exception Type: ImportError at /
>> Exception Value: cannot import name contactForm
>> I do not understand this error, or better to say I can not see the error, how come he can not import 'contactForm'. Mine views.py and mine forms.py.
>> Can you help me understand and overcome this.
>> Tank you.
>>
>> --
>> You received this message because you are subscribed to the Google Groups "Django users" group. >> To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users%2bunsubscr...@googlegroups.com>. >> To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/819c2889-37f9-4fbd-a422-1c18a7177865%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
>> You received this message because you are subscribed to a topic in the Google Groups "Django users" group. >> To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/a9iraquxOHU/unsubscribe. >> To unsubscribe from this group and all its topics, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users%2bunsubscr...@googlegroups.com>. >> To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/54E2FFDB.5010207%40arkade.info.
>> For more options, visit https://groups.google.com/d/optout.
>> --
You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com <mailto:django-users+unsubscr...@googlegroups.com>. To post to this group, send email to django-users@googlegroups.com <mailto:django-users@googlegroups.com>.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAK8niQuLfTDj-KMon-sbAWHCg5vObiu_Dj%3DAnqqjbR3MAdtFpQ%40mail.gmail.com <https://groups.google.com/d/msgid/django-users/CAK8niQuLfTDj-KMon-sbAWHCg5vObiu_Dj%3DAnqqjbR3MAdtFpQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54E3487D.4040704%40arkade.info.
For more options, visit https://groups.google.com/d/optout.

Reply via email to