django admin.py error

G

Gary Roach

Installation of the django admin.py package worked fine. But. when I
tried to add my database to the admin page I get the following error:

ImportError at /admin/

cannot import name membership

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.5.2
Exception Type: ImportError
Exception Value:

cannot import name membership

Exception Location:
/home/gary/ProgramFiles/mysite/mysite/admin.py in <module>, line 4
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:

['/home/gary/ProgramFiles/mysite/mysite',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/python2.7/dist-packages/gtk-2.0',
'/usr/lib/pymodules/python2.7',
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']

My admin.py file is:
#Adding this app to the admin page.

from django.contrib import admin
from mysite.models import membership, address, status, audio, video,
photos

admin.site.register(membership)
admin.site.register(address)
admin.site.register(status)
admin.site.register(audio)
admin.site.register(video)
admin.site.register(photos)

I can't seem to locate the source of the problem. Everything seems to be
installed properly.

Any help will be sincerely appreciated.

Gary R
 
J

John Gordon

In said:
Installation of the django admin.py package worked fine. But. when I
tried to add my database to the admin page I get the following error:
ImportError at /admin/
cannot import name membership
['/home/gary/ProgramFiles/mysite/mysite',

My admin.py file is:
#Adding this app to the admin page.
from django.contrib import admin
from mysite.models import membership, address, status, audio, video,
photos

Does /home/gary/ProgramFiles/mysite/mysite/models.py define an object
named 'membership'?
 
G

Gary Roach

ImportError at /admin/
Does /home/gary/ProgramFiles/mysite/mysite/models.py define an object
named 'membership'?
Yes. The following is the top part of the models.py file: q

from __future__ import unicode_literals

from django.db import models

class Membership(models.Model):
id_membership = models.IntegerField(unique=True, primary_key=True)
first_name = models.CharField(max_length=20L, blank=True)
middle_name = models.CharField(max_length=20L, blank=True)
last_name = models.CharField(max_length=20L, blank=True)
born = models.DateField(null=True, blank=True)
born_date_accuracy = models.CharField(max_length=8L, blank=True)
died = models.DateField(null=True, blank=True)
died_date_accuracy = models.CharField(max_length=8L, blank=True)
photo_url = models.CharField(max_length=200L,
db_column='photo_URL', blank=True) # Field name made lowercase.
class Meta:
db_table = 'membership'

class Address(models.Model):
id_address = models.IntegerField(unique=True, primary_key=True)
street = models.CharField(max_length=45L, blank=True)
city = models.CharField(max_length=45L, blank=True)
state = models.CharField(max_length=45L, blank=True)
class Meta:
db_table = 'address'

class AddressHasMembership(models.Model):
address_id_address = models.ForeignKey(Address,
db_column='address_id_address')
membership_id_membership = models.ForeignKey('Membership',
db_column='membership_id_member
ship')
class Meta:
db_table = 'address_has_membership'

I hope this helps. Thanks for the reply

Gary R
 
J

John Gordon

In said:
On 09/19/2013 11:15 AM, John Gordon wrote:
Yes. The following is the top part of the models.py file: q
class Membership(models.Model):
id_membership = models.IntegerField(unique=True, primary_key=True)

I see something named 'Membership', but nothing named 'membership'.
Python names are case-sensitive.
 
G

Gary Roach

I see something named 'Membership', but nothing named 'membership'.
Python names are case-sensitive.
Stupid stupid stupid. Thanks. You would think that after working with
Linux for over 10 years that I wouldn't pull such a stunt. Thanks.
Everything now working fine.

Gary R
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,828
Messages
2,569,736
Members
45,518
Latest member
vlonesshirt

Latest Threads

Top