Saturday, April 30, 2011

Re: Attribute error

class wish(models.Model):
wish=models.CharField(max_length=200)

what's your django version

On Sun, May 1, 2011 at 3:45 AM, Pulkit Mehrotra <mehrotra.pulkit@gmail.com> wrote:

AttributeError at /mysite/wishlist/

'module' object has no attribute 'CharField'

What does this error means ???

View for this is:
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect,HttpResponse
from wishlist.models import wish
from wishlist.forms import wish

def wishlist(request):
wish_list=wish.objects.all()
return render_to_response(
'wishlist/wishlist.html',
{'list':wish_list}
)

def wish_form(request):
return render_to_response('wishlist/wish_form.html', {'form': form, })

def search(request):
if 'q' in request.GET:
message = 'You searched for: %r' % request.GET['q']
else:
message = 'You submitted an empty form.'
return HttpResponse(message)

The models.py for this is:
from django.db import models

class wish(models.Model):
wish=models.CharField(max_length=200)
wish_date=models.DateTimeField('date published')

the urls.py for this is:
from django.conf.urls.defaults import patterns, include, url
from mysite.wishlist import views

# Uncomment the next two lines to enable the admin:
# from django.contrib import admin
# admin.autodiscover()

urlpatterns = patterns('',
(r'^mysite/wishlist/$','wishlist.views.wishlist'),
(r'^mysite/wish/$','wishlist.views.wish_form'),
(r'^mysite/wishsearch/$','wishlist.views.search'),
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.foo.urls')),

# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
# url(r'^admin/', include(admin.site.urls)),

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

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

No comments:

Post a Comment