RMachnik
RMachnik

Reputation: 3684

Django.views is missing why? No module named django.views

I have a problem with django.views My Code is

template

<!doctype html>
<html>
  <h1>{{userName}} twoje wycieczki : </h1>
    <a href ="">Dodaj wycieczke>></a>
</html>

basic html template with url tag.

my views.py

def tripList(request):
    user = request.user
    print user.username
    tList = Trip.objects.filter(userId = user.id)
    return render_to_response('tripList.html',{'userName' : user.username}, context_instance = RequestContext(request))

also urls.py

from django.conf.urls import patterns, url
from views import *

urlpatterns = patterns('',
url(r'^createTrip/$', createTrip, name = 'createTrip'),)

but i get error

No module named django.views

Exception Location: /var/src/Django-1.4.2/django/utils/importlib.py in import_module, line 35

And I don't know what is wrong because i have included django.views in settings.py and in my python console also django.views can be imported so there is django.views

I have no idea what's wrong. I have other views with url tag but there was no bug like that. Maybe someone have simple problem. Thank's in advance.

Upvotes: 0

Views: 2055

Answers (2)

RMachnik
RMachnik

Reputation: 3684

My problem was laying in configuration of django. You have file settings.py and my problem was with configuration of MEDIA_* variables configuration. You have to remember that MEDIA_ROOT should be absolute path to files in yor file system, MEDIA_URL that is mapping your media file access, and STATIC_URL also should be filled. This is my configuration. When I properly filled it problem dissapeared. :) If you have any more question write.

MEDIA_ROOT = 'myAbsolutePath\media\\'
MEDIA_URL = '/media/'
STATIC_URL='/static/'

Upvotes: 0

Eren T.
Eren T.

Reputation: 320

What is the name of your project, and where is your views.py is located? Usually, you do not have such a line while importing your views:

from views import *

If you are importing views within your project, please use the name of the project as a prefix. If you have an application in its own folder, say trip, you need to import its view file as

from trip.views import *

Upvotes: 2

Related Questions