Re: create_question not define error. NameError.

2022-05-03 Thread Derek
What steps did you follow to get here?  What does your code look like that 
creates this error?

(Its probably better to post actual code snippets as text rather than 
screenshots.)

On Monday, 2 May 2022 at 15:02:44 UTC+2 mdanz...@gmail.com wrote:

> Anyone is here for help?
>
> On Friday, 29 April 2022 at 11:45:48 UTC+5:30 Md Anzar wrote:
>
>> I am following Django tutorial in part 5 when I tried to test and getting 
>> error.  I need help.
>> [image: Screenshot from 2022-04-28 23-50-50.png]
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c241971-c05f-4c71-8536-d615ac0ca3a3n%40googlegroups.com.


Re: create_question not define error. NameError.

2022-05-02 Thread Md Anzar
Anyone is here for help?

On Friday, 29 April 2022 at 11:45:48 UTC+5:30 Md Anzar wrote:

> I am following Django tutorial in part 5 when I tried to test and getting 
> error.  I need help.
> [image: Screenshot from 2022-04-28 23-50-50.png]

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/506cd1c9-2079-4c3f-bec8-644ee56f6f8cn%40googlegroups.com.


Re: NameError:

2022-04-09 Thread tech george
Hello Antonis,

Thanks, it worked.

Much appreciated.

Regards,

On Fri, Apr 8, 2022 at 11:10 PM Antonis Christofides <
anto...@antonischristofides.com> wrote:

> Hi! In the line where the error occurs, Pharmacist has not been defined
> yet. Move your Pharmacist model before your Patients model.
>
> Regards,
>
> Antonis
>
> On 08/04/2022 20.49, tech george wrote:
>
> Hello,
>
> I've been struggling with the below error, what might be the problem?
>
> I have used the same ForeignKey in other models.. all works ok, except
> this.
>
> Please advise.
>
> *Models:*
>
> class CustomUser(AbstractUser):
> user_type_data = ((1, "AdminHOD"), (2, "Pharmacist"), (3, "Doctor"),
> (4, "PharmacyClerk"),(5, "Patients"))
> user_type = models.CharField(default=1, choices=user_type_data,
> max_length=10)
>
>
>
> class Patients(models.Model):
> gender_category=(
> ('Male','Male'),
> ('Female','Female'),
> )
>
> nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist',
> on_delete=models.CASCADE, null=True)
> admin = models.OneToOneField(CustomUser,null=True, on_delete =
> models.CASCADE)
> reg_no=models.CharField(max_length=30,null=True,blank=True,unique=True)
>
> gender=models.CharField(max_length=7,null=True,blank=True,choices=gender_category)
> first_name=models.CharField(max_length=20,null=True,blank=True)
> last_name=models.CharField(max_length=20,null=True,blank=True)
> date_admitted=models.DateTimeField(auto_now_add=True, auto_now=False)
> last_updated = models.DateTimeField(auto_now_add=False, auto_now=True)
>
> def __str__(self):
> return str(self.admin)
>
>
> *Error:*
>
> nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist',
> on_delete=models.CASCADE, null=True)
> NameError: name 'Pharmacist' is not defined
>
>
> Regards,
>
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CADYG20GbMnoGjkT7VtD1FFMw3Tr8Axaepnf27vDyvqYvMb%2BUiQ%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CADYG20GbMnoGjkT7VtD1FFMw3Tr8Axaepnf27vDyvqYvMb%2BUiQ%40mail.gmail.com?utm_medium=email_source=footer>
> .
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/6f64f27c-ec8c-da80-5878-5520c7017b35%40antonischristofides.com
> <https://groups.google.com/d/msgid/django-users/6f64f27c-ec8c-da80-5878-5520c7017b35%40antonischristofides.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADYG20HOOnQksvprL5VgiR1pxCaqaujdFmuHO4LK-nNQfGiprQ%40mail.gmail.com.


Re: NameError:

2022-04-08 Thread Antonis Christofides
Hi! In the line where the error occurs, Pharmacist has not been defined yet. 
Move your Pharmacist model before your Patients model.


Regards,

Antonis


On 08/04/2022 20.49, tech george wrote:


Hello,

I've been struggling with the below error, what might be the problem?

I have used the same ForeignKey in other models.. all works ok, except this.

Please advise.

*Models:*

class CustomUser(AbstractUser):
    user_type_data = ((1, "AdminHOD"), (2, "Pharmacist"), (3, "Doctor"), (4, 
"PharmacyClerk"),(5, "Patients"))

    user_type = models.CharField(default=1, choices=user_type_data, 
max_length=10)



class Patients(models.Model):
    gender_category=(
        ('Male','Male'),
        ('Female','Female'),
    )

nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist', 
on_delete=models.CASCADE, null=True)

    admin = models.OneToOneField(CustomUser,null=True, on_delete = 
models.CASCADE)
reg_no=models.CharField(max_length=30,null=True,blank=True,unique=True)
gender=models.CharField(max_length=7,null=True,blank=True,choices=gender_category)
first_name=models.CharField(max_length=20,null=True,blank=True)
last_name=models.CharField(max_length=20,null=True,blank=True)
    date_admitted=models.DateTimeField(auto_now_add=True, auto_now=False)
    last_updated = models.DateTimeField(auto_now_add=False, auto_now=True)

    def __str__(self):
        return str(self.admin)


*Error:*

nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist', 
on_delete=models.CASCADE, null=True)

NameError: name 'Pharmacist' is not defined


Regards,




--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADYG20GbMnoGjkT7VtD1FFMw3Tr8Axaepnf27vDyvqYvMb%2BUiQ%40mail.gmail.com 
<https://groups.google.com/d/msgid/django-users/CADYG20GbMnoGjkT7VtD1FFMw3Tr8Axaepnf27vDyvqYvMb%2BUiQ%40mail.gmail.com?utm_medium=email_source=footer>.


--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6f64f27c-ec8c-da80-5878-5520c7017b35%40antonischristofides.com.


NameError:

2022-04-08 Thread tech george
Hello,

I've been struggling with the below error, what might be the problem?

I have used the same ForeignKey in other models.. all works ok, except this.

Please advise.

*Models:*

class CustomUser(AbstractUser):
user_type_data = ((1, "AdminHOD"), (2, "Pharmacist"), (3, "Doctor"),
(4, "PharmacyClerk"),(5, "Patients"))
user_type = models.CharField(default=1, choices=user_type_data,
max_length=10)



class Patients(models.Model):
gender_category=(
('Male','Male'),
('Female','Female'),
)

nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist',
on_delete=models.CASCADE, null=True)
admin = models.OneToOneField(CustomUser,null=True, on_delete =
models.CASCADE)
reg_no=models.CharField(max_length=30,null=True,blank=True,unique=True)

gender=models.CharField(max_length=7,null=True,blank=True,choices=gender_category)
first_name=models.CharField(max_length=20,null=True,blank=True)
last_name=models.CharField(max_length=20,null=True,blank=True)
date_admitted=models.DateTimeField(auto_now_add=True, auto_now=False)
last_updated = models.DateTimeField(auto_now_add=False, auto_now=True)

def __str__(self):
return str(self.admin)


*Error:*

nurse = models.ForeignKey(Pharmacist, related_name='Pharmacist',
on_delete=models.CASCADE, null=True)
NameError: name 'Pharmacist' is not defined


Regards,

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CADYG20GbMnoGjkT7VtD1FFMw3Tr8Axaepnf27vDyvqYvMb%2BUiQ%40mail.gmail.com.


Re: NameError: name 'SignUpForm' is not defined

2021-03-13 Thread YAYA KONE
You must called file SignUpForm in your views and start server

Le sam. 13 mars 2021 à 04:00, Desh Deepak  a
écrit :

> Enter after line 6 write this:
> from  .forms import SignUpForm
>
> On Sat, 13 Mar 2021, 9:26 am Desh Deepak,  wrote:
>
>> Need to import form
>>
>>
>> Ex. From appname import formname
>>
>> On Sat, 13 Mar 2021, 4:10 am Noyon Barman, 
>> wrote:
>>
>>> I can't fix it, anyone please suggest to me
>>>
>>> --
>>> 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 view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/4f9095ca-7715-4496-9072-c372434a918bn%40googlegroups.com
>>> 
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJ0m4xj5NvgyDAgPzs157aw4_%2BwSNPXj%2BHGRh_XCApwV_KTbNA%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Buai5DWc6BojsAkS5H4gn%3DK-UtNchNrxV-FixtUrcN6_o86WQ%40mail.gmail.com.


Re: NameError at /account/signup/

2021-03-13 Thread Mohammad Anarul
You did not import the signup form. So showing errors

On Sat, Mar 13, 2021 at 5:48 AM Eduardo Agreda López <
eduardoagred...@gmail.com> wrote:

> Do you have create the SingUpForm. If you use Django auth model, can you
> create the forms.py file and  import this path:
>
> from django.contrib.auth.forms import UserCreationForm
> from django.contrib.auth.models import User
>
> inside of the forms.py file create the SingUpForm class and extends of the
> UserCreationForm module, example:
>
> class SignUpForm(UserCreationForm):
>   class Meta:
>   model = User
>   fields = ('username', 'first_name', 'last_name', 'email',
> 'password1', 'password2', )
>
> Before, in your sign_up view, import you SingUpForm.
>
> El viernes, 12 de marzo de 2021 a las 16:41:40 UTC-6, noyonba...@gmail.com
> escribió:
>
>> I can't fix it, anyone please suggest to me.
>> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/422bb634-0371-43a0-8f8a-2f5dcfdf93a9n%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE59x8eg_AqAM6FduwTaGhHU2b4gc%2BtFSRprm5XeSbL%2B62cP0g%40mail.gmail.com.


Re: NameError: name 'SignUpForm' is not defined

2021-03-12 Thread Desh Deepak
Enter after line 6 write this:
from  .forms import SignUpForm

On Sat, 13 Mar 2021, 9:26 am Desh Deepak,  wrote:

> Need to import form
>
>
> Ex. From appname import formname
>
> On Sat, 13 Mar 2021, 4:10 am Noyon Barman, 
> wrote:
>
>> I can't fix it, anyone please suggest to me
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/4f9095ca-7715-4496-9072-c372434a918bn%40googlegroups.com
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJ0m4xj5NvgyDAgPzs157aw4_%2BwSNPXj%2BHGRh_XCApwV_KTbNA%40mail.gmail.com.


Re: NameError: name 'SignUpForm' is not defined

2021-03-12 Thread Desh Deepak
Need to import form


Ex. From appname import formname

On Sat, 13 Mar 2021, 4:10 am Noyon Barman, 
wrote:

> I can't fix it, anyone please suggest to me
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/4f9095ca-7715-4496-9072-c372434a918bn%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJ0m4xgP9d4kWgUFX7dZYFwcU2nTpxUkL5wG_3nE61yD95zUOQ%40mail.gmail.com.


Re: NameError at /account/signup/

2021-03-12 Thread Fiifi Pius
It's like you are not importing your sign up form

On Fri, Mar 12, 2021, 10:42 PM Noyon Barman 
wrote:

> I can't fix it, anyone please suggest to me.
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d79e07cc-4d37-4833-815d-e6c107a88e97n%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANVLA7EHgdr04jf5Lmze4FhU5ZJt_iQKj8_cW4fW6Hwte7-X3A%40mail.gmail.com.


Re: NameError at /account/signup/

2021-03-12 Thread Eduardo Agreda López
Do you have create the SingUpForm. If you use Django auth model, can you 
create the forms.py file and  import this path:

from django.contrib.auth.forms import UserCreationForm 
from django.contrib.auth.models import User

inside of the forms.py file create the SingUpForm class and extends of the 
UserCreationForm module, example:

class SignUpForm(UserCreationForm): 
  class Meta: 
  model = User 
  fields = ('username', 'first_name', 'last_name', 'email', 
'password1', 'password2', )

Before, in your sign_up view, import you SingUpForm.

El viernes, 12 de marzo de 2021 a las 16:41:40 UTC-6, noyonba...@gmail.com 
escribió:

> I can't fix it, anyone please suggest to me.
> 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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/422bb634-0371-43a0-8f8a-2f5dcfdf93a9n%40googlegroups.com.


Re: Trouble With Tutorial #1 - NameError: name 'polls' is not defined

2018-12-17 Thread Aakash Choudhary
Share the code I'll debug the error

On Mon, 17 Dec 2018, 00:47 Sarthak Khandelwal  can you send your file structure after this step?
> I am having a similar problem, after adding views to url according to the
> tutorial in the documentation, when I was trying to run the server i was
> having a similar to your problem.
> If anyone has completed this step please share the file structure to
> confirm if I am doing something wrong.
>
> and yes I am not doing this error.
>
> On Friday, October 18, 2013 at 2:04:28 AM UTC+5:30,
> michael@farecompare.com wrote:
>>
>> Oh my gosh ... I did. LOL. Thanks. I'm an idiot.
>>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e2a3e21b-6f32-4f67-8689-4f9a380f0b7b%40googlegroups.com
> 
> .
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAOB_Bqpsy5kP9_bp0qO1MceUh9NRPBidByjBxpCwG-N0KifSAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble With Tutorial #1 - NameError: name 'polls' is not defined

2018-12-17 Thread BALA KRISHNAN
you can change this url from your app

from django.conf.urls import include, url
from django.contrib import admin
from django.views.generic import TemplateView
from rest_framework import routers

from user_profile.views import UserViewSet

router = routers.DefaultRouter()
router.register(r'user', UserViewSet,)

urlpatterns = [
url(r'^admin/', include(admin.site.urls)),

# This is used for user reset password
url(r'^', include('django.contrib.auth.urls')),
url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),
url(r'^account/', include('allauth.urls')),
url(r'^api/',  include(router.urls)),
]


On Mon, 17 Dec 2018 at 16:37, Daniel Hepper  wrote:

> Check out this repository:
> https://github.com/consideratecode/django-tutorial-step-by-step
>
> It's not updated for Django 2.1 yet, but the differences should not matter
> in your case.
>
> Hope that helps,
> Daniel
>
> On Sun, Dec 16, 2018 at 8:18 PM Sarthak Khandelwal 
> wrote:
>
>> can you send your file structure after this step?
>> I am having a similar problem, after adding views to url according to the
>> tutorial in the documentation, when I was trying to run the server i was
>> having a similar to your problem.
>> If anyone has completed this step please share the file structure to
>> confirm if I am doing something wrong.
>>
>> and yes I am not doing this error.
>>
>> On Friday, October 18, 2013 at 2:04:28 AM UTC+5:30,
>> michael@farecompare.com wrote:
>>>
>>> Oh my gosh ... I did. LOL. Thanks. I'm an idiot.
>>>
>> --
>> 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 https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/e2a3e21b-6f32-4f67-8689-4f9a380f0b7b%40googlegroups.com
>> 
>> .
>> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHEnUVWeCXGeLj-7O%2BrMztP%3Dp6PTaO%2BMtm2m8KpAV-jG70i_BA%40mail.gmail.com
> 
> .
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGxtV7ZprTYCjgQZzRhBP_aSNjj1vMqKvy%3DvGoodOfvvvd2yVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble With Tutorial #1 - NameError: name 'polls' is not defined

2018-12-17 Thread Daniel Hepper
Check out this repository:
https://github.com/consideratecode/django-tutorial-step-by-step

It's not updated for Django 2.1 yet, but the differences should not matter
in your case.

Hope that helps,
Daniel

On Sun, Dec 16, 2018 at 8:18 PM Sarthak Khandelwal 
wrote:

> can you send your file structure after this step?
> I am having a similar problem, after adding views to url according to the
> tutorial in the documentation, when I was trying to run the server i was
> having a similar to your problem.
> If anyone has completed this step please share the file structure to
> confirm if I am doing something wrong.
>
> and yes I am not doing this error.
>
> On Friday, October 18, 2013 at 2:04:28 AM UTC+5:30,
> michael@farecompare.com wrote:
>>
>> Oh my gosh ... I did. LOL. Thanks. I'm an idiot.
>>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e2a3e21b-6f32-4f67-8689-4f9a380f0b7b%40googlegroups.com
> 
> .
> 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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHEnUVWeCXGeLj-7O%2BrMztP%3Dp6PTaO%2BMtm2m8KpAV-jG70i_BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Trouble With Tutorial #1 - NameError: name 'polls' is not defined

2018-12-16 Thread Sarthak Khandelwal
can you send your file structure after this step?
I am having a similar problem, after adding views to url according to the 
tutorial in the documentation, when I was trying to run the server i was 
having a similar to your problem.
If anyone has completed this step please share the file structure to 
confirm if I am doing something wrong.

and yes I am not doing this error.

On Friday, October 18, 2013 at 2:04:28 AM UTC+5:30, 
michael@farecompare.com wrote:
>
> Oh my gosh ... I did. LOL. Thanks. I'm an idiot.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e2a3e21b-6f32-4f67-8689-4f9a380f0b7b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deployment/NameError Problem

2017-01-04 Thread Antonis Christofides
The error occurs in line 68 of admin.py. The admin.py you're showing doesn't
seem to have 68 lines. Maybe the admin.py you have in development is not the
same you have in production. Or the admin.py the system's reading is not the one
you think it is (maybe it's reading it from another directory). You need to
triple check that. Sometimes such errors are also caused by Python using its
compiled files, *.pyc (in Python 2) or __pycache__/* (in Python 3). Normally it
understands when a source file has changed and recompiles it, but for a variety
of reasons it might fail to do so, so you might want to go and delete all
compiled files.

Antonis Christofides
http://djangodeployment.com

On 01/04/2017 05:33 PM, Richard Jackson wrote:
> Hi there
>
> I've been having some issues with my Mezzanine-powered site and have solved
> all issues locally (including a fresh migration covering all additional
> models). However, when I try to deploy the site to the server (WebFaction) I'm
> given a NameError:
>
> [81.95.157.172] out:   File "vital_theme/admin.py", line 67, in 
> [81.95.157.172] out: class 
> TuitionContentInline(StackedDynamicInlineAdmin):
> [81.95.157.172] out:   File "vital_theme/admin.py", line 68, in
> TuitionContentInline
> [81.95.157.172] out: model = TuitionContent
> [81.95.157.172] out: NameError: name 'TuitionContent' is not defined
>
> At present *admin.py* looks like:
>
> ***START***
>
> from models import (...
> Tuition, TuitionContactIconBox, TuitionContent,
> ...)
>
> class TuitionContentInline(StackedDynamicInlineAdmin):
> model = TuitionContent
>
> ***END***
>
> ...and* models.py* contains:
>
> ***START***
>
> [...]
> # Tutorial Page
> class Tuition(Page):
> heading = models.CharField(
> max_length=200,
> blank=True,
> help_text="The heading at the top of the page")
> subheading = models.CharField(
> max_length=200, blank=True,
> help_text="The subheading just below the heading")
> blurb = models.TextField(
> blank=True,
> help_text="Text under the headings")
>
> class Meta:
> verbose_name = _("Tuition")
> verbose_name_plural = _("Tuitions")
>
>
> class TuitionContent(Orderable, RichText):
> tuition = models.ForeignKey(Tuition, related_name="contents")
> title = models.CharField("Title", max_length=50)
> icon = models.CharField("Icon", max_length=50)
>
> ***END***
>
> Can anyone think of any reasons that this isn't deploying correctly, though is
> working fine locally? I may have missed important details so please let me
> know if this is the case.
>
> Thanks for your time,
>
> Rich
>
> -- 
> 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
> <mailto:django-users+unsubscr...@googlegroups.com>.
> To post to this group, send email to django-users@googlegroups.com
> <mailto:django-users@googlegroups.com>.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/1ccf8f63-cdc6-404a-aeef-12efc630b9a6%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/1ccf8f63-cdc6-404a-aeef-12efc630b9a6%40googlegroups.com?utm_medium=email_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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a4c9b72f-c33b-9c77-6ac9-72486340a8e7%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Deployment/NameError Problem

2017-01-04 Thread Richard Jackson
Hi there

I've been having some issues with my Mezzanine-powered site and have solved 
all issues locally (including a fresh migration covering all additional 
models). However, when I try to deploy the site to the server (WebFaction) 
I'm given a NameError:

[81.95.157.172] out:   File "vital_theme/admin.py", line 67, in 
[81.95.157.172] out: class 
TuitionContentInline(StackedDynamicInlineAdmin):
[81.95.157.172] out:   File "vital_theme/admin.py", line 68, in 
TuitionContentInline
[81.95.157.172] out: model = TuitionContent
[81.95.157.172] out: NameError: name 'TuitionContent' is not defined

At present *admin.py* looks like:

***START***

from models import (...
Tuition, TuitionContactIconBox, TuitionContent,
...)

class TuitionContentInline(StackedDynamicInlineAdmin):
model = TuitionContent

***END***

...and* models.py* contains:

***START***

[...]
# Tutorial Page
class Tuition(Page):
heading = models.CharField(
max_length=200,
blank=True,
help_text="The heading at the top of the page")
subheading = models.CharField(
max_length=200, blank=True,
help_text="The subheading just below the heading")
blurb = models.TextField(
blank=True,
help_text="Text under the headings")

class Meta:
verbose_name = _("Tuition")
verbose_name_plural = _("Tuitions")


class TuitionContent(Orderable, RichText):
tuition = models.ForeignKey(Tuition, related_name="contents")
title = models.CharField("Title", max_length=50)
icon = models.CharField("Icon", max_length=50)

***END***

Can anyone think of any reasons that this isn't deploying correctly, though 
is working fine locally? I may have missed important details so please let 
me know if this is the case.

Thanks for your time,

Rich

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1ccf8f63-cdc6-404a-aeef-12efc630b9a6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError: name 's' is not defined

2016-02-02 Thread Michal Petrucha
On Mon, Feb 01, 2016 at 07:39:48PM -0800, Murray Baker wrote:
> *```*
> *Murrays-MacBook-Pro:mysite MurrayBaker89$ python manage.py sqlmigrate 
> polls 0001*
> *Traceback (most recent call last):*
> *  File "manage.py", line 10, in *
> *execute_from_command_line(sys.argv)*
> *  File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 353, in execute_from_command_line*
> *utility.execute()*
> *  File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
>  
> line 302, in execute*
> *settings.INSTALLED_APPS*
> *  File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 55, in __getattr__*
> *self._setup(name)*
> *  File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 43, in _setup*
> *self._wrapped = Settings(settings_module)*
> *  File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
>  
> line 99, in __init__*
> *mod = importlib.import_module(self.SETTINGS_MODULE)*
> *  File 
> "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",
>  
> line 37, in import_module*
> *__import__(name)*
> *  File "/Users/MurrayBaker89/Documents/dja1/mysite/mysite/settings.py", 
> line 113, in *
> *s*
> *NameError: name 's' is not defined*
> 
> *```*

As the error above says, line 113 of
/Users/MurrayBaker89/Documents/dja1/mysite/mysite/settings.py cotains
just a single character "s", which is not defined in the file.

By the way, something seems to be wrong with your email client, it
looks like it wrapped every line in asterisks, which makes them harder
to read.

Good luck,

Michal

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160202121235.GK19381%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


NameError: name 's' is not defined

2016-02-02 Thread Murray Baker
*```*
*Murrays-MacBook-Pro:mysite MurrayBaker89$ python manage.py sqlmigrate 
polls 0001*
*Traceback (most recent call last):*
*  File "manage.py", line 10, in *
*execute_from_command_line(sys.argv)*
*  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 353, in execute_from_command_line*
*utility.execute()*
*  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/core/management/__init__.py",
 
line 302, in execute*
*settings.INSTALLED_APPS*
*  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 55, in __getattr__*
*self._setup(name)*
*  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 43, in _setup*
*self._wrapped = Settings(settings_module)*
*  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/conf/__init__.py",
 
line 99, in __init__*
*mod = importlib.import_module(self.SETTINGS_MODULE)*
*  File 
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py",
 
line 37, in import_module*
*__import__(name)*
*  File "/Users/MurrayBaker89/Documents/dja1/mysite/mysite/settings.py", 
line 113, in *
*s*
*NameError: name 's' is not defined*

*```*

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bc16afb6-e8b3-4f57-9365-0fa6b646fa68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError: name 'reciever' is not defined

2015-06-20 Thread Marco Neumann
Thanks for your response.

I need a extra pair of eyes. :-)

Op zaterdag 20 juni 2015 00:27:07 UTC+2 schreef Marco Neumann:
>
> Hi There,
>
> Im stuck on above error. Anyone a hint? Many thanks
>
> My code in models.py:
>
> from django.db.models.signals import post_save
> from django.dispatch import receiver
> from django.db import models
> from django.contrib.auth.models import User
>
> class UserProfile(models.Model):
> user = models.OneToOneField(User)
> bio = models.TextField(max_length=500, null=True, blank=True)
> 
> def __unicode__(self):
> return self.user.username
> 
> @reciever(post_save, sender=User)
> def create_profile(sender, instance, created, **kwargs):
> if created:
> profile, new = UserProfile.objects.get_or_created(user=instance)
>
>
>
>

-- 
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/7b3d8e1d-bd85-48db-9501-cb6e16b6d325%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError: name 'reciever' is not defined

2015-06-20 Thread Marco Neumann
Need a extra pair of eyes. :-)

Thanks for your answer

Op zaterdag 20 juni 2015 00:43:00 UTC+2 schreef James Schneider:
>
> Check your spelling for receiver...
>
> -James
> On Jun 19, 2015 3:26 PM, "Marco Neumann"  > wrote:
>
>> Hi There,
>>
>> Im stuck on above error. Anyone a hint? Many thanks
>>
>> My code in models.py:
>>
>> from django.db.models.signals import post_save
>> from django.dispatch import receiver
>> from django.db import models
>> from django.contrib.auth.models import User
>>
>> class UserProfile(models.Model):
>> user = models.OneToOneField(User)
>> bio = models.TextField(max_length=500, null=True, blank=True)
>> 
>> def __unicode__(self):
>> return self.user.username
>> 
>> @reciever(post_save, sender=User)
>> def create_profile(sender, instance, created, **kwargs):
>> if created:
>> profile, new = UserProfile.objects.get_or_created(user=instance)
>>
>>
>>
>>  -- 
>> 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9dd30923-5e94-49d1-a321-a199138777a5%40googlegroups.com
>>  
>> 
>> .
>> 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/259b90c0-4ec2-419d-8e9c-19f3d9a802e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError: name 'reciever' is not defined

2015-06-19 Thread James Schneider
Check your spelling for receiver...

-James
On Jun 19, 2015 3:26 PM, "Marco Neumann"  wrote:

> Hi There,
>
> Im stuck on above error. Anyone a hint? Many thanks
>
> My code in models.py:
>
> from django.db.models.signals import post_save
> from django.dispatch import receiver
> from django.db import models
> from django.contrib.auth.models import User
>
> class UserProfile(models.Model):
> user = models.OneToOneField(User)
> bio = models.TextField(max_length=500, null=True, blank=True)
>
> def __unicode__(self):
> return self.user.username
>
> @reciever(post_save, sender=User)
> def create_profile(sender, instance, created, **kwargs):
> if created:
> profile, new = UserProfile.objects.get_or_created(user=instance)
>
>
>
>  --
> 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/9dd30923-5e94-49d1-a321-a199138777a5%40googlegroups.com
> 
> .
> 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/CA%2Be%2BciVP8jfNaxuFii_QgV%2BsZhuDGikdzJ7%3D4cMyeO%3DaEke61g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


NameError: name 'reciever' is not defined

2015-06-19 Thread Marco Neumann
Hi There,

Im stuck on above error. Anyone a hint? Many thanks

My code in models.py:

from django.db.models.signals import post_save
from django.dispatch import receiver
from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
user = models.OneToOneField(User)
bio = models.TextField(max_length=500, null=True, blank=True)

def __unicode__(self):
return self.user.username

@reciever(post_save, sender=User)
def create_profile(sender, instance, created, **kwargs):
if created:
profile, new = UserProfile.objects.get_or_created(user=instance)



-- 
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/9dd30923-5e94-49d1-a321-a199138777a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError name 'lang' is not defined, corresponds to name 'polls' is not defined,

2014-07-08 Thread Tom Evans
On Tue, Jul 8, 2014 at 6:54 PM, Rodrigo Caicedo
 wrote:
> In your INSTALLED_APPS part in the configuration file, the registered
> application is called 'langu', and not 'lang'. If you copied your code,
> that's your problem.

I don't think so, he has a project named "lang" (with "lang.settings")
that has an app named "langu".

>
>
>
> On Sunday, July 6, 2014 2:26:15 AM UTC-5, gintare wrote:
>>
>> I am trying to create a project "lang" according Django documentation part
>> 1-4 tutorial.
>>
>> Folder structure:
>>
>> Scripts\lang\lang\_init_.py
>> Scripts\lang\lang\settings.py
>> Scripts\lang\lang\urls.py
>>
>> Scripts\lang\langu\_init_.py
>> Scripts\lang\langu\admin.py
>> Scripts\lang\langu\models.py
>> Scripts\lang\langu\urlsu.py
>> Scripts\lang\langu\views.py

Where is manage.py? Should be at Scripts\lang\manage.py and have
appropriate contents.

I think "lang" and "langu" are not being picked up as python modules
because Scripts\lang is not being added to sys.path, which is one half
of manage.py's two jobs.

Cheers

Tom

-- 
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/CAFHbX1J4xM8cECmdoix2vViNTb9DYJ1Mf8GrQ8%2BtCCxF58zdqA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError name 'lang' is not defined, corresponds to name 'polls' is not defined,

2014-07-08 Thread Rodrigo Caicedo
In your INSTALLED_APPS part in the configuration file, the registered 
application is called 'langu', and not 'lang'. If you copied your code, 
that's your problem.



On Sunday, July 6, 2014 2:26:15 AM UTC-5, gintare wrote:
>
> I am trying to create a project "lang" according Django documentation part 
> 1-4 tutorial.
>
> Folder structure:
>
> Scripts\lang\lang\_init_.py
> Scripts\lang\lang\settings.py
> Scripts\lang\lang\urls.py
>
> Scripts\lang\langu\_init_.py
> Scripts\lang\langu\admin.py
> Scripts\lang\langu\models.py
> Scripts\lang\langu\urlsu.py
> Scripts\lang\langu\views.py
>
> * Scripts\lang\lang\urls.py
> from django.conf.urls import patterns, include, url
>
> from django.contrib import admin
> admin.autodiscover()
>
> from langu import views
>
> urlpatterns = patterns('',   
> url(r'^langu/', include(langu.urlsu)),
> url(r'^admin/', include(admin.site.urls)),
> )
>
>
> * Scripts\lang\langu\urlsu.py
> from django.conf.urls import patterns, url
>
> from langu import views
>
> urlpatterns = patterns('',
> url(r'^$', views.index, name='index')
> )
>
>
> * Scripts\lang\lang\settings.py
> ... 
> INSTALLED_APPS = (
> 'django.contrib.admin',
> 'langu',
> )
> ROOT_URLCONF = 'lang.urls'
> 
>
>
>
>
> * Scripts\lang\langu\views.py
> from django.shortcuts import render
> from django.http import HttpResponse
>
> def index(request):
> return HttpResponse("Hello, world. You're at the poll index.")
>
>
>

-- 
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/a5d1e185-49e5-44aa-a13b-d496bec66375%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


NameError name 'lang' is not defined, corresponds to name 'polls' is not defined,

2014-07-06 Thread gintare
I am trying to create a project "lang" according Django documentation part 
1-4 tutorial.

Folder structure:

Scripts\lang\lang\_init_.py
Scripts\lang\lang\settings.py
Scripts\lang\lang\urls.py

Scripts\lang\langu\_init_.py
Scripts\lang\langu\admin.py
Scripts\lang\langu\models.py
Scripts\lang\langu\urlsu.py
Scripts\lang\langu\views.py

* Scripts\lang\lang\urls.py
from django.conf.urls import patterns, include, url

from django.contrib import admin
admin.autodiscover()

from langu import views

urlpatterns = patterns('',   
url(r'^langu/', include(langu.urlsu)),
url(r'^admin/', include(admin.site.urls)),
)


* Scripts\lang\langu\urlsu.py
from django.conf.urls import patterns, url

from langu import views

urlpatterns = patterns('',
url(r'^$', views.index, name='index')
)


* Scripts\lang\lang\settings.py
... 
INSTALLED_APPS = (
'django.contrib.admin',
'langu',
)
ROOT_URLCONF = 'lang.urls'





* Scripts\lang\langu\views.py
from django.shortcuts import render
from django.http import HttpResponse

def index(request):
return HttpResponse("Hello, world. You're at the poll index.")


-- 
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/7e9d6515-aa6b-402a-a540-c9bf4201f33f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
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/ADk/4X45ORinrbU/s1600/Screen+Shot+2014-06-11+at+22.05.07.png>

<https://lh5.googleusercontent.com/-14oEuDDZj9Y/U5jEtIyEW3I/ADw/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  
> >[mailto:django...@googlegroups.com ] On Behalf Of Patrick C 
> >Sent: Thursday, June 12, 2014 12:52 AM 
> >To: django...@googlegroups.com  
> >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 
>  > 
> >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 , 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 
> > 
> > 

RE: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Ilya Kazakevich
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-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Patrick C
>Sent: Thursday, June 12, 2014 12:52 AM
>To: django-users@googlegroups.com
>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 
>  >
>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 , 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 mode

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Thanks Ilya,

I will go through that this evening - I tend to learn through hardship, 
banging my head off the wall, walking away and finding a moment of clarity, 
I'm quick to understand the logic and approach but I leant the language / 
syntax through repetition. 

On Wednesday, June 11, 2014 9:44:18 PM UTC+1, Ilya Kazakevich wrote:
>
> Hello, 
>
> I believe you should start with Python tutorial: 
> https://docs.python.org/2/tutorial/ 
> After you complete it, you may go to Django tutorial. 
>
> It is generally a good idea to study basic language concepts, syntax and 
> standard library before studying any framework (you've learned PHP _before_ 
> zend/phpcacke/joomla or wordpress, right?:) ) 
>
>
>
> Ilya Kazakevich, 
> JetBrains PyCharm (Best Python/Django IDE) 
> http://www.jetbrains.com/pycharm/ 
> "Develop with pleasure!" 
>
>
> >-Original Message- 
> >From: django...@googlegroups.com  
> >[mailto:django...@googlegroups.com ] On Behalf Of Patrick C 
> >Sent: Thursday, June 12, 2014 12:32 AM 
> >To: django...@googlegroups.com  
> >Cc: ilya.ka...@jetbrains.com  
> >Subject: Re: NameError at /admin/ name 'HoleImage' is not defined 
> > 
> >Hi Ilya, 
> > 
> >Thanks for the swift reply, sorry for the noob question but can you 
> elaborate on 
> >"but you forgot to import HoleImage" - I'm not quite following, I'm sure 
> I will 
> >understand it once explained. 
> > 
> >I'm only about 4 hours into my first workings with Python / Django, 
> perhaps I'm 
> >jumping in a little too quick but so far I have read through a fair bit 
> and live the 
> >prose. 
> > 
> >On Wednesday, June 11, 2014 9:26:30 PM UTC+1, Ilya Kazakevich wrote: 
> > 
> >To use any symbol (including " HoleImage" class) you need to 
> import it first. 
> >You've imported Hole (from holes.models import Hole), but you 
> forgot to 
> >import HoleImage. 
> >So, you got " name 'HoleImage' is not defined " error. 
> > 
> >It is better to use IDE, because it helps you in such cases :) 
> > 
> > 
> > 
> > 
> >Ilya Kazakevich, 
> >JetBrains PyCharm (Best Python/Django IDE) 
> >http://www.jetbrains.com/pycharm/ 
> ><http://www.jetbrains.com/pycharm/> 
> >"Develop with pleasure!" 
> > 
> > 
> >>-Original Message- 
> >>From: django...@googlegroups.com  
> >>[mailto:django...@googlegroups.com  ] On Behalf Of 
> Patrick C 
> >>Sent: Thursday, June 12, 2014 12:19 AM 
> >>To: django...@googlegroups.com  
> >>Subject: NameError at /admin/ name 'HoleImage' is not defined 
> >> 
> >>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): 
> >

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
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 > 
> 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.5Exception Type: NameErrorException Value:
>>
>> name 'Hole' is not defined
>>
>> Exception Location: 
>> /Users/my_laptop/development/golfsmart/holes/admin.py in , line 
>> 12Python 
>> Executable: /usr/bin/pythonPython 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*
>>>>
&g

RE: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Ilya Kazakevich
Hello,

I believe you should start with Python tutorial: 
https://docs.python.org/2/tutorial/ 
After you complete it, you may go to Django tutorial.

It is generally a good idea to study basic language concepts, syntax and 
standard library before studying any framework (you've learned PHP _before_ 
zend/phpcacke/joomla or wordpress, right?:) )



Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Patrick C
>Sent: Thursday, June 12, 2014 12:32 AM
>To: django-users@googlegroups.com
>Cc: ilya.kazakev...@jetbrains.com
>Subject: Re: NameError at /admin/ name 'HoleImage' is not defined
>
>Hi Ilya,
>
>Thanks for the swift reply, sorry for the noob question but can you elaborate 
>on
>"but you forgot to import HoleImage" - I'm not quite following, I'm sure I will
>understand it once explained.
>
>I'm only about 4 hours into my first workings with Python / Django, perhaps I'm
>jumping in a little too quick but so far I have read through a fair bit and 
>live the
>prose.
>
>On Wednesday, June 11, 2014 9:26:30 PM UTC+1, Ilya Kazakevich wrote:
>
>   To use any symbol (including " HoleImage" class) you need to import it 
> first.
>   You've imported Hole (from holes.models import Hole), but you forgot to
>import HoleImage.
>   So, you got " name 'HoleImage' is not defined " error.
>
>   It is better to use IDE, because it helps you in such cases :)
>
>
>
>
>   Ilya Kazakevich,
>   JetBrains PyCharm (Best Python/Django IDE)
>   http://www.jetbrains.com/pycharm/
><http://www.jetbrains.com/pycharm/>
>   "Develop with pleasure!"
>
>
>   >-Original Message-
>   >From: django...@googlegroups.com 
>   >[mailto:django...@googlegroups.com  ] On Behalf Of 
> Patrick C
>   >Sent: Thursday, June 12, 2014 12:19 AM
>   >To: django...@googlegroups.com 
>   >Subject: NameError at /admin/ name 'HoleImage' is not defined
>   >
>   >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/
><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
>   >Pytho

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Jorge Andrés Vergara Ebratt
Oh and in the last line, admin.site.register, use the model you want to
register in the Admin
On Jun 11, 2014 3:41 PM, "Patrick C" <patrick.vibef...@gmail.com> 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:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.6.5Exception Type:NameErrorException Value:
>
> name 'Hole' is not defined
>
> Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py
> in , line 12Python Executable:/usr/bin/pythonPython 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:GETRequest URL: http://127.0.0.1:8000/admin/Django
>>> Version: 1.6.5Exception Type: NameErrorException Value:
>>>
>>> name 'HoleImage' is not defined
>>>
>>> Exception Location: /Users/my_laptop/development/golfsmart/holes/admin.py
>>> in HoleImageInline, line 5Python Executable: /usr/bin/pythonPython
>>> 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 subscr

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Jorge Andrés Vergara Ebratt
When you import HoleImage don't remove Hole :)
On Jun 11, 2014 3:41 PM, "Patrick C" <patrick.vibef...@gmail.com> 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:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.6.5Exception Type:NameErrorException Value:
>
> name 'Hole' is not defined
>
> Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py
> in , line 12Python Executable:/usr/bin/pythonPython 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:GETRequest URL: http://127.0.0.1:8000/admin/Django
>>> Version: 1.6.5Exception Type: NameErrorException Value:
>>>
>>> name 'HoleImage' is not defined
>>>
>>> Exception Location: /Users/my_laptop/development/golfsmart/holes/admin.py
>>> in HoleImageInline, line 5Python Executable: /usr/bin/pythonPython
>>> 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 "

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
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:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
1.6.5Exception Type:NameErrorException Value:

name 'Hole' is not defined

Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py in 
, line 12Python Executable:/usr/bin/pythonPython 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:GETRequest URL: http://127.0.0.1:8000/admin/Django 
>> Version: 1.6.5Exception Type: NameErrorException Value:
>>
>> name 'HoleImage' is not defined
>>
>> Exception Location: 
>> /Users/my_laptop/development/golfsmart/holes/admin.py in HoleImageInline, 
>> line 5Python Executable: /usr/bin/pythonPython 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.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google

Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Jorge Andrés Vergara Ebratt
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.vibef...@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:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.6.5Exception Type:NameErrorException Value:
>
> name 'HoleImage' is not defined
>
> Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py
> in HoleImageInline, line 5Python Executable:/usr/bin/pythonPython 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+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/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com?utm_medium=email_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/CAAeX05H1F0sX5_2LtaRjMb39gX8gT7YDNdFetGUCrK_xdNpkWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
Hi Ilya,

Thanks for the swift reply, sorry for the noob question but can you 
elaborate on "but you forgot to import HoleImage" - I'm not quite 
following, I'm sure I will understand it once explained.

I'm only about 4 hours into my first workings with Python / Django, perhaps 
I'm jumping in a little too quick but so far I have read through a fair bit 
and live the prose. 

On Wednesday, June 11, 2014 9:26:30 PM UTC+1, Ilya Kazakevich wrote:
>
> To use any symbol (including " HoleImage" class) you need to import it 
> first. 
> You've imported Hole (from holes.models import Hole), but you forgot to 
> import HoleImage. 
> So, you got " name 'HoleImage' is not defined " error. 
>
> It is better to use IDE, because it helps you in such cases :) 
>
>
>
>
> Ilya Kazakevich, 
> JetBrains PyCharm (Best Python/Django IDE) 
> http://www.jetbrains.com/pycharm/ 
> "Develop with pleasure!" 
>
>
> >-Original Message- 
> >From: django...@googlegroups.com  
> >[mailto:django...@googlegroups.com ] On Behalf Of Patrick C 
> >Sent: Thursday, June 12, 2014 12:19 AM 
> >To: django...@googlegroups.com  
> >Subject: NameError at /admin/ name 'HoleImage' is not defined 
> > 
> >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. 
> >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_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/c7b136ef-2763-4b8c-929a-f3d17751cd0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Jorge Andrés Vergara Ebratt
You need to import HoleImage in admin.py
On Jun 11, 2014 3:19 PM, "Patrick C" <patrick.vibef...@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:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
> 1.6.5Exception Type:NameErrorException Value:
>
> name 'HoleImage' is not defined
>
> Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py
> in HoleImageInline, line 5Python Executable:/usr/bin/pythonPython 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+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/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com?utm_medium=email_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/CAAeX05HKSUjsYNzRevcM%2BEvbBomdEhZpd_%3Dytr5SmPquRF8QGA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


RE: NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Ilya Kazakevich
To use any symbol (including " HoleImage" class) you need to import it first. 
You've imported Hole (from holes.models import Hole), but you forgot to import 
HoleImage.
So, you got " name 'HoleImage' is not defined " error.

It is better to use IDE, because it helps you in such cases :)




Ilya Kazakevich,
JetBrains PyCharm (Best Python/Django IDE)
http://www.jetbrains.com/pycharm/
"Develop with pleasure!"


>-Original Message-
>From: django-users@googlegroups.com
>[mailto:django-users@googlegroups.com] On Behalf Of Patrick C
>Sent: Thursday, June 12, 2014 12:19 AM
>To: django-users@googlegroups.com
>Subject: NameError at /admin/ name 'HoleImage' is not defined
>
>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+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/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_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/00c601cf85b3%24568dd690%2403a983b0%24%40JetBrains.com.
For more options, visit https://groups.google.com/d/optout.


NameError at /admin/ name 'HoleImage' is not defined

2014-06-11 Thread Patrick C
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:GETRequest URL:http://127.0.0.1:8000/admin/Django Version:
1.6.5Exception Type:NameErrorException Value:

name 'HoleImage' is not defined

Exception Location:/Users/my_laptop/development/golfsmart/holes/admin.py in 
HoleImageInline, line 5Python Executable:/usr/bin/pythonPython 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+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/7079f896-e765-428f-a95a-6f953ad105f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: NameError "SignUpAdmin"

2014-01-03 Thread Eddie29
Thank you so much! I will post regular code in future for simple fixes. 
Thanks again,
Eddie :)

On Friday, January 3, 2014 5:53:57 PM UTC+8, Daniel Roseman wrote:
>
> On Friday, 3 January 2014 03:02:30 UTC, Eddie29 wrote:
>>
>> Hi Guys, 
>> I am really new to Django and Python. I have recently started learning 
>> them from a course on Udemy and I got stuck on the first example, making a 
>> web app. I'm not sure what I have done wrong but when I run my Django 
>> server it comes up with a NameError. I think the app is supposed to handle 
>> user data, such as first name,last name and email. 
>> Thanks in advance :)
>>
>>
>>
> It would have been better to post the code in your message rather than 
> attaching it - it's only a few lines.
>
> You have an indentation error in admin.py - the `admin.site.register` line 
> should be all the way to the left.
> --
> DR. 
>

-- 
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/88f1852b-491c-47d2-be55-40dd7fff780f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: NameError "SignUpAdmin"

2014-01-03 Thread Daniel Roseman
On Friday, 3 January 2014 03:02:30 UTC, Eddie29 wrote:
>
> Hi Guys, 
> I am really new to Django and Python. I have recently started learning 
> them from a course on Udemy and I got stuck on the first example, making a 
> web app. I'm not sure what I have done wrong but when I run my Django 
> server it comes up with a NameError. I think the app is supposed to handle 
> user data, such as first name,last name and email. 
> Thanks in advance :)
>
>
>
It would have been better to post the code in your message rather than 
attaching it - it's only a few lines.

You have an indentation error in admin.py - the `admin.site.register` line 
should be all the way to the left.
--
DR. 

-- 
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/5f01fbe4-4931-4e1f-8466-ead64951da32%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: NameError "SignUpAdmin"

2014-01-02 Thread Thomas Lockhart

On 1/2/14 7:02 PM, Eddie29 wrote:

Hi Guys,
I am really new to Django and Python. I have recently started learning 
them from a course on Udemy and I got stuck on the first example, 
making a web app. I'm not sure what I have done wrong but when I run 
my Django server it comes up with a NameError. I think the app is 
supposed to handle user data, such as first name,last name and email.
I'm not familiar with the course, and haven't tried to set up your 
project to test.


But I can recommend that you start with the Django tutorial in the 
Django docs (whichever doc version matches the version of Django you are 
using). You might then find it easier to spot small problems in other 
projects such as when you go back to your course.


hth

   - Tom


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+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/468b9c2b-5ff6-412a-bc4f-e3c26aa3ddaf%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.


--
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/52C63201.6040207%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


NameError "SignUpAdmin"

2014-01-02 Thread Eddie29
Hi Guys, 
I am really new to Django and Python. I have recently started learning them 
from a course on Udemy and I got stuck on the first example, making a web 
app. I'm not sure what I have done wrong but when I run my Django server it 
comes up with a NameError. I think the app is supposed to handle user data, 
such as first name,last name and email. 
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+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/468b9c2b-5ff6-412a-bc4f-e3c26aa3ddaf%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
from django.db import models
from django.utils.encoding import smart_unicode
# Create your models here.

class SignUp(models.Model):
first_name = models.CharField(max_length=120, null=True, blank=True)
last_name = models.CharField(max_length=120, null=True, blank=True)
email = models.EmailField()
timestamp = models.DateTimeField(auto_now_add =True, auto_now=False)
updated = models.DateTimeField(auto_now_add=False, auto_now=True)

def __unicode__(self):
return smart_unicode(self.email)
pass
from django.contrib import admin
#Everything Below this

from .models import SignUp


class SignUpAdmin(admin.ModelAdmin):
class Meta:
model = SignUp

admin.site.register(SignUp, SignUpAdmin)
#code


Re: Trouble With Tutorial #1 - NameError: name 'polls' is not defined

2013-10-17 Thread michael . schaefer
Oh my gosh ... I did. LOL. Thanks. I'm an idiot.

-- 
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/22d6b827-a23b-44df-b73c-9abd7e21f7fb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Trouble With Tutorial #1 - NameError: name 'polls' is not defined

2013-10-17 Thread Daniel Roseman
On Thursday, 17 October 2013 21:05:17 UTC+1, michael@farecompare.com 
wrote:

> Hi, 
>
> I'm trying to learn Django and Python at the same time. So I realize this 
> is a really simple issue for a beginner. But since I'm new to this, I could 
> use a little help. 
>
> Basically, I'm going through the tutorial here: 
>
> https://docs.djangoproject.com/en/1.5/intro/tutorial01/
>
> I have gone through it up to the point where we create the polls app with 
> the command: 
>
> python manage.py startapp polls
>
>
> I then created the models in polls/models.py by cutting and pasting from 
> the article. 
>
> Finally, to activate the new model, I went back to my settings.py file and 
> added "polls" to my list of installed apps. However, when I run the 
> command: 
>
> python manage.py sql polls
>
>
> I get the following error: 
>
> Michael$ python manage.py sql polls
> Traceback (most recent call last):
>   File "manage.py", line 10, in 
> execute_from_command_line(sys.argv)
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
>  
> line 453, in execute_from_command_line
> utility.execute()
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
>  
> line 392, in execute
> self.fetch_command(subcommand).run_from_argv(self.argv)
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
>  
> line 263, in fetch_command
> app_name = get_commands()[subcommand]
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
>  
> line 109, in get_commands
> apps = settings.INSTALLED_APPS
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py",
>  
> line 53, in __getattr__
> self._setup(name)
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py",
>  
> line 48, in _setup
> self._wrapped = Settings(settings_module)
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py",
>  
> line 132, in __init__
> mod = importlib.import_module(self.SETTINGS_MODULE)
>   File 
> "/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/utils/importlib.py",
>  
> line 35, in import_module
> __import__(name)
>   File 
> "/Users/Michael/dev/projects/python/ape_admin/ape_admin/settings.py", line 
> 127, in 
> polls,
> NameError: name 'polls' is not defined
>
> I have a folder called "polls" that is in the same directory as my 
> manage.py file. Can someone tell me what I'm doing wrong? Is there a step 
> I'm missing that's not in the tutorial that a Python developer would just 
> know automatically? 
>
> Thanks,
>
> Michael
>
>
Sounds like you've put a line with just
   polls
in your INSTALLED_APPS, instead of
   "polls"
--
DR. 

-- 
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/5c2d606c-5491-4af2-b1bb-09711c04348e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Trouble With Tutorial #1 - NameError: name 'polls' is not defined

2013-10-17 Thread michael . schaefer
Hi, 

I'm trying to learn Django and Python at the same time. So I realize this 
is a really simple issue for a beginner. But since I'm new to this, I could 
use a little help. 

Basically, I'm going through the tutorial here: 

https://docs.djangoproject.com/en/1.5/intro/tutorial01/

I have gone through it up to the point where we create the polls app with 
the command: 

python manage.py startapp polls


I then created the models in polls/models.py by cutting and pasting from 
the article. 

Finally, to activate the new model, I went back to my settings.py file and 
added "polls" to my list of installed apps. However, when I run the 
command: 

python manage.py sql polls


I get the following error: 

Michael$ python manage.py sql polls
Traceback (most recent call last):
  File "manage.py", line 10, in 
execute_from_command_line(sys.argv)
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
 
line 453, in execute_from_command_line
utility.execute()
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
 
line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
 
line 263, in fetch_command
app_name = get_commands()[subcommand]
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/core/management/__init__.py",
 
line 109, in get_commands
apps = settings.INSTALLED_APPS
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py",
 
line 53, in __getattr__
self._setup(name)
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py",
 
line 48, in _setup
self._wrapped = Settings(settings_module)
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/conf/__init__.py",
 
line 132, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
  File 
"/Library/Python/2.7/site-packages/Django-1.5.4-py2.7.egg/django/utils/importlib.py",
 
line 35, in import_module
__import__(name)
  File 
"/Users/Michael/dev/projects/python/ape_admin/ape_admin/settings.py", line 
127, in 
polls,
NameError: name 'polls' is not defined

I have a folder called "polls" that is in the same directory as my 
manage.py file. Can someone tell me what I'm doing wrong? Is there a step 
I'm missing that's not in the tutorial that a Python developer would just 
know automatically? 

Thanks,

Michael

-- 
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/7d2fefe7-e2e6-489e-81dc-01b5cdba9ecc%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: NameError help

2013-03-18 Thread Nicklas af Ekenstam
Never mind. Too tired to realize I had my model classes in the wrong order.


On Tue, Mar 19, 2013 at 1:18 AM, Nicklas af Ekenstam <n...@nille.org> wrote:
> Hello,
>
> I am working on a few models but keep getting "NameError: name 'Area'
> is not defined" while trying to validate. I must be doing something
> wrong but I seem to be unable to figure it out myself and any help
> would be very appreciated as I am now stuck on what I believe is a
> really trivial problem.
>
> The application is called restaurants and here is my models.py:
>
> from django.db import models
> from geoposition.fields import GeopositionField
>
> # Create your models here.
> class Restaurant(models.Model):
> PRICES = (
> ('$', '$'),
> ('$$', '$$'),
> ('$$$', '$$$'),
> ('', ''),
> ('$', '$$'),
> ('unknown', 'Unknown'),
> )
> restaurant_name = models.CharField(max_length=100)
> description = models.TextField(blank=True)
> area = models.ForeignKey(Area)
> labels = models.ManyToManyField(Label)
> cuisine = models.ManyToManyField(Cuisine)
> price_range = models.CharField(max_length=10, choices=PRICES)
> phone = models.CharField(max_length=100,blank=True)
> address = models.TextField()
> subway = models.ForeignKey(Subway, blank=True)
> subway_distance = models.CharField(max_length=100, blank=True)
> opening_hours = models.TextField(blank=True)
> payment_methods = models.ForeignKey(Payment, blank=True)
> website_url = models.URLField(blank=True)
> email = models.EmailField(blank=True)
> position = GeopositionField()
> publication_date = models.DateField()
> def __unicode__(self):
> return self.restaurant_name
>
> class Area(models.Model):
> area_name = models.CharField(max_length=100)
> area_name_chinese = models.CharField(max_length=100)
> def __unicode__(self):
> return self.area_name
>
> class Label(models.Model):
> label_name = models.CharField(max_length=100)
> def __unicode__(self):
> return self.label_name
>
> class Cuisine(models.Model):
> cuisine_name = models.CharField(max_length=100)
> def __unicode__(self):
> return self.cuisine_name
>
> class Payment(models.Model):
> payment_name = models.CharField(max_length=100)
> def __unicode__(self):
> return self.payment_name
>
> class Subway(models.Model):
> subway_name = models.CharField(max_length=100)
> subway_name_chinese = models.CharField(max_length=100, blank=True)
> def __unicode__(self):
> return self.subway_name
>
> I am trying to hook this up with the admin interface using an admin.py
> file that looks like this:
>
> from django.contrib import admin
> from shanghai.restaurants.models import Label, Payment, Area,
> Restaurant, Subway, Cuisine
>
> class LabelAdmin(admin.ModelAdmin):
> list_display = ('label_name',)
> ordering = ['label_name']
>
> class PaymentAdmin(admin.ModelAdmin):
> list_display = ('payment_name',)
> ordering = ['payment_name']
>
> class AreaAdmin(admin.ModelAdmin):
> list_display = ('area_name',)
> ordering = ['area_name']
>
> class RestaurantAdmin(admin.ModelAdmin):
> list_display = ('restaurant_name', 'area', 'publication_date',)
> ordering = ['publication_date']
>
> class SubwayAdmin(admin.ModelAdmin):
> list_display = ('subway_name',)
> ordering = ['subway_name']
>
> class CuisineAdmin(admin.ModelAdmin):
> list_display = ('cuisine_name',)
> ordering = ['cuisine_name']
>
> admin.site.register(Label, LabelAdmin)
> admin.site.register(Payment, PaymentAdmin)
> admin.site.register(Area, AreaAdmin)
> admin.site.register(Restaurant, RestaurantAdmin)
> admin.site.register(Subway, SubwayAdmin)
> admin.site.register(Cuisine, CuisineAdmin)
>
> Any ideas? Thanks!
>
> - Nicklas

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




NameError help

2013-03-18 Thread Nicklas af Ekenstam
Hello,

I am working on a few models but keep getting "NameError: name 'Area'
is not defined" while trying to validate. I must be doing something
wrong but I seem to be unable to figure it out myself and any help
would be very appreciated as I am now stuck on what I believe is a
really trivial problem.

The application is called restaurants and here is my models.py:

from django.db import models
from geoposition.fields import GeopositionField

# Create your models here.
class Restaurant(models.Model):
PRICES = (
('$', '$'),
('$$', '$$'),
('$$$', '$$$'),
('', ''),
('$', '$$'),
('unknown', 'Unknown'),
)
restaurant_name = models.CharField(max_length=100)
description = models.TextField(blank=True)
area = models.ForeignKey(Area)
labels = models.ManyToManyField(Label)
cuisine = models.ManyToManyField(Cuisine)
price_range = models.CharField(max_length=10, choices=PRICES)
phone = models.CharField(max_length=100,blank=True)
address = models.TextField()
subway = models.ForeignKey(Subway, blank=True)
subway_distance = models.CharField(max_length=100, blank=True)
opening_hours = models.TextField(blank=True)
payment_methods = models.ForeignKey(Payment, blank=True)
website_url = models.URLField(blank=True)
email = models.EmailField(blank=True)
position = GeopositionField()
publication_date = models.DateField()
def __unicode__(self):
return self.restaurant_name

class Area(models.Model):
area_name = models.CharField(max_length=100)
area_name_chinese = models.CharField(max_length=100)
def __unicode__(self):
return self.area_name

class Label(models.Model):
label_name = models.CharField(max_length=100)
def __unicode__(self):
return self.label_name

class Cuisine(models.Model):
cuisine_name = models.CharField(max_length=100)
def __unicode__(self):
return self.cuisine_name

class Payment(models.Model):
payment_name = models.CharField(max_length=100)
def __unicode__(self):
return self.payment_name

class Subway(models.Model):
subway_name = models.CharField(max_length=100)
subway_name_chinese = models.CharField(max_length=100, blank=True)
def __unicode__(self):
return self.subway_name

I am trying to hook this up with the admin interface using an admin.py
file that looks like this:

from django.contrib import admin
from shanghai.restaurants.models import Label, Payment, Area,
Restaurant, Subway, Cuisine

class LabelAdmin(admin.ModelAdmin):
list_display = ('label_name',)
ordering = ['label_name']

class PaymentAdmin(admin.ModelAdmin):
list_display = ('payment_name',)
ordering = ['payment_name']

class AreaAdmin(admin.ModelAdmin):
list_display = ('area_name',)
ordering = ['area_name']

class RestaurantAdmin(admin.ModelAdmin):
list_display = ('restaurant_name', 'area', 'publication_date',)
ordering = ['publication_date']

class SubwayAdmin(admin.ModelAdmin):
list_display = ('subway_name',)
ordering = ['subway_name']

class CuisineAdmin(admin.ModelAdmin):
list_display = ('cuisine_name',)
ordering = ['cuisine_name']

admin.site.register(Label, LabelAdmin)
admin.site.register(Payment, PaymentAdmin)
admin.site.register(Area, AreaAdmin)
admin.site.register(Restaurant, RestaurantAdmin)
admin.site.register(Subway, SubwayAdmin)
admin.site.register(Cuisine, CuisineAdmin)

Any ideas? Thanks!

- Nicklas

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: django 1.5, subclass AbstractUser -> NameError: name 'settings' is not defined

2012-11-02 Thread Michael Muster
On Fri, Nov 02, 2012 at 10:15:11AM +0100, Raffaele Salmaso wrote:
> did you forget to include
> from django.conf import settings
> in /home/michael/www/project/news/models.py?
> 
> --
> | Raffaele Salmaso

Yep, adding it did it :)

Thanks to both of you!

--
Michael

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django 1.5, subclass AbstractUser -> NameError: name 'settings' is not defined

2012-11-02 Thread Raffaele Salmaso
On Fri, Nov 2, 2012 at 10:11 AM, Michael Muster
<michael.mus...@googlemail.com> wrote:
>   File "/home/michael/www/project/news/models.py", line 28, in News
> author = models.ForeignKey(settings.AUTH_USER_MODEL)
> NameError: name 'settings' is not defined
> NameError: name 'settings' is not defined
did you forget to include
from django.conf import settings
in /home/michael/www/project/news/models.py?

--
| Raffaele Salmaso
| http://salmaso.org
| https://bitbucket.org/rsalmaso
| http://gnammo.com

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django 1.5, subclass AbstractUser -> NameError: name 'settings' is not defined

2012-11-02 Thread Michael Muster
On Fri, Nov 02, 2012 at 04:59:35PM +0800, Russell Keith-Magee wrote:
> Can you run:
> 
> ./manage syncdb --traceback
> 
> so we can get the full context of the error message?
> 

Sure, here it is:

:~/www/project$ python manage.py syncdb --traceback
Traceback (most recent call last):
  File "/usr/local/bin/django/django/core/management/base.py", line 222, in 
run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/local/bin/django/django/core/management/base.py", line 251, in 
execute
self.validate()
  File "/usr/local/bin/django/django/core/management/base.py", line 277, in 
validate
num_errors = get_validation_errors(s, app)
  File "/usr/local/bin/django/django/core/management/validation.py", line 34, 
in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/local/bin/django/django/db/models/loading.py", line 165, in 
get_app_errors
self._populate()
  File "/usr/local/bin/django/django/db/models/loading.py", line 71, in 
_populate
self.load_app(app_name, True)
  File "/usr/local/bin/django/django/db/models/loading.py", line 95, in load_app
models = import_module('.models', app_name)
  File "/usr/local/bin/django/django/utils/importlib.py", line 35, in 
import_module
__import__(name)
  File "/home/michael/www/project/news/models.py", line 27, in 
class News(models.Model):
  File "/home/michael/www/project/news/models.py", line 28, in News
author = models.ForeignKey(settings.AUTH_USER_MODEL)
NameError: name 'settings' is not defined
NameError: name 'settings' is not defined


What i forgot in my first post is 
that i reference the user model like this:

author = models.ForeignKey(settings.AUTH_USER_MODEL)

So if i remove that line the syncdb command works 
just fine.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django 1.5, subclass AbstractUser -> NameError: name 'settings' is not defined

2012-11-02 Thread Russell Keith-Magee
(Apologies for the first reply -- my send button misfired…)

Hi Michael,

It sounds like something else - not related to the your User model - is
going wrong with your app; the error about settings doesn't sound like
something the auth system would be generating.

Can you run:

./manage syncdb --traceback

so we can get the full context of the error message?

Yours,
Russ Magee %-)

On Fri, Nov 2, 2012 at 4:34 PM, Michael Muster <
michael.mus...@googlemail.com> wrote:

> Hi,
>
> I am using django 1.5 and want to add an extra
> field to the django user class.
> The documentation says that i have to subclass AbstractUser
> and add extra fields to it.
>
> So i tried it, in my app 'news' i have:
>
> from django.contrib.auth.models import AbstractUser
>
> class cpUser(AbstractUser):
> twitter = models.CharField(max_length=100)
> def __unicode__(self):
> return self.twitter
>
>
> and in my settings.py file:
>
> AUTH_USER_MODEL = 'news.cpUser'
>
> however, after running
>
> $ python manage syncdb
>
> i get
>
> NameError: name 'settings' is not defined
>
> What am i doing wrong?
>
>
>
> best regards,
> Michael
>
> --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django 1.5, subclass AbstractUser -> NameError: name 'settings' is not defined

2012-11-02 Thread Russell Keith-Magee
On Fri, Nov 2, 2012 at 4:34 PM, Michael Muster <
michael.mus...@googlemail.com> wrote:

> Hi,
>
> I am using django 1.5 and want to add an extra
> field to the django user class.
> The documentation says that i have to subclass AbstractUser
> and add extra fields to it.
>
> So i tried it, in my app 'news' i have:
>
> from django.contrib.auth.models import AbstractUser
>
> class cpUser(AbstractUser):
> twitter = models.CharField(max_length=100)
> def __unicode__(self):
> return self.twitter
>
>
> and in my settings.py file:
>
> AUTH_USER_MODEL = 'news.cpUser'
>
> however, after running
>
> $ python manage syncdb
>
> i get
>
> NameError: name 'settings' is not defined
>
> What am i doing wrong?
>
>
>
> best regards,
> Michael
>
> --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



django 1.5, subclass AbstractUser -> NameError: name 'settings' is not defined

2012-11-02 Thread Michael Muster
Hi,

I am using django 1.5 and want to add an extra
field to the django user class.
The documentation says that i have to subclass AbstractUser
and add extra fields to it.

So i tried it, in my app 'news' i have:

from django.contrib.auth.models import AbstractUser

class cpUser(AbstractUser):
twitter = models.CharField(max_length=100)
def __unicode__(self):
return self.twitter


and in my settings.py file:

AUTH_USER_MODEL = 'news.cpUser'

however, after running 

$ python manage syncdb 

i get

NameError: name 'settings' is not defined

What am i doing wrong?



best regards,
Michael

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Kayode Odeyemi
Thanks.

I just simply result to core Django to get done what I need.

On Wed, Aug 10, 2011 at 12:22 PM, Tom Evans wrote:

> On Wed, Aug 10, 2011 at 12:16 PM, Subhranath Chunder
>  wrote:
> > You seem to have heavily used external django apps like django-pagination
> > and django-tables.
> > I haven't used either of them myself, so it'll be difficult for me to
> follow
> > your code like this. Maybe, some else with experience on those might be
> able
> > to help you better.
>
> I was about to reply with exactly this - if you are using 3rd party
> libraries - firstly, you need to tell people you are using them before
> asking for help, and secondly, they often won't play that well with
> each other.
>
> In this case, looking at the code for django-pagination (as there
> appears to be no documentation), the autopaginate tag is expecting to
> be passed a queryset, not whatever a django-tables instance is.
>
> Cheers
>
> Tom
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Tom Evans
On Wed, Aug 10, 2011 at 12:16 PM, Subhranath Chunder
 wrote:
> You seem to have heavily used external django apps like django-pagination
> and django-tables.
> I haven't used either of them myself, so it'll be difficult for me to follow
> your code like this. Maybe, some else with experience on those might be able
> to help you better.

I was about to reply with exactly this - if you are using 3rd party
libraries - firstly, you need to tell people you are using them before
asking for help, and secondly, they often won't play that well with
each other.

In this case, looking at the code for django-pagination (as there
appears to be no documentation), the autopaginate tag is expecting to
be passed a queryset, not whatever a django-tables instance is.

Cheers

Tom

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Subhranath Chunder
You seem to have heavily used external django apps like django-pagination
and django-tables.
I haven't used either of them myself, so it'll be difficult for me to follow
your code like this. Maybe, some else with experience on those might be able
to help you better.

On Wed, Aug 10, 2011 at 4:22 PM, Kayode Odeyemi <drey...@gmail.com> wrote:

> Thanks.
>
> Here's the views.py
>
> class TransactionReport(tables.ModelTable):
> identifier = tables.Column(sortable=False, visible=False)
> created = tables.Column(sortable=True, visible=True)
>
> @classmethod
> def get_reports_paid(self, object, req):
> return TransactionReport(object, order_by=req)
>
> class Meta:
> model = Transaction
>
>
> @login_required
> def display_reports(request):
> logger = logging.getLogger(__name__)
> dataqs = Transaction.objects.filter(paid="TRUE")
> req = request.GET.get('sort', 'created')
> tx = TransactionReport().get_reports_paid(dataqs, req)
>
> return render_to_response('webapp/reports.html', {'table': tx,
> 'rows' : tx.rows})
>
>
> rows is of type TransactionReport.
>
>
> On Wed, Aug 10, 2011 at 11:46 AM, Subhranath Chunder <subhran...@gmail.com
> > wrote:
>
>>
>>
>> On Mon, Aug 8, 2011 at 5:04 PM, Kayode Odeyemi <drey...@gmail.com> wrote:
>>
>>> Hello,
>>>
>>> Please why am I get the following error:
>>>
>>> Caught NameError while rendering: global name 'name' is not defined.
>>>
>>> Initially I did not receive this sort of error, it just surfaced all
>>> off a sudden. I restored my app to the state where everything worked
>>> and I'm still getting the same error.
>>>
>>> Full stack trace:
>>>
>>> Caught NameError while rendering: global name 'name' is not defined
>>> Request Method: GET
>>> Request URL:http://site/reports
>>> Django Version: 1.3
>>> Exception Type: TemplateSyntaxError
>>> Exception Value:
>>> Caught NameError while rendering: global name 'name' is not defined
>>> Exception Location: build\bdist.win32\egg\django_tables\models.py in
>>> _default_render, line 73
>>> Python Executable:  C:\path\apache\apache2.2.10\bin\httpd.exe
>>> Python Version: 2.7.1
>>>
>>> In my template file:
>>>
>>> {% load humanize %}
>>> {% load tables %}
>>> {% load pagination_tags %}
>>> {% autopaginate rows 2 %}
>>>
>> What is data type of this variable named 'rows' in here?
>>
>>
>>>
>>>{% for row in table.rows %}
>>>  
>>>  {% for value in row %}
>>>{{ value }}
>>>  {% endfor %}
>>>  
>>>{% endfor %}
>>>
>>> When i remove the above code from my template the error goes away but
>>> table rows are not displayed.
>>>
>>> Any suggestions please.
>>>
>>> Thanks
>>>
>>> --
>>> 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+unsubscr...@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+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> --
> Odeyemi 'Kayode O.
> http://www.sinati.com. t: @charyorde
>
>  --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Kayode Odeyemi
Thanks.

Here's the views.py

class TransactionReport(tables.ModelTable):
identifier = tables.Column(sortable=False, visible=False)
created = tables.Column(sortable=True, visible=True)

@classmethod
def get_reports_paid(self, object, req):
return TransactionReport(object, order_by=req)

class Meta:
model = Transaction


@login_required
def display_reports(request):
logger = logging.getLogger(__name__)
dataqs = Transaction.objects.filter(paid="TRUE")
req = request.GET.get('sort', 'created')
tx = TransactionReport().get_reports_paid(dataqs, req)

return render_to_response('webapp/reports.html', {'table': tx,
'rows' : tx.rows})


rows is of type TransactionReport.


On Wed, Aug 10, 2011 at 11:46 AM, Subhranath Chunder
<subhran...@gmail.com>wrote:

>
>
> On Mon, Aug 8, 2011 at 5:04 PM, Kayode Odeyemi <drey...@gmail.com> wrote:
>
>> Hello,
>>
>> Please why am I get the following error:
>>
>> Caught NameError while rendering: global name 'name' is not defined.
>>
>> Initially I did not receive this sort of error, it just surfaced all
>> off a sudden. I restored my app to the state where everything worked
>> and I'm still getting the same error.
>>
>> Full stack trace:
>>
>> Caught NameError while rendering: global name 'name' is not defined
>> Request Method: GET
>> Request URL:    http://site/reports
>> Django Version: 1.3
>> Exception Type: TemplateSyntaxError
>> Exception Value:
>> Caught NameError while rendering: global name 'name' is not defined
>> Exception Location: build\bdist.win32\egg\django_tables\models.py in
>> _default_render, line 73
>> Python Executable:  C:\path\apache\apache2.2.10\bin\httpd.exe
>> Python Version: 2.7.1
>>
>> In my template file:
>>
>> {% load humanize %}
>> {% load tables %}
>> {% load pagination_tags %}
>> {% autopaginate rows 2 %}
>>
> What is data type of this variable named 'rows' in here?
>
>
>>
>>{% for row in table.rows %}
>>  
>>  {% for value in row %}
>>{{ value }}
>>  {% endfor %}
>>  
>>{% endfor %}
>>
>> When i remove the above code from my template the error goes away but
>> table rows are not displayed.
>>
>> Any suggestions please.
>>
>> Thanks
>>
>> --
>> 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+unsubscr...@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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Subhranath Chunder
On Mon, Aug 8, 2011 at 5:04 PM, Kayode Odeyemi <drey...@gmail.com> wrote:

> Hello,
>
> Please why am I get the following error:
>
> Caught NameError while rendering: global name 'name' is not defined.
>
> Initially I did not receive this sort of error, it just surfaced all
> off a sudden. I restored my app to the state where everything worked
> and I'm still getting the same error.
>
> Full stack trace:
>
> Caught NameError while rendering: global name 'name' is not defined
> Request Method: GET
> Request URL:http://site/reports
> Django Version: 1.3
> Exception Type: TemplateSyntaxError
> Exception Value:
> Caught NameError while rendering: global name 'name' is not defined
> Exception Location: build\bdist.win32\egg\django_tables\models.py in
> _default_render, line 73
> Python Executable:  C:\path\apache\apache2.2.10\bin\httpd.exe
> Python Version: 2.7.1
>
> In my template file:
>
> {% load humanize %}
> {% load tables %}
> {% load pagination_tags %}
> {% autopaginate rows 2 %}
>
What is data type of this variable named 'rows' in here?


>
>{% for row in table.rows %}
>  
>  {% for value in row %}
>{{ value }}
>  {% endfor %}
>  
>{% endfor %}
>
> When i remove the above code from my template the error goes away but
> table rows are not displayed.
>
> Any suggestions please.
>
> Thanks
>
> --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: {django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-10 Thread Kayode Odeyemi
Please I'm still stuck on this.

I have posted it to SO at
http://stackoverflow.com/questions/6993387/django-tables-caught-nameerror-while-rendering-global-name-name-is-not-defin.
But it's still not getting resolved.

I'll appreciate some pointers to the root cause of this.

Thanks

On Mon, Aug 8, 2011 at 12:34 PM, Kayode Odeyemi <drey...@gmail.com> wrote:

> Hello,
>
> Please why am I get the following error:
>
> Caught NameError while rendering: global name 'name' is not defined.
>
> Initially I did not receive this sort of error, it just surfaced all
> off a sudden. I restored my app to the state where everything worked
> and I'm still getting the same error.
>
> Full stack trace:
>
> Caught NameError while rendering: global name 'name' is not defined
> Request Method: GET
> Request URL:http://site/reports
> Django Version: 1.3
> Exception Type: TemplateSyntaxError
> Exception Value:
> Caught NameError while rendering: global name 'name' is not defined
> Exception Location: build\bdist.win32\egg\django_tables\models.py in
> _default_render, line 73
> Python Executable:  C:\path\apache\apache2.2.10\bin\httpd.exe
> Python Version: 2.7.1
>
> In my template file:
>
> {% load humanize %}
> {% load tables %}
> {% load pagination_tags %}
> {% autopaginate rows 2 %}
>
>{% for row in table.rows %}
>  
>  {% for value in row %}
>{{ value }}
>  {% endfor %}
>  
>{% endfor %}
>
> When i remove the above code from my template the error goes away but
> table rows are not displayed.
>
> Any suggestions please.
>
> Thanks
>
> --
> 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+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
Odeyemi 'Kayode O.
http://www.sinati.com. t: @charyorde

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



{django-tables} Caught NameError while rendering: global name 'name' is not defined.

2011-08-08 Thread Kayode Odeyemi
Hello,

Please why am I get the following error:

Caught NameError while rendering: global name 'name' is not defined.

Initially I did not receive this sort of error, it just surfaced all
off a sudden. I restored my app to the state where everything worked
and I'm still getting the same error.

Full stack trace:

Caught NameError while rendering: global name 'name' is not defined
Request Method: GET
Request URL:http://site/reports
Django Version: 1.3
Exception Type: TemplateSyntaxError
Exception Value:
Caught NameError while rendering: global name 'name' is not defined
Exception Location: build\bdist.win32\egg\django_tables\models.py in
_default_render, line 73
Python Executable:  C:\path\apache\apache2.2.10\bin\httpd.exe
Python Version: 2.7.1

In my template file:

{% load humanize %}
{% load tables %}
{% load pagination_tags %}
{% autopaginate rows 2 %}

{% for row in table.rows %}
  
  {% for value in row %}
{{ value }}
  {% endfor %}
  
{% endfor %}

When i remove the above code from my template the error goes away but
table rows are not displayed.

Any suggestions please.

Thanks

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NameError at /admin/

2011-07-20 Thread lokesh
Hi,

In admin.py yourprojectname is missing. Instead of from
news.models import Articles, try from yourprojectname.news.models
import Articles.
Lokesh S

On Jul 18, 7:06 pm, arthur_mwai <mwaigar...@gmail.com> wrote:
> I wanted to register an app called "news" in the admin site and i got
> this error:
>
> NameError at /admin/
> name 'news' is not defined
> Request Method: GET
> Request URL:    http://127.0.0.1:8000/admin/
> Django Version: 1.3
> Exception Type: NameError
> Exception Value:
> name 'news' is not defined
> Exception Location:     /home/arthur/code_testing/news/admin.py in
> , line 3
>
> here is my admi.py:
>
> from django.contrib import admin
> from news.models import Articles
>
> class ArticlesAdmin(admin.ModelAdmin):
>   pass
> admin.site.register(Articles,ArticlesAdmin)
>
> and below is my urls.py
> from django.conf.urls.defaults import patterns, include, url
>
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>     # Examples:
>     # url(r'^$', 'code_testing.views.home', name='home'),
>     # url(r'^code_testing/', include('code_testing.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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: logout problem - NameError - newbie

2011-04-23 Thread Jirka Vejrazka
Hi did you notice in tutorial (or docs) that view names in urls.py are
usually strings, not functions? So, if you use 'farewell' in urls.py,
you should be fine.

  HTH

 Jirka

On 22/04/2011, Marg Wilkinson  wrote:
> Hi,
>
> I'm a total newbie slogging my way through a tutorial. I've reached an
> impasse with logging off
>
> In views my code includes
>
> 
> from django.contrib.auth import logout
>
> def farewell(request):
> logout(request)
> return HttpResponseRedirect('/')
> ---
>
> and urls.py has the lines
>
> -
> urlpatterns = patterns('',
>  url(r'^admin/', include(admin.site.urls)),
>  url(r'^$', main_page),
>  url(r'^user/(\w+)/$', user_page),
>  url(r'^login/$', 'django.contrib.auth.views.login',
> {'template_name': 'registration/login.html'}),
>  url(r'^logout/$',farewell),
> 
>
>
> http://127.0.0.1:8000/farewell  (or anything after the 8000/)  gives
> me an error
> -
> Exception Value:
>
> name 'farewell' is not defined
> 
>
> OK  but farewell looks defined to me in views.py,so what am I
> missing?
>
> (BTW - originally I was trying to use logout for my def instead of
> farewell, with appropriate urls.py changes - same error except it
> specified that "logout" was not defined.)
>
> Can anyone please point a newbie in the right direction?
>
> --
> 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+unsubscr...@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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: logout problem - NameError - newbie

2011-04-22 Thread Marg Wilkinson
Good call - thanks Shawn - totally forgot to check the imports - the
joys of being a newbie.

Thanks for the quick reply.

On Apr 23, 11:24 am, Shawn Milochik  wrote:
> It's probably that you didn't import 'farewell' from views.py in
> urls.py, so it's not in scope.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: logout problem - NameError - newbie

2011-04-22 Thread Shawn Milochik
It's probably that you didn't import 'farewell' from views.py in
urls.py, so it's not in scope.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



logout problem - NameError - newbie

2011-04-22 Thread Marg Wilkinson
Hi,

I'm a total newbie slogging my way through a tutorial. I've reached an
impasse with logging off

In views my code includes


from django.contrib.auth import logout

def farewell(request):
logout(request)
return HttpResponseRedirect('/')
---

and urls.py has the lines

-
urlpatterns = patterns('',
 url(r'^admin/', include(admin.site.urls)),
 url(r'^$', main_page),
 url(r'^user/(\w+)/$', user_page),
 url(r'^login/$', 'django.contrib.auth.views.login',
{'template_name': 'registration/login.html'}),
 url(r'^logout/$',farewell),



http://127.0.0.1:8000/farewell  (or anything after the 8000/)  gives
me an error
-
Exception Value:

name 'farewell' is not defined


OK  but farewell looks defined to me in views.py,so what am I
missing?

(BTW - originally I was trying to use logout for my def instead of
farewell, with appropriate urls.py changes - same error except it
specified that "logout" was not defined.)

Can anyone please point a newbie in the right direction?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NameError at / global name 'volatility' is not defined

2011-04-11 Thread Tongas
Thanks man! "filter(volatility_lte = var)" it's the solution

On Apr 11, 11:16 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Monday, April 11, 2011 2:36:21 PM UTC+1, Tongas wrote:
>
> > Hi!
> > views.py
> > context_processors.py
> > from django.db.models import Avg
> > from orama_financial.models import TargetFund
>
> > def fund_context(request):
> >   avg_all = TargetFund.objects.all().aggregate(Avg('volatility'))
> >   top_1 = TargetFund.objects.order_by('volatility').filter(volatility
> > < avg_all['volatility__avg']) #line 7
> >   return {
> >     'avg_all':avg_all['volatility__avg'],
> >   }
>
> > Error:
> > NameError at /
> > global name 'volatility' is not defined
> > 
> > What is the problem?
>
> You can't use < in a filter expression.
> Seehttp://docs.djangoproject.com/en/1.3/ref/models/querysets/#field-lookups
> --
> DR.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NameError at / global name 'volatility' is not defined

2011-04-11 Thread Tongas
Thanks man!
How to use ORM to "where volatility <= 30" ?

On Apr 11, 11:16 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Monday, April 11, 2011 2:36:21 PM UTC+1, Tongas wrote:
>
> > Hi!
> > views.py
> > context_processors.py
> > from django.db.models import Avg
> > from orama_financial.models import TargetFund
>
> > def fund_context(request):
> >   avg_all = TargetFund.objects.all().aggregate(Avg('volatility'))
> >   top_1 = TargetFund.objects.order_by('volatility').filter(volatility
> > < avg_all['volatility__avg']) #line 7
> >   return {
> >     'avg_all':avg_all['volatility__avg'],
> >   }
>
> > Error:
> > NameError at /
> > global name 'volatility' is not defined
> > 
> > What is the problem?
>
> You can't use < in a filter expression.
> Seehttp://docs.djangoproject.com/en/1.3/ref/models/querysets/#field-lookups
> --
> DR.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: NameError at / global name 'volatility' is not defined

2011-04-11 Thread Daniel Roseman
On Monday, April 11, 2011 2:36:21 PM UTC+1, Tongas wrote:
>
> Hi! 
> views.py 
> context_processors.py 
> from django.db.models import Avg 
> from orama_financial.models import TargetFund 
>
> def fund_context(request): 
>   avg_all = TargetFund.objects.all().aggregate(Avg('volatility')) 
>   top_1 = TargetFund.objects.order_by('volatility').filter(volatility 
> < avg_all['volatility__avg']) #line 7 
>   return { 
> 'avg_all':avg_all['volatility__avg'], 
>   } 
>
> Error: 
> NameError at / 
> global name 'volatility' is not defined 
> 
> What is the problem?


You can't use < in a filter expression. 
See http://docs.djangoproject.com/en/1.3/ref/models/querysets/#field-lookups
--
DR.

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



NameError at / global name 'volatility' is not defined

2011-04-11 Thread Tongas
Hi!
views.py
from django.http import HttpResponse
from django.template import Context, RequestContext
from django.shortcuts import render_to_response
from context_processors import fund_context
from orama_financial.models import TargetFund

def home(request):
c = RequestContext( request, {
'message': 'Hello World!',
}, processors=[fund_context] )
return render_to_response('home.html',c)

context_processors.py
from django.db.models import Avg
from orama_financial.models import TargetFund

def fund_context(request):
  avg_all   = TargetFund.objects.all().aggregate(Avg('volatility'))
  top_1 = TargetFund.objects.order_by('volatility').filter(volatility
< avg_all['volatility__avg']) #line 7
  return {
'avg_all':avg_all['volatility__avg'],
  }

Error:
NameError at /
global name 'volatility' is not defined

Request Method: GET
Request URL:http://127.0.0.1:8000/
Django Version: 1.3
Exception Type:     NameError
Exception Value:

global name 'volatility' is not defined

Exception Location: /home/mrlugh/djangoprojects/orama/
context_processors.py in fund_context, line 7
Python Executable:  /usr/bin/python
Python Version: 2.6.5
Python Path:

['/home/mrlugh/djangoprojects/orama',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib/python2.6/lib-old',
 '/usr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6/dist-packages',
 '/usr/lib/python2.6/dist-packages/PIL',
 '/usr/lib/pymodules/python2.6',
 '/usr/lib/pymodules/python2.6/gtk-2.0',
 '/usr/local/lib/python2.6/dist-packages']

What is the problem?

-- 
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+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Django NameError in first web app

2010-11-16 Thread Recep KIRMIZI
You should uncomment admin from the top of the urls.py
it should be imported
from django.contrib import admin
and also
admin.autodiscover()


Sal, 2010-11-16 tarihinde 03:49 -0800 saatinde, frank yazdı:
> hi all,
> 
> i just doing Django..tried the first example in Django book...i
> encountered problem at admin page. it says that admin is not defined.
> i followed each step in tutorial and i am able to run django server
> also. pls help me to solve it.
> i am adding error output here.
> 
> Environment:
> 
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/
> Django Version: 1.2.3
> Python Version: 2.7.0
> Installed Applications:
> ['django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'mysite.polls',
> 'django.contrib.admin']
> Installed Middleware:
> ('django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.middleware.csrf.CsrfViewMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.contrib.messages.middleware.MessageMiddleware')
> 
> 
> Traceback:
> File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
> get_response
> 91. request.path_info)
> File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> resolve
> 215. for pattern in self.url_patterns:
> File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> _get_url_patterns
> 244. patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
> File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
> _get_urlconf_module
> 239. self._urlconf_module = import_module(self.urlconf_name)
> File "C:\Python27\lib\site-packages\django\utils\importlib.py" in
> import_module
> 35. __import__(name)
> File "C:\Users\Jeyashree\mysite\..\mysite\urls.py" in 
> 15. (r'^admin/', include(admin.site.urls)),
> 
> Exception Type: NameError at /admin/
> Exception Value: name 'admin' is not defined
> 


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



Django NameError in first web app

2010-11-16 Thread frank
hi all,

i just doing Django..tried the first example in Django book...i
encountered problem at admin page. it says that admin is not defined.
i followed each step in tutorial and i am able to run django server
also. pls help me to solve it.
i am adding error output here.

Environment:

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Django Version: 1.2.3
Python Version: 2.7.0
Installed Applications:
['django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'mysite.polls',
'django.contrib.admin']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')


Traceback:
File "C:\Python27\lib\site-packages\django\core\handlers\base.py" in
get_response
91. request.path_info)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
resolve
215. for pattern in self.url_patterns:
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
_get_url_patterns
244. patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)
File "C:\Python27\lib\site-packages\django\core\urlresolvers.py" in
_get_urlconf_module
239. self._urlconf_module = import_module(self.urlconf_name)
File "C:\Python27\lib\site-packages\django\utils\importlib.py" in
import_module
35. __import__(name)
File "C:\Users\Jeyashree\mysite\..\mysite\urls.py" in 
15. (r'^admin/', include(admin.site.urls)),

Exception Type: NameError at /admin/
Exception Value: name 'admin' is not defined

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



Re: Following Django Book, get NameError when accessing certain page

2010-05-04 Thread Karen Tracey
On Sun, May 2, 2010 at 11:16 PM, kelp  wrote:

> Yes, I did that, but for some reason, it is still not working, here's
> the contents of my views.py:
> from django.http import HttpResponse
> from django.shortcuts import render_to_response
> import datetime
>
> def hello(request):
>return HttpResponse("Hello world")
>
> def search_form(request):
>return render_to_response('search_form.html')
>
> def current_datetime(request):
>now = datetime.datetime.now()
>html = "It is now %s." % now
>return HttpResponse(html)
>
>
>
> Does order matter when I am importing?
>
>
Order matters in that you must import something before attempting to use it.

As for getting the error you are getting even though views.py has a
definition for search_form -- that is a bit of a mystery. Somehow the
views.py that has the search_form function defined is not the one that is
being used. I assume you are using the development server? It should have
re-loaded itself when you changed views.py, so that the new code would be
picked up. But you can manually stop and restart it to make sure it is
picking up the latest code.

Karen

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



Re: Following Django Book, get NameError when accessing certain page

2010-05-02 Thread kelp
Yes, I did that, but for some reason, it is still not working, here's
the contents of my views.py:
from django.http import HttpResponse
from django.shortcuts import render_to_response
import datetime

def hello(request):
return HttpResponse("Hello world")

def search_form(request):
return render_to_response('search_form.html')

def current_datetime(request):
now = datetime.datetime.now()
html = "It is now %s." % now
return HttpResponse(html)



Does order matter when I am importing?

On May 2, 7:28 pm, Karen Tracey  wrote:
> On Sun, May 2, 2010 at 10:17 PM, kelp  wrote:
> > Hello,
> > Thanks! That fixed the problem, but now I am getting another one. I am
> > getting an AttributeError now:
> >http://dpaste.com/190232/
>
> Before the url pattern that references views.search_form, the book mentions
> adding:
>
> from django.shortcuts import render_to_response
>
> def search_form(request):
>     return render_to_response('search_form.html')
>
> to your views.py code.  Did you do that?
>
> > This shows up even when I access localhost:8000/hello/ or basically
> > anything I have set up in urls.py
>
> Yes, it would. All of your url patterns must be valid in order for any of
> them to be used. If there is an error processing any of your url patterns
> (as there is now, since it appears the search_form view doe snot exist in
> views.py) it will be reflected on any attempt to evaluate your url pattern
> configuration.
>
> Karen
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Following Django Book, get NameError when accessing certain page

2010-05-02 Thread Karen Tracey
On Sun, May 2, 2010 at 10:17 PM, kelp  wrote:

> Hello,
> Thanks! That fixed the problem, but now I am getting another one. I am
> getting an AttributeError now:
> http://dpaste.com/190232/
>
>
Before the url pattern that references views.search_form, the book mentions
adding:

from django.shortcuts import render_to_response

def search_form(request):
return render_to_response('search_form.html')

to your views.py code.  Did you do that?


> This shows up even when I access localhost:8000/hello/ or basically
> anything I have set up in urls.py
>

Yes, it would. All of your url patterns must be valid in order for any of
them to be used. If there is an error processing any of your url patterns
(as there is now, since it appears the search_form view doe snot exist in
views.py) it will be reflected on any attempt to evaluate your url pattern
configuration.

Karen

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



Re: Following Django Book, get NameError when accessing certain page

2010-05-02 Thread kelp
Hello,
Thanks! That fixed the problem, but now I am getting another one. I am
getting an AttributeError now:
http://dpaste.com/190232/

This shows up even when I access localhost:8000/hello/ or basically
anything I have set up in urls.py

On May 2, 6:49 pm, Karen Tracey  wrote:
> On Sun, May 2, 2010 at 8:41 PM, kelp  wrote:
> > Hello, I am trying to learn Django through the documentation:
> >http://www.djangobook.com/en/2.0/chapter07/
>
> > I am having a view issue, though. When I try to access
> >http://127.0.0.1:8000/search-form/after running my server, I get the
> > following error:
> >http://dpaste.com/190212/
>
> > Here is what I have in my urls.py:
> > (r'^search-form/$', views.search_form),
>
> > Any ideas of what I need to do to fix this problem?
>
> You need to include:
>
> from mysite.books import views
>
> before attempting to reference views.search_form. (This import is included
> in the book example code on the page you reference right above the first
> mention of views.search_form.)
>
> Karen
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To post to this group, send email to django-us...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Following Django Book, get NameError when accessing certain page

2010-05-02 Thread Karen Tracey
On Sun, May 2, 2010 at 8:41 PM, kelp  wrote:

> Hello, I am trying to learn Django through the documentation:
> http://www.djangobook.com/en/2.0/chapter07/
>
> I am having a view issue, though. When I try to access
> http://127.0.0.1:8000/search-form/ after running my server, I get the
> following error:
> http://dpaste.com/190212/
>
> Here is what I have in my urls.py:
> (r'^search-form/$', views.search_form),
>
> Any ideas of what I need to do to fix this problem?
>
>
You need to include:

from mysite.books import views

before attempting to reference views.search_form. (This import is included
in the book example code on the page you reference right above the first
mention of views.search_form.)

Karen

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



Following Django Book, get NameError when accessing certain page

2010-05-02 Thread kelp
Hello, I am trying to learn Django through the documentation:
http://www.djangobook.com/en/2.0/chapter07/

I am having a view issue, though. When I try to access
http://127.0.0.1:8000/search-form/ after running my server, I get the
following error:
http://dpaste.com/190212/

Here is what I have in my urls.py:
(r'^search-form/$', views.search_form),

Any ideas of what I need to do to fix this problem?

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



Re: NameError: name 'Job' is not defined

2009-07-10 Thread Rajesh D



On Jul 10, 8:39 am, bruno <bruno.prig...@gmail.com> wrote:
> Hi,
>
> I'm new in django and I have problem with importing models
>
> I have two class : Job and Event
>
> The Job class defines a method run_job() wich do something and log the
> result by creating a new Event so I need to import the Event class
> from file app/events/models.py
> The Event class reference the job who created the log entry so I need
> to import the Job class from file app/jobs/models.py
>
> file : app/jobs/models.py
> --
>
> from events.models import Event
> ...
>
> class Job(models.Model):
> ...
>     def run_job(self):
>         result = do_something()
>         e = Event(timestamp_gmt=datetime.now(), job=self,
> result=result)
>         self.save()
>         return result
>
> file : app/events/models.py
> --
>
> from jobs.models import Job
> ...
>
> class Event(models.Model):
> ...
>     timestamp_gmt = models.DateTimeField(null=False, editable=False)
>     job = models.ForeignKey(Job, blank=False, null=False)
>
> When I start the serveur I have the following error :
> ...
>   File "app\jobs\models.py", line 8, in 
>     from events.models import Event
>   File "app\events\models.py", line 12, in 
>     class Event(models.Model):
>   File "app\events\models.py", line 14, in Event
>     job = models.ForeignKey(Job, blank=False, null=False)
> NameError: name 'Job' is not defined
>
> It's like Django doesn't like the cross import between Job and Event.
> Anyone can tell me what I'm doing wrong ?
> I think the easy solution is to declar the Event class in the Job
> model file but I'd like to keep them in different files.

You could move the Event import to the run_job method which is the
only place where your code needs it:


file : app/jobs/models.py
--
class Job(models.Model):
...
def run_job(self):
from events.models import Event
result = do_something()
e = Event(timestamp_gmt=datetime.now(), job=self,
result=result)
self.save()
return result

-RD

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError: name 'Job' is not defined

2009-07-10 Thread Ramiro Morales

On Fri, Jul 10, 2009 at 9:39 AM, bruno<bruno.prig...@gmail.com> wrote:
>
> Hi,
>
> I'm new in django and I have problem with importing models
>
> I have two class : Job and Event
>
> The Job class defines a method run_job() wich do something and log the
> result by creating a new Event so I need to import the Event class
> from file app/events/models.py
> The Event class reference the job who created the log entry so I need
> to import the Job class from file app/jobs/models.py
>
>
> [...]
>
> When I start the serveur I have the following error :
> ...
>  File "app\jobs\models.py", line 8, in 
>    from events.models import Event
>  File "app\events\models.py", line 12, in 
>    class Event(models.Model):
>  File "app\events\models.py", line 14, in Event
>    job = models.ForeignKey(Job, blank=False, null=False)
> NameError: name 'Job' is not defined
>
> It's like Django doesn't like the cross import between Job and Event.
> Anyone can tell me what I'm doing wrong ?
> I think the easy solution is to declar the Event class in the Job
> model file but I'd like to keep them in different files.

One solution to this is described in the relevant documentation:

http://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkey

-- 
Ramiro Morales
http://rmorales.net

PyCon 2009 Argentina - Vie 4 y Sab 5 Septiembre
Buenos Aires, Argentina
http://ar.pycon.org/2009/about/

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



NameError: name 'Job' is not defined

2009-07-10 Thread bruno

Hi,

I'm new in django and I have problem with importing models

I have two class : Job and Event

The Job class defines a method run_job() wich do something and log the
result by creating a new Event so I need to import the Event class
from file app/events/models.py
The Event class reference the job who created the log entry so I need
to import the Job class from file app/jobs/models.py


file : app/jobs/models.py
--

from events.models import Event
...

class Job(models.Model):
...
def run_job(self):
result = do_something()
e = Event(timestamp_gmt=datetime.now(), job=self,
result=result)
self.save()
return result


file : app/events/models.py
--

from jobs.models import Job
...

class Event(models.Model):
...
timestamp_gmt = models.DateTimeField(null=False, editable=False)
job = models.ForeignKey(Job, blank=False, null=False)


When I start the serveur I have the following error :
...
  File "app\jobs\models.py", line 8, in 
from events.models import Event
  File "app\events\models.py", line 12, in 
class Event(models.Model):
  File "app\events\models.py", line 14, in Event
job = models.ForeignKey(Job, blank=False, null=False)
NameError: name 'Job' is not defined

It's like Django doesn't like the cross import between Job and Event.
Anyone can tell me what I'm doing wrong ?
I think the easy solution is to declar the Event class in the Job
model file but I'd like to keep them in different files.

Thanks

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError from two models with ForeignKeys to each other

2009-05-28 Thread Karen Tracey
On Thu, May 28, 2009 at 1:11 PM, Alex Gaynor <alex.gay...@gmail.com> wrote:

>
> On Thu, May 28, 2009 at 11:51 AM, enthropyinaction <
> enthropy.in.act...@gmail.com> wrote:
>
>>
>> [snip] File "/home/django/ipdb/../ipdb/nagios/models.py", line 15, in
>> 
>>class APC(models.Model):
>>  File "/home/django/ipdb/../ipdb/nagios/models.py", line 22, in APC
>>switch = models.ForeignKey(Switches)
>> NameError: name 'Switches' is not defined
>>
>> --
>>
>> Basically, I'm putting together an IP address database that will
>> update our network monitor, Nagios.  I wanted to cover all my bases
>> and make it all-inclusive.  Each Switch is on a networked APC so I
>> want it foreign keyed to the APC it's on.  Each APC is networked and
>> so connected to one of the switches in the other model, so I want a
>> foreign key to the Switches model.  I need the foreign keys to set up
>> parenting in Nagios.
>>
>> I've confirmed that this is definately related to the order the models
>> are placed in because reversing the order in models.py changes the
>> name error to complain about the opposite model.  Is there any way
>> around this that I'm missing in the documentation?  I suppose I can
>> remove the foreign key and just make one of them an integer field and
>> relate it manually.  It'd just be easier to make django handle the
>> table relations.  Any suggestions?
>>
>>
>>
> Take a look at:
> http://docs.djangoproject.com/en/dev/ref/models/fields/#lazy-relationshipswhich
>  explains how to do something like this.
>

Except as described (each switch is on *a* networked APC...each APC [is]
...connected to *one* of the switches) it sounds more like the relationship
that is being described here is OneToOne (
http://docs.djangoproject.com/en/dev/topics/db/models/#one-to-one-relationships)
not a pair of ForeignKeys.

So yes, you can fix the error by using quoted names to reference models not
yet defined, but I'm not sure that the models you have defined here are
really describing the relationship you are trying to model.  You may just
need a single OneToOneField in one of the models.

Karen

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError from two models with ForeignKeys to each other

2009-05-28 Thread enthropyinaction

I'm dumb, sorry if I wasted anyone's time.  Found my answer in the
Model Fields Reference (http://docs.djangoproject.com/en/dev/ref/
models/fields/#django.db.models.ForeignKey):

-

If you need to create a relationship on a model that has not yet been
defined, you can use the name of the model, rather than the model
object itself:

class Car(models.Model):
manufacturer = models.ForeignKey('Manufacturer')
# ...

class Manufacturer(models.Model):
# ...

Note, however, that this only refers to models in the same models.py
file -- you cannot use a string to reference a model defined in
another application or imported from elsewhere.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError from two models with ForeignKeys to each other

2009-05-28 Thread Alex Gaynor
On Thu, May 28, 2009 at 11:51 AM, enthropyinaction <
enthropy.in.act...@gmail.com> wrote:

>
> First, an excerpt from my models.py and the traceback:
>
> -
>
> class Loc(models.Model):
>added = models.DateTimeField(auto_now_add=True)
>updated = models.DateTimeField(auto_now=True)
>name = models.CharField(max_length=100)
>alias = models.CharField(max_length=50)
>company = models.CharField('Provided by', max_length=100)
>address = models.CharField(max_length=255)
>phone = models.IntegerField('Contact Phone Number')
>email = models.EmailField('Contact Email', max_length=75)
>acct = models.CharField('Account Number(s)', max_length=255)
>cid = models.CharField('Circuit ID(s)', max_length=255)
>
> class APC(models.Model):
>added = models.DateTimeField(auto_now_add=True)
>updated = models.DateTimeField(auto_now=True)
>name = models.CharField(max_length=100)
>domain = models.CharField(max_length=255)
>ip = models.IPAddressField()
>nagios = models.BooleanField()
>switch = models.ForeignKey(Switches)
>loc = models.ForeignKey(Loc)
>snmp = models.BooleanField()
>
> class Switches(models.Model):
>added = models.DateTimeField(auto_now_add=True)
>updated = models.DateTimeField(auto_now=True)
>name = models.CharField(max_length=100)
>domain = models.CharField(max_length=255)
>ip = models.IPAddressField()
>nagios = models.BooleanField()
>apc = models.ForeignKey(APC)
>loc = models.ForeignKey(Loc)
>snmp = models.BooleanField()
>
> -
>
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 340, in execute_manager
>utility.execute()
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> __init__.py", line 295, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 77, in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 95, in execute
>self.validate()
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> base.py", line 122, in validate
>num_errors = get_validation_errors(s, app)
>  File "/usr/lib/python2.5/site-packages/django/core/management/
> validation.py", line 28, in get_validation_errors
>for (app_name, error) in get_app_errors().items():
>  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 128, in get_app_errors
>self._populate()
>  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 57, in _populate
>self.load_app(app_name, True)
>  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
> line 72, in load_app
>mod = __import__(app_name, {}, {}, ['models'])
>  File "/home/django/ipdb/../ipdb/nagios/models.py", line 15, in
> 
>class APC(models.Model):
>  File "/home/django/ipdb/../ipdb/nagios/models.py", line 22, in APC
>switch = models.ForeignKey(Switches)
> NameError: name 'Switches' is not defined
>
> --
>
> Basically, I'm putting together an IP address database that will
> update our network monitor, Nagios.  I wanted to cover all my bases
> and make it all-inclusive.  Each Switch is on a networked APC so I
> want it foreign keyed to the APC it's on.  Each APC is networked and
> so connected to one of the switches in the other model, so I want a
> foreign key to the Switches model.  I need the foreign keys to set up
> parenting in Nagios.
>
> I've confirmed that this is definately related to the order the models
> are placed in because reversing the order in models.py changes the
> name error to complain about the opposite model.  Is there any way
> around this that I'm missing in the documentation?  I suppose I can
> remove the foreign key and just make one of them an integer field and
> relate it manually.  It'd just be easier to make django handle the
> table relations.  Any suggestions?
>
> >
>
Take a look at:
http://docs.djangoproject.com/en/dev/ref/models/fields/#lazy-relationshipswhich
explains how to do something like this.

Alex

-- 
"I disapprove of what y

NameError from two models with ForeignKeys to each other

2009-05-28 Thread enthropyinaction

First, an excerpt from my models.py and the traceback:

-

class Loc(models.Model):
added = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100)
alias = models.CharField(max_length=50)
company = models.CharField('Provided by', max_length=100)
address = models.CharField(max_length=255)
phone = models.IntegerField('Contact Phone Number')
email = models.EmailField('Contact Email', max_length=75)
acct = models.CharField('Account Number(s)', max_length=255)
cid = models.CharField('Circuit ID(s)', max_length=255)

class APC(models.Model):
added = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100)
domain = models.CharField(max_length=255)
ip = models.IPAddressField()
nagios = models.BooleanField()
switch = models.ForeignKey(Switches)
loc = models.ForeignKey(Loc)
snmp = models.BooleanField()

class Switches(models.Model):
added = models.DateTimeField(auto_now_add=True)
updated = models.DateTimeField(auto_now=True)
name = models.CharField(max_length=100)
domain = models.CharField(max_length=255)
ip = models.IPAddressField()
nagios = models.BooleanField()
apc = models.ForeignKey(APC)
loc = models.ForeignKey(Loc)
snmp = models.BooleanField()

-

Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 340, in execute_manager
utility.execute()
  File "/usr/lib/python2.5/site-packages/django/core/management/
__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 77, in run_from_argv
self.execute(*args, **options.__dict__)
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 95, in execute
self.validate()
  File "/usr/lib/python2.5/site-packages/django/core/management/
base.py", line 122, in validate
num_errors = get_validation_errors(s, app)
  File "/usr/lib/python2.5/site-packages/django/core/management/
validation.py", line 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 128, in get_app_errors
self._populate()
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 57, in _populate
self.load_app(app_name, True)
  File "/usr/lib/python2.5/site-packages/django/db/models/loading.py",
line 72, in load_app
mod = __import__(app_name, {}, {}, ['models'])
  File "/home/django/ipdb/../ipdb/nagios/models.py", line 15, in

class APC(models.Model):
  File "/home/django/ipdb/../ipdb/nagios/models.py", line 22, in APC
switch = models.ForeignKey(Switches)
NameError: name 'Switches' is not defined

--

Basically, I'm putting together an IP address database that will
update our network monitor, Nagios.  I wanted to cover all my bases
and make it all-inclusive.  Each Switch is on a networked APC so I
want it foreign keyed to the APC it's on.  Each APC is networked and
so connected to one of the switches in the other model, so I want a
foreign key to the Switches model.  I need the foreign keys to set up
parenting in Nagios.

I've confirmed that this is definately related to the order the models
are placed in because reversing the order in models.py changes the
name error to complain about the opposite model.  Is there any way
around this that I'm missing in the documentation?  I suppose I can
remove the foreign key and just make one of them an integer field and
relate it manually.  It'd just be easier to make django handle the
table relations.  Any suggestions?

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError on view which IS defined

2009-03-01 Thread Les



On Mar 1, 11:22 pm, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Sun, 2009-03-01 at 19:38 -0800, Les wrote:
> > I created a view and template dummy / dummy.html to use in new urls
> > for testing.
>
> > Despite the fact that both are defined, I get NameError:
>
> > The other urls defined work fine, if I take the refs to dummy out of
> > urls.py.  As is, nothing works.
> > +===
> > Here's urls.py:
>
> > from django.conf.urls.defaults import *
> > from django.conf import settings
> > import os
> > from frodo.views import welcome
> > from frodo.views import outside_home
>
> > # Uncomment the next two lines to enable the admin:
> > from django.contrib import admin
> > admin.autodiscover()
>
> > urlpatterns = patterns('',
> >    # Example:
> >     # (r'^frodo/', include('frodo.foo.urls')),
> >     # Outside homepage
> >     (r'^$', outside_home),
> >     # Welcome page (after login)
> >     (r'^welcome/$', welcome),
> >     (r'^login/$', dummy),
> >     (r'^upload/$', dummy),
> >     (r'^download/$', dummy),
>
> The error is telling you what the problem is: the name is not defined in
> this namespace. Because you haven't imported it. Notice that you've
> imported "welcome" and "outside_home", but not "dummy".
>
> Regards,
> Malcolm

Thanks it always takes someone else looking at it to see the dumb
stunt
Les
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError on view which IS defined

2009-03-01 Thread Malcolm Tredinnick

On Sun, 2009-03-01 at 19:38 -0800, Les wrote:
> I created a view and template dummy / dummy.html to use in new urls
> for testing.
> 
> Despite the fact that both are defined, I get NameError:
> 
> The other urls defined work fine, if I take the refs to dummy out of
> urls.py.  As is, nothing works.
> +===
> Here's urls.py:
> 
> from django.conf.urls.defaults import *
> from django.conf import settings
> import os
> from frodo.views import welcome
> from frodo.views import outside_home
> 
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
> 
> urlpatterns = patterns('',
>   # Example:
> # (r'^frodo/', include('frodo.foo.urls')),
> # Outside homepage
> (r'^$', outside_home),
> # Welcome page (after login)
> (r'^welcome/$', welcome),
> (r'^login/$', dummy),
>(r'^upload/$', dummy),
> (r'^download/$', dummy),

The error is telling you what the problem is: the name is not defined in
this namespace. Because you haven't imported it. Notice that you've
imported "welcome" and "outside_home", but not "dummy".

Regards,
Malcolm



--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



NameError on view which IS defined

2009-03-01 Thread Les

I created a view and template dummy / dummy.html to use in new urls
for testing.

Despite the fact that both are defined, I get NameError:

The other urls defined work fine, if I take the refs to dummy out of
urls.py.  As is, nothing works.
+===
Here's urls.py:

from django.conf.urls.defaults import *
from django.conf import settings
import os
from frodo.views import welcome
from frodo.views import outside_home

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

urlpatterns = patterns('',
# Example:
# (r'^frodo/', include('frodo.foo.urls')),
# Outside homepage
(r'^$', outside_home),
# Welcome page (after login)
(r'^welcome/$', welcome),
(r'^login/$', dummy),
 (r'^upload/$', dummy),
(r'^download/$', dummy),

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

# Uncomment the next line to enable the admin:
 (r'^admin/(.*)', admin.site.root),

)
# serve static in debug
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static_media/(?P.*)$', 'django.views.static.serve',
{'document_root': '/home/les/django/frodo/static_media'}),
)
+++
Here's views.py:
from django.shortcuts import render_to_response
from django.http import HttpResponse

# Outside home page (before login)
def outside_home(request):
return render_to_response('outside_home.html', {"MEDIA_URL" : '/
static_media/'})

# Home page after login
def welcome(request):
userName = "George"
return render_to_response('welcome.html',{"userName" : userName})

# Place holder
def dummy(request):
return render_to_response('dummy.html')
++==
Here's dummy.html:

http://www.w3.org/
TR/html4/strict.dtd">


Dummy page


Dummy page




--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread djandrow

You need to remove the # from:

# from django.contrib import admin
# admin.autodiscover()

I had the same thing earlier.

Heres some more stuff about setting up the admin if you want to read
it:

http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02

On Feb 9, 11:24 pm, "claudio.br...@googlemail.com"
 wrote:
> On 9 Feb, 19:16, Daniel Roseman  wrote:
>
> > On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
>
> >  wrote:
> > > Hi Alex
>
> > > Yes I have the line from django.contrib import admin" in urls.py
>
> > You're going to need to post the whole urls.py. It's a bit hard to
> > understand why you're getting that error if you do have that line, and
> > it's not commented out. Please show us the whole file, preferably by
> > posting it somewhere like dpaste.com.
>
> > --
> > DR.
>
> Okay I stripped everything else out of the urls.py and am left with
> the following
>
> ---
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
> urlpatterns = patterns('',
>     # Example:
>     # (r'^mysite/', include('mysite.foo.urls')),
>
>     # Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
>     # to INSTALLED_APPS to enable admin documentation:
>     # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
>     # Uncomment the next line to enable the admin:
>      (r'^admin/(.*)', admin.site.root),
> )
>
> and I still get the same error
>
> K
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 6:24 PM, claudio.br...@googlemail.com <
claudio.br...@googlemail.com> wrote:

>
>
>
> On 9 Feb, 19:16, Daniel Roseman  wrote:
> > On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
> >
> >  wrote:
> > > Hi Alex
> >
> > > Yes I have the line from django.contrib import admin" in urls.py
> >
> > You're going to need to post the whole urls.py. It's a bit hard to
> > understand why you're getting that error if you do have that line, and
> > it's not commented out. Please show us the whole file, preferably by
> > posting it somewhere like dpaste.com.
> >
> > --
> > DR.
>
> Okay I stripped everything else out of the urls.py and am left with
> the following
>
> ---
>
> from django.conf.urls.defaults import *
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
> urlpatterns = patterns('',
># Example:
># (r'^mysite/', include('mysite.foo.urls')),
>
># Uncomment the admin/doc line below and add
> 'django.contrib.admindocs'
># to INSTALLED_APPS to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
>
># Uncomment the next line to enable the admin:
> (r'^admin/(.*)', admin.site.root),
> )
>
> and I still get the same error
>
> K
>
> >
>
You have the import commented out, this means that code never gets
executed.  I would recommend reading up a bit more on python before
proceeding.

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread claudio.br...@googlemail.com



On 9 Feb, 19:16, Daniel Roseman  wrote:
> On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
>
>  wrote:
> > Hi Alex
>
> > Yes I have the line from django.contrib import admin" in urls.py
>
> You're going to need to post the whole urls.py. It's a bit hard to
> understand why you're getting that error if you do have that line, and
> it's not commented out. Please show us the whole file, preferably by
> posting it somewhere like dpaste.com.
>
> --
> DR.

Okay I stripped everything else out of the urls.py and am left with
the following

---

from django.conf.urls.defaults import *

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

urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),

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

# Uncomment the next line to enable the admin:
 (r'^admin/(.*)', admin.site.root),
)

and I still get the same error

K

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread Daniel Roseman

On Feb 9, 6:57 pm, "claudio.br...@googlemail.com"
 wrote:
> Hi Alex
>
> Yes I have the line from django.contrib import admin" in urls.py
>

You're going to need to post the whole urls.py. It's a bit hard to
understand why you're getting that error if you do have that line, and
it's not commented out. Please show us the whole file, preferably by
posting it somewhere like dpaste.com.

--
DR.
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread claudio.br...@googlemail.com

Hi Alex

Yes I have the line from django.contrib import admin" in urls.py

On 9 Feb, 16:20, Alex Gaynor <alex.gay...@gmail.com> wrote:
> On Mon, Feb 9, 2009 at 11:11 AM, claudio.br...@googlemail.com <
>
>
>
> claudio.br...@googlemail.com> wrote:
>
> > Hi
>
> > I am new to django and have just started to play. I have a working
> > (small) app but wanted to turn on the admin console for the project. I
> > edited the settings.py to include the admin module and now get the
> > following errors
>
> > NameError at /admin/
>
> > name 'admin' is not defined
>
> > Request Method: GET
> > Request URL:http://127.0.0.1:8000/admin/
> > Exception Type: NameError
> > Exception Value:
>
> > name 'admin' is not defined
>
> > although I first saw the error using django 1.0.2, I can re-create it
> > using 0.96. I have come to the conclusion that I am doing something
> > wrong but can anyone tell me what?
>
> > the relevant part of my settings.py looks like;
>
> > INSTALLED_APPS = (
> >'django.contrib.auth',
> >'django.contrib.contenttypes',
> >'django.contrib.sessions',
> >'django.contrib.sites',
> >'django.contrib.admin',
> > )
>
> > and URLS looks like
>
> ># Uncomment the next line to enable the admin:
> > (r'^admin/(.*)', admin.site.root),
> > )
>
> > i have removed evrything else from the project and app and still get
> > the errror, at the top of the urls.py it makes no difference whether I
> > have the line admin.autodiscover() or not as I still get the error
>
> > Regards
>
> > K
>
> Do you have the line "from django.contrib import admin" in your urls.py?
>
> Alex
>
> --
> "I disapprove of what you say, but I will defend to the death your right to
> say it." --Voltaire
> "The people's good is the highest law."--Cicero
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Keep getting NameError at /admin/

2009-02-09 Thread Alex Gaynor
On Mon, Feb 9, 2009 at 11:11 AM, claudio.br...@googlemail.com <
claudio.br...@googlemail.com> wrote:

>
> Hi
>
> I am new to django and have just started to play. I have a working
> (small) app but wanted to turn on the admin console for the project. I
> edited the settings.py to include the admin module and now get the
> following errors
>
> NameError at /admin/
>
> name 'admin' is not defined
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/
> Exception Type: NameError
> Exception Value:
>
> name 'admin' is not defined
>
> although I first saw the error using django 1.0.2, I can re-create it
> using 0.96. I have come to the conclusion that I am doing something
> wrong but can anyone tell me what?
>
> the relevant part of my settings.py looks like;
>
> INSTALLED_APPS = (
>'django.contrib.auth',
>'django.contrib.contenttypes',
>'django.contrib.sessions',
>'django.contrib.sites',
>'django.contrib.admin',
> )
>
> and URLS looks like
>
>
># Uncomment the next line to enable the admin:
> (r'^admin/(.*)', admin.site.root),
> )
>
> i have removed evrything else from the project and app and still get
> the errror, at the top of the urls.py it makes no difference whether I
> have the line admin.autodiscover() or not as I still get the error
>
> Regards
>
> K
>
> >
>
Do you have the line "from django.contrib import admin" in your urls.py?

Alex

-- 
"I disapprove of what you say, but I will defend to the death your right to
say it." --Voltaire
"The people's good is the highest law."--Cicero

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Keep getting NameError at /admin/

2009-02-09 Thread claudio.br...@googlemail.com

Hi

I am new to django and have just started to play. I have a working
(small) app but wanted to turn on the admin console for the project. I
edited the settings.py to include the admin module and now get the
following errors

NameError at /admin/

name 'admin' is not defined

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/
Exception Type: NameError
Exception Value:

name 'admin' is not defined

although I first saw the error using django 1.0.2, I can re-create it
using 0.96. I have come to the conclusion that I am doing something
wrong but can anyone tell me what?

the relevant part of my settings.py looks like;

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.admin',
)

and URLS looks like


# Uncomment the next line to enable the admin:
 (r'^admin/(.*)', admin.site.root),
)

i have removed evrything else from the project and app and still get
the errror, at the top of the urls.py it makes no difference whether I
have the line admin.autodiscover() or not as I still get the error

Regards

K

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError: global name ‘datetime’ is not defined

2009-01-19 Thread Kenneth Gonsalves

On Monday 19 Jan 2009 3:01:29 pm jazz wrote:
> p.was_published_today() Traceback (most recent call last):
> File "", line 1, in File "c:\projects\mysite..\mysite\polls
> \models.py", line 11, in was_published_today return self.pub_date.date
> () == datetime.date.today() NameError: global name 'datetime' is not
> defined

you need to import datetime

-- 
regards
KG
http://lawgon.livejournal.com

--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: NameError: global name ‘datetime’ is not defined

2009-01-19 Thread Malcolm Tredinnick

On Mon, 2009-01-19 at 01:31 -0800, jazz wrote:
> p.was_published_today() Traceback (most recent call last):
> File "", line 1, in File "c:\projects\mysite..\mysite\polls
> \models.py", line 11, in was_published_today return self.pub_date.date
> () == datetime.date.today() NameError: global name 'datetime' is not
> defined
> 
> any help

This is the third time in a couple of hours that you've posted something
like this. So, a couple of items of general advice. Please take them in
the spirit they're offered:

(1) Just posting the very last line on the screen is not that helpful.
It's like reporting there's a car crash without mentioning where it is
or that you happened to be the driver. We don't have enough information
to say anything intelligent beyond "you haven't given us enough
information." It happens, from having seen lots of questions, that I can
guess you're working through the first part of the tutorial, but you're
not always going to be that lucky.

(2) The tutorial is not fundamentally broken. Thousands of people have
worked through it successfully. So if you're seeing things that appear
to be basic errors, like the above, go back a few steps, re-read things
and try to find what you've missed. All of the information needed to
construct the examples are in the tutorial text.

For example, the above error suggests you've omitted the "import
datetime" line. That is on the line exactly one line above where you're
seeing the error. So you don't have to look back very far to find the
problem in this case. You've already seen that case-sensitivity is
important (in an earlier message) and that not missing lines (in this
case) is important. So, please take your time. If you end up posting 6
or 12 messages a day, you're going to find that people simply don't have
the time or inclination to help you, because you're not taking the time
to help yourself first.

We're very helpful on this list, providing you realise you are one of
well over 10,000 people on a very high-volume list. You have to do some
reasonable level of homework/preparation before posting.

In any case, it's nice to see another person trying out Django. It might
well require a little getting used to, since you're also trying to learn
Python at the same time (I would *strongly* recommend working through
the Python tutorial at python.org, at a minimum, before starting to work
with Django, but people are free to attempt anything), but it's
generally a fun experience once you put in the necessary study time.

Regards,
Malcolm



--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



NameError: global name ‘datetime’ is not defined

2009-01-19 Thread jazz

p.was_published_today() Traceback (most recent call last):
File "", line 1, in File "c:\projects\mysite..\mysite\polls
\models.py", line 11, in was_published_today return self.pub_date.date
() == datetime.date.today() NameError: global name 'datetime' is not
defined

any help
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting a NameError: global name 'Lesson' is not defined

2008-10-29 Thread Daniel Strasser

Thank you very much for your precise answer. I think I misunderstood a
lot and I will go through the tutorial again.

On 28 Okt., 15:04, bruno desthuilliers <[EMAIL PROTECTED]>
wrote:
> On 28 oct, 14:05,DanielStrasser<[EMAIL PROTECTED]> wrote:
>
> > > You have a circular reference between students.models and
> > > lessons.models. The first want to import the second, which want to
> > > import the first, etc... This just can't work.
>
> > Thank you very much. I played around but I don't come to a solution. I
> > think I'll try again. I just don't understand where this circular
> > reference should be (Problem exists also if I remove them from one
> > place or another)
>
> Sorry, it appears I jumped to conclusion a bit too fast. Re-reading
> the traceback:
>
> 1/ students.models imports lessons.models.Lesson
> 2/ lessons.models.Lesson try to reference students.models.Student -
> which is not defined.
>
> IOW : you don't _actually_ have a circular reference, but you would
> have one if you tried to solve this NameError by import
> students.models in lessons.models.
>
> The solution is to declare the foreign key on Students using a
> app_label.model_name string instead of a model object, ie (not
> tested...) :
>
> class Lesson(models.Model):
>    # ...
>    student = models.ForeignKey('students.Student')
>
> cfhttp://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.mod...
> for more on this.
>
> A bit OT, but using a models.ForeignKey here means that a Lesson can
> have *at most one* single student. I can't of course tell whether
> that's ok for your app, but it sure looks a bit weird to me.
>
> And while we're at it: given the existence of this foreign key, the
> Student.lesson_hours method mentioned in your first post should make
> use of it, ie:
>
> class Student(models.Model):
>   # ...
>   def lesson_hours(self):
>       return self.lesson_set.count()
>
> HTH
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting a NameError: global name 'Lesson' is not defined

2008-10-28 Thread bruno desthuilliers

On 28 oct, 14:05, Daniel Strasser <[EMAIL PROTECTED]> wrote:
> > You have a circular reference between students.models and
> > lessons.models. The first want to import the second, which want to
> > import the first, etc... This just can't work.
>
> Thank you very much. I played around but I don't come to a solution. I
> think I'll try again. I just don't understand where this circular
> reference should be (Problem exists also if I remove them from one
> place or another)

Sorry, it appears I jumped to conclusion a bit too fast. Re-reading
the traceback:

1/ students.models imports lessons.models.Lesson
2/ lessons.models.Lesson try to reference students.models.Student -
which is not defined.

IOW : you don't _actually_ have a circular reference, but you would
have one if you tried to solve this NameError by import
students.models in lessons.models.

The solution is to declare the foreign key on Students using a
app_label.model_name string instead of a model object, ie (not
tested...) :

class Lesson(models.Model):
   # ...
   student = models.ForeignKey('students.Student')


cf 
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey
for more on this.

A bit OT, but using a models.ForeignKey here means that a Lesson can
have *at most one* single student. I can't of course tell whether
that's ok for your app, but it sure looks a bit weird to me.

And while we're at it: given the existence of this foreign key, the
Student.lesson_hours method mentioned in your first post should make
use of it, ie:

class Student(models.Model):
  # ...
  def lesson_hours(self):
  return self.lesson_set.count()

HTH
--~--~-~--~~~---~--~~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



  1   2   >