Understood, got that error cleared now.

Just a last question - should my HoleImages not present their upload 
options in the Hole part of the admin?

<https://lh3.googleusercontent.com/-ChpLmrlMN-s/U5jEmgNkdrI/AAAAAAAAADk/4X45ORinrbU/s1600/Screen+Shot+2014-06-11+at+22.05.07.png>

<https://lh5.googleusercontent.com/-14oEuDDZj9Y/U5jEtIyEW3I/AAAAAAAAADw/lun-Q51aNb8/s1600/Screen+Shot+2014-06-11+at+22.05.41.png>


On Wednesday, June 11, 2014 9:57:19 PM UTC+1, Ilya Kazakevich wrote:
>
> Instead of 
>  from holes.models import HoleImage 
> write 
>  from holes.models import HoleImage, Hole 
>
> Please read https://docs.python.org/2/tutorial/modules.html 
>
>
>
>
> Ilya Kazakevich, 
> JetBrains PyCharm (Best Python/Django IDE) 
> http://www.jetbrains.com/pycharm/ 
> "Develop with pleasure!" 
>
>
> >-----Original Message----- 
> >From: django...@googlegroups.com <javascript:> 
> >[mailto:django...@googlegroups.com <javascript:>] On Behalf Of Patrick C 
> >Sent: Thursday, June 12, 2014 12:52 AM 
> >To: django...@googlegroups.com <javascript:> 
> >Subject: Re: NameError at /admin/ name 'HoleImage' is not defined 
> > 
> >Should it be this: 
> > 
> >from django.contrib import admin 
> >from holes.models import HoleImage 
> > 
> >class HoleImageInline(admin.TabularInline): 
> >    model = HoleImage 
> > 
> >class HoleAdmin(admin.ModelAdmin): 
> >    fields = ['hole_number', 'hole_name', 'hole_description'] 
> >    list_display = ['hole_number', 'hole_name', 'hole_description'] 
> >    inlines = [ HoleImageInline, ] 
> > 
> >admin.site.register(Hole) 
> >admin.site.register(HoleImage) 
> > 
> > 
> > 
> >or this: 
> > 
> >from django.contrib import admin 
> >from holes.models import HoleImage 
> > 
> >class HoleImageInline(admin.TabularInline): 
> >    model = HoleImage 
> > 
> >class HoleAdmin(admin.ModelAdmin): 
> >    fields = ['hole_number', 'hole_name', 'hole_description'] 
> >    list_display = ['hole_number', 'hole_name', 'hole_description'] 
> >    inlines = [ HoleImageInline, ] 
> > 
> >admin.site.register(Hole, HoleImages) 
> > 
> > 
> >Still have errors trying either, sorry again for noob questions. 
> > 
> >On Wednesday, June 11, 2014 9:45:10 PM UTC+1, Jorge Andrés Vergara Ebratt 
> >wrote: 
> > 
> >        When you import HoleImage don't remove Hole :) 
> > 
> >        On Jun 11, 2014 3:41 PM, "Patrick C" <patrick....@gmail.com 
> <javascript:> > 
> >wrote: 
> > 
> > 
> >                Hi Jorge, 
> > 
> >                Thanks for helping out - I understand that and have just 
> tried it but still 
> >get the error: 
> > 
> > 
> >                NameError at /admin/ 
> > 
> >                name 'Hole' is not defined 
> >Request Method:        GET 
> >Request URL:        http://127.0.0.1:8000/admin/ 
> >Django Version:        1.6.5 
> >Exception Type:        NameError 
> >Exception Value:        name 'Hole' is not defined 
> >Exception 
> Location:        /Users/my_laptop/development/golfsmart/holes/admin.py 
> >in <module>, line 12 
> >Python Executable:         /usr/bin/python 
> >Python Version:        2.7.5 
> > 
> > 
> >                So just to clarify my structure incase I'm missing 
> something on 
> >pluralisation: 
> > 
> >                holes 
> >                - admin.py 
> >                - model.py 
> > 
> > 
> >                models.py: 
> > 
> >                from django.db import models 
> > 
> >                class Hole(models.Model): 
> >                    hole_number = models.IntegerField() 
> >                    hole_name = models.CharField(max_length=255) 
> >                    hole_description = models.CharField(max_length=500) 
> > 
> >                    def __str__(self): 
> >                    return self.hole_number 
> > 
> >                class HoleImage(models.Model): 
> >                    hole = models.ForeignKey(Hole, related_name='images') 
> >                    image = models.ImageField(upload_to='hole_photos') 
> >                    caption = models.CharField(max_length=250) 
> > 
> >                admin.py: 
> > 
> >                from django.contrib import admin 
> >                from holes.models import HoleImage 
> > 
> >                class HoleImageInline(admin.TabularInline): 
> >                    model = HoleImage 
> > 
> >                class HoleAdmin(admin.ModelAdmin): 
> >                    fields = ['hole_number', 'hole_name', 
> 'hole_description'] 
> >                    list_display = ['hole_number', 'hole_name', 
> 'hole_description'] 
> >                    inlines = [ HoleImageInline, ] 
> > 
> >                admin.site.register(Hole) 
> > 
> > 
> > 
> >                On Wednesday, June 11, 2014 9:36:11 PM UTC+1, Jorge 
> Andrés Vergara 
> >Ebratt wrote: 
> > 
> >                        In admin.py you have 
> > 
> >                        from hotels.models import Hole 
> > 
> >                        Add HoleImage to that import 
> > 
> >                        On Jun 11, 2014 3:19 PM, "Patrick C" <
> patrick....@gmail.com> 
> >wrote: 
> > 
> > 
> >                                Hi All, 
> > 
> >                                New to Django / Python (coming from PHP). 
> > 
> >                                Trying to make a site for a golf course 
> where there is a hole 
> >by hole guide, each hole has a number, name, description then multiple 
> images 
> >for the gallery. 
> > 
> >                                I've spend the last few hours googling 
> how I'm going wrong 
> >here because I get the error in the subject line. 
> > 
> >                                My models.py is: 
> > 
> >                                from django.db import models 
> > 
> > 
> >                                class Hole(models.Model): 
> >                                    hole_number = models.IntegerField() 
> >                                    hole_name = 
> models.CharField(max_length=255) 
> >                                    hole_description = 
> models.CharField(max_length=500) 
> > 
> > 
> >                                    def __str__(self): 
> >                                    return self.hole_number 
> > 
> > 
> >                                class HoleImage(models.Model): 
> >                                    hole = models.ForeignKey(Hole, 
> >related_name='images') 
> >                                    image = 
> models.ImageField(upload_to='hole_photos') 
> >                                    caption = 
> models.CharField(max_length=250) 
> > 
> > 
> >                                and my admin.py is: 
> > 
> >                                from django.contrib import admin 
> >                                from holes.models import Hole 
> > 
> > 
> >                                class 
> HoleImageInline(admin.TabularInline): 
> >                                    model = HoleImage 
> > 
> > 
> >                                class HoleAdmin(admin.ModelAdmin): 
> >                                    fields = ['hole_number', 'hole_name', 
> >'hole_description'] 
> >                                    list_display = ['hole_number', 
> 'hole_name', 
> >'hole_description'] 
> >                                    inlines = [ HoleImageInline, ] 
> > 
> > 
> >                                admin.site.register(Hole) 
> > 
> > 
> > 
> > 
> >                                Full admin panel error is: 
> > 
> > 
> > 
> >                                NameError at /admin/ 
> > 
> >                                name 'HoleImage' is not defined 
> >Request Method:        GET 
> >Request URL:        http://127.0.0.1:8000/admin/ 
> >Django Version:         1.6.5 
> >Exception Type:        NameError 
> >Exception Value:        name 'HoleImage' is not defined 
> >Exception 
> Location:        /Users/my_laptop/development/golfsmart/holes/admin.py 
> >in HoleImageInline, line 5 
> >Python Executable:         /usr/bin/python 
> >Python Version:        2.7.5 
> > 
> > 
> > 
> > 
> >                                As I say, I'm new to this and have had a 
> good trial and error 
> >stab, I'm sure it's something simple I am overlooking and once I have it 
> resolved 
> >I will have a lesson learned as I have a few other apps to setup that 
> will use this 
> >many type for images. 
> > 
> >                                Thanks in advance. 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >                                -- 
> >                                You received this message because you are 
> subscribed to 
> >the Google Groups "Django users" group. 
> >                                To unsubscribe from this group and stop 
> receiving emails 
> >from it, send an email to django-users...@googlegroups.com. 
> >                                To post to this group, send email to 
> >django...@googlegroups.com. 
> >                                Visit this group at 
> >http://groups.google.com/group/django-users 
> ><http://groups.google.com/group/django-users> . 
> >                                To view this discussion on the web visit 
> >
> https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f9 
> >53ad105f8%40googlegroups.com 
> ><
> https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f 
> >953ad105f8%40googlegroups.com?utm_medium=email&utm_source=footer> . 
> >                                For more options, visit 
> https://groups.google.com/d/optout 
> ><https://groups.google.com/d/optout> . 
> > 
> > 
> > 
> > 
> >                -- 
> >                You received this message because you are subscribed to 
> the Google 
> >Groups "Django users" group. 
> >                To unsubscribe from this group and stop receiving emails 
> from it, send 
> >an email to django-users...@googlegroups.com <javascript:> . 
> >                To post to this group, send email to 
> django...@googlegroups.com 
> ><javascript:> . 
> >                Visit this group at 
> http://groups.google.com/group/django-users 
> ><http://groups.google.com/group/django-users> . 
> >                To view this discussion on the web visit 
> >
> https://groups.google.com/d/msgid/django-users/fca37d2a-b54f-4cec-af32-df5a 
> >6d1bfbdf%40googlegroups.com 
> ><
> https://groups.google.com/d/msgid/django-users/fca37d2a-b54f-4cec-af32-df5 
> >a6d1bfbdf%40googlegroups.com?utm_medium=email&utm_source=footer> . 
> >                For more options, visit 
> https://groups.google.com/d/optout 
> ><https://groups.google.com/d/optout> . 
> > 
> > 
> >-- 
> >You received this message because you are subscribed to the Google Groups 
> >"Django users" group. 
> >To unsubscribe from this group and stop receiving emails from it, send an 
> email 
> >to django-users...@googlegroups.com <javascript:>. 
> >To post to this group, send email to django...@googlegroups.com 
> <javascript:>. 
> >Visit this group at http://groups.google.com/group/django-users. 
> >To view this discussion on the web visit 
> >
> https://groups.google.com/d/msgid/django-users/848555d3-1004-43e4-a7c6-490 
> >07ef0af4c%40googlegroups.com 
> ><
> https://groups.google.com/d/msgid/django-users/848555d3-1004-43e4-a7c6-49 
> >007ef0af4c%40googlegroups.com?utm_medium=email&utm_source=footer> . 
> >For more options, visit https://groups.google.com/d/optout. 
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5f1324f4-ba4e-4d89-baea-0214c26ab528%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to