Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #54430 > unrolled thread

django admin.py error

Started byGary Roach <gary719_list1@verizon.net>
First post2013-09-19 09:04 -0700
Last post2013-09-19 12:33 -0700
Articles 5 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  django admin.py error Gary Roach <gary719_list1@verizon.net> - 2013-09-19 09:04 -0700
    Re: django admin.py error John Gordon <gordon@panix.com> - 2013-09-19 18:15 +0000
      Re: django admin.py error Gary Roach <gary719_list1@verizon.net> - 2013-09-19 11:49 -0700
        Re: django admin.py error John Gordon <gordon@panix.com> - 2013-09-19 18:56 +0000
          Re: django admin.py error (solved) Gary Roach <gary719_list1@verizon.net> - 2013-09-19 12:33 -0700

#54430 — django admin.py error

FromGary Roach <gary719_list1@verizon.net>
Date2013-09-19 09:04 -0700
Subjectdjango admin.py error
Message-ID<mailman.154.1379606716.18130.python-list@python.org>
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



[toc] | [next] | [standalone]


#54433

FromJohn Gordon <gordon@panix.com>
Date2013-09-19 18:15 +0000
Message-ID<l1fev6$k1v$1@reader1.panix.com>
In reply to#54430
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@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#54435

FromGary Roach <gary719_list1@verizon.net>
Date2013-09-19 11:49 -0700
Message-ID<mailman.157.1379616572.18130.python-list@python.org>
In reply to#54433

[Multipart message — attachments visible in raw view] — view raw

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=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







[toc] | [prev] | [next] | [standalone]


#54437

FromJohn Gordon <gordon@panix.com>
Date2013-09-19 18:56 +0000
Message-ID<l1fhdj$g8i$1@reader1.panix.com>
In reply to#54435
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@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [next] | [standalone]


#54440 — Re: django admin.py error (solved)

FromGary Roach <gary719_list1@verizon.net>
Date2013-09-19 12:33 -0700
SubjectRe: django admin.py error (solved)
Message-ID<mailman.159.1379619225.18130.python-list@python.org>
In reply to#54437
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

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web