FAQ
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

Search Discussions

  • John Gordon at Sep 19, 2013 at 6:15 pm

    In <mailman.154.1379606716.18130.python-list@python.org> Gary Roach <gary719_list1@verizon.net> writes:


    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'?


    --
    John Gordon A is for Amy, who fell down the stairs
    gordon at panix.com B is for Basil, assaulted by bears
                                     -- Edward Gorey, "The Gashlycrumb Tinies"
  • Gary Roach at Sep 19, 2013 at 6:49 pm

    On 09/19/2013 11:15 AM, John Gordon wrote:
    In <mailman.154.1379606716.18130.python-list@python.org> Gary Roach <gary719_list1@verizon.net> writes:
    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/
    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 L, blank=True)
              middle_name = models.CharField(max_length L, blank=True)
              last_name = models.CharField(max_length L, 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 0L,
         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_lengthEL, blank=True)
              city = models.CharField(max_lengthEL, blank=True)
              state = models.CharField(max_lengthEL, 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














    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: <http://mail.python.org/pipermail/python-list/attachments/20130919/d69e83ac/attachment.html>
  • John Gordon at Sep 19, 2013 at 6:56 pm

    In <mailman.157.1379616572.18130.python-list@python.org> Gary Roach <gary719_list1@verizon.net> writes:


    On 09/19/2013 11:15 AM, John Gordon wrote:
    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
    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.


    --
    John Gordon A is for Amy, who fell down the stairs
    gordon at panix.com B is for Basil, assaulted by bears
                                     -- Edward Gorey, "The Gashlycrumb Tinies"
  • Gary Roach at Sep 19, 2013 at 7:33 pm

    On 09/19/2013 11:56 AM, John Gordon wrote:
    In <mailman.157.1379616572.18130.python-list@python.org> Gary Roach <gary719_list1@verizon.net> writes:
    On 09/19/2013 11:15 AM, John Gordon wrote:
    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
    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.
    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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
categoriespython
postedSep 19, '13 at 4:04p
activeSep 19, '13 at 7:33p
posts5
users2
websitepython.org

2 users in discussion

Gary Roach: 3 posts John Gordon: 2 posts

People

Translate

site design / logo © 2022 Grokbase