ViewDoesNotExist Error

7 views
Skip to first unread message

ravi krishna

unread,
Feb 22, 2011, 11:24:43 PM2/22/11
to django...@googlegroups.com
Hi,
 i am trying to do a simple Django application where employee list is read from database and displayed. for that i defined the models and entered the values to database through Django admin. But while trying to display data from database i am stuck with an error, "ViewDoesNotExist at /employeeProfile/ : Could not import task.employeeDetails.views. Error was: cannot import name emp_profile ".I am relatively new to django,so please help me to solve this. This is the code

VIEWS.PY
from django.shortcuts import render_to_response
 from django.contrib.auth.models import*
from task.employeeDetails.models import *
 from django.conf import settings
from django.http import HttpResponse
from task.employeeDetails import emp_profile

def employeeList(request): tableList = EmployeeDetails.objects.all() return render_to_response('employeeList.html', {'emp_list': tableList})

def employeeProfile(request): profile = EmployeeDetails.objects.all() return render_to_response('employeeProfile.html',{'emp_profile':emp_profile})

URLS.PY

(r'^employeeProfile/$','task.employeeDetails.views.employeeProfile'),

TEMPLATE

{%for emp in emp_profile%} {{ emp.userName }} {{ emp.designation }} {{ emp.employeeID }} {%endfor%}

MODELS.PY

from django.db import models
class EmployeeDetails(models.Model):
    userName = models.CharField(max_length=200)
    designation = models.CharField(max_length=200)
    employeeID = models.IntegerField()
    contactNumber = models.IntegerField()
    project = models.CharField(max_length=200)
    dateOfJoin=models.DateField()


Thanks & Regards,

Ravi Krishna

My profiles: Facebook LinkedIn Twitter


Mike Ramirez

unread,
Feb 22, 2011, 11:54:36 PM2/22/11
to django...@googlegroups.com

On Tuesday, February 22, 2011 08:24:43 pm ravi krishna wrote:

> from task.employeeDetails import emp_profile

I did not where emp_profile comes from.

Mike

--

We are sorry. We cannot complete your call as dialed. Please check

the number and dial again or ask your operator for assistance.

This is a recording.

Mike Ramirez

unread,
Feb 22, 2011, 11:59:53 PM2/22/11
to django...@googlegroups.com

On Tuesday, February 22, 2011 08:24:43 pm ravi krishna wrote:

> from task.employeeDetails import emp_profile

I did see* not where emp_profile comes from.

Mike

(sorry).

ravi krishna

unread,
Feb 23, 2011, 12:57:24 AM2/23/11
to django...@googlegroups.com, Mike Ramirez
Hi all,

I got it solved.

def employeeProfile(request): emp_profile = EmployeeDetails.objects.all() return render_to_response('employeeProfile.html',{'emp_profile':emp_profile})




Thanks & Regards,

Ravi Krishna

My profiles: Facebook LinkedIn Twitter




--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

Reply all
Reply to author
Forward
0 new messages