Re: SessionStore attribute error

2022-09-21 Thread Basheer Olamilekan Balogun
I think this best way is to check which kind of id your are store, because 
the primary id by default is integer
which is going to be added automatically, so in your code i can see that 
you specify company_id upon creation new company which i do not think 
you have such field in your JobDetail model.py,. so django will throw an 
error saying I do not have any place to store the id.

if that is the case, you do not need to specify id bro.

On Tuesday, September 20, 2022 at 8:11:01 AM UTC+1 shivas...@gmail.com 
wrote:

> hello Dear Kasper Laudrup
> I am beginner
>  sorry for this but my problem is not solve  yet  that's why  I have  sent 
> my code for better solution of error
> I am not familiar  about this file witch you are send me
>
>
> On Tuesday, September 20, 2022 at 12:22:12 PM UTC+5:30 Kasper Laudrup 
> wrote:
>
>> On 20/09/2022 08.21, shiva singh wrote:
>> > hello everyone please help how can solve this problem?
>> >
>>
>> I suggest you ignore all the replies you've already gotten and then post 
>> the exact same question a third time.
>>
>> Kind regards,
>> Kasper Laudrup
>>
>

-- 
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/12cbb283-a8d3-4eaa-b27b-4b95d7f0539en%40googlegroups.com.


Re: SessionStore attribute error

2022-09-20 Thread shiva singh
hello Dear Kasper Laudrup
I am beginner
 sorry for this but my problem is not solve  yet  that's why  I have  sent 
my code for better solution of error
I am not familiar  about this file witch you are send me


On Tuesday, September 20, 2022 at 12:22:12 PM UTC+5:30 Kasper Laudrup wrote:

> On 20/09/2022 08.21, shiva singh wrote:
> > hello everyone please help how can solve this problem?
> >
>
> I suggest you ignore all the replies you've already gotten and then post 
> the exact same question a third time.
>
> Kind regards,
> Kasper Laudrup
>

-- 
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/c7e37c46-d540-49b1-ba24-989ace6845b0n%40googlegroups.com.


Re: SessionStore attribute error

2022-09-20 Thread 'Kasper Laudrup' via Django users

On 20/09/2022 08.21, shiva singh wrote:

hello everyone please help how can solve this problem?



I suggest you ignore all the replies you've already gotten and then post 
the exact same question a third time.


Kind regards,
Kasper Laudrup

--
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/04483ea1-1cd3-ed58-2e77-19eca96ccf40%40stacktrace.dk.


OpenPGP_0xE5D9CAC64AAA55EB.asc
Description: OpenPGP public key


OpenPGP_signature
Description: OpenPGP digital signature


SessionStore attribute error

2022-09-20 Thread shiva singh
hello everyone please help how can solve this problem?

this is session  code:-
 if user.password==password and user.role=="Company":
com=Company.objects.get(user_id=user)
request.session['id']=user.id
request.session['role']=user.role
request.session['company_name']=com.company_name
request.session['email']=user.email
return redirect('companyprofilepage')

This is my views.py code:-
def JobPostSubmit(request):
user=UserMaster.objects.get(id=request.session.id)  
if user.role == "Comapny":
comp = Company.objects.get(user_id=user)
jobname=request.POST['jobname']
comname=request.POST['comn']
comemail=request.POST['come']
comaddress=request.POST['comadd']
comcontact=request.POST['comco']
qualifications=request.POST['quli']
responsblities=request.POST['resp']
salary=request.POST['salary']
experience=request.POST['exep']
jobdesc=request.POST['jobdesc']
weburl=request.POST['weburl']
comlogo=request.FILES['comlogo']

jps=JobDetails.objects.create(company_id=comp,jobname=jobname,company_name=comname,jobdesc=jobdesc,qulifications=qualifications,resposiilites=responsblities,location=comaddress,companywebsite=weburl,companyemail=comemail,companycontact=comcontact,salarypackage=salary,experience=experience,logo=comlogo)
message="Job Post Successfully"
return redirect('jobpostsubmit',{'msg':message})


[image: image.jpeg]

-- 
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/5cbd8bee-7089-466a-8b61-7d7e3f59bb5en%40googlegroups.com.


Re: session id attribute error

2022-09-19 Thread Mohammad Ehsan Ansari
Hi SessionStore is a model class? if yes you can use pk instant of id


On Monday, 19 September 2022 at 22:48:02 UTC+5:30 aashishk...@gmail.com 
wrote:

> Do this 
>
> request.session.get(‘id’)
>
> On Mon, 19 Sep 2022 at 1:30 PM, shiva singh  wrote:
>
>> hello everyone please help me how can solve this problem:-[image: 
>> image.jpeg]  
>>
>> -- 
>>
> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/f1b3116a-a14a-45fb-84d0-c4f95a05fdf0n%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/f80105fe-94e0-4ae8-a2b4-d8173a2c608an%40googlegroups.com.


Re: session id attribute error

2022-09-19 Thread Aashish Kumar
Do this

request.session.get(‘id’)

On Mon, 19 Sep 2022 at 1:30 PM, shiva singh  wrote:

> hello everyone please help me how can solve this problem:-[image:
> image.jpeg]
>
> --
> 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/f1b3116a-a14a-45fb-84d0-c4f95a05fdf0n%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/CACTAcrwdE7AtZR9u9YQG-3gwYedvid-33fG2JG1n2Z4eRbwbpQ%40mail.gmail.com.


Re: session id attribute error

2022-09-19 Thread Muhammad Juwaini Abdul Rahman
That was user, so probably you need request.user.id, not session.

On Mon, 19 Sept 2022 at 16:00, shiva singh  wrote:

> hello everyone please help me how can solve this problem:-[image:
> image.jpeg]
>
> --
> 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/f1b3116a-a14a-45fb-84d0-c4f95a05fdf0n%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/CAFKhtoQYy2BqXm7htomDc4nyP7RRMhtJS1NHog0JHn7yTQECGg%40mail.gmail.com.


session id attribute error

2022-09-19 Thread shiva singh
hello everyone please help me how can solve this problem:-[image: 
image.jpeg] 

-- 
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/f1b3116a-a14a-45fb-84d0-c4f95a05fdf0n%40googlegroups.com.


Re: Attribute error

2021-05-18 Thread Peter Kirieny
tanks for this, it was helpfull


On Thu, 13 May 2021 at 15:31, Ryan Nowakowski  wrote:

> It's likely that your instance of OrderItem has a product field that's
> null.
>
> On May 12, 2021 3:50:42 AM CDT, Peter Kirieny 
> wrote:
> >can somebody help with this please, am building an ecommerce web and
> >when i
> >want to view my cart i get this error
> >AttributeError: 'NoneType' object has no attribute 'price'
> >
> >here is my models.py
> >class OrderItem(models.Model):
> >
> >product = models.ForeignKey(Product, on_delete=models.SET_NULL,
> >null=True)
> > order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
> >quantity = models.IntegerField(default=0, null=True, blank=True)
> >date_added = models.DateTimeField(auto_now_add=True)
> >
> >@property
> >def get_total(self):
> >total = self.product.price * self.quantity
> >return total
> >
> >
> >
> >AttributeError at /cart/
> >
> >'NoneType' object has no attribute 'price'
> >
> >Request Method: GET
> >Request URL: http://127.0.0.1:8000/cart/
> >Django Version: 3.2
> >Exception Type: AttributeError
> >Exception Value:
> >
> >'NoneType' object has no attribute 'price'
> >
> >Exception Location:
> >C:\Users\Admin\PycharmProject\MyProject\Ecommerce\shop\models.py, line
> >71,
> >in get_total
> >Python Executable:
> >C:\Users\Admin\PycharmProject\MyProject\venv\Scripts\python.exe
> >Python Version: 3.8.2
> >Python Path:
> >
> >['C:\\Users\\Admin\\PycharmProject\\MyProject\\Ecommerce',
>
> >'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
> > 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
> > 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\lib',
> > 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38',
> > 'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv',
> >'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv\\lib\\site-packages']
> >
> >Server time: Wed, 12 May 2021 08:44:09 +
>
> --
> 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/FDF6B1C2-9134-43D2-8057-EA3BCF14C2A1%40fattuba.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/CAL8t8eoTHsQh2Lu6oVWdF8sZvoBgTMTrEY4KFU__eepU0QP1uw%40mail.gmail.com.


Re: Attribute error

2021-05-13 Thread Ryan Nowakowski
It's likely that your instance of OrderItem has a product field that's null. 

On May 12, 2021 3:50:42 AM CDT, Peter Kirieny  wrote:
>can somebody help with this please, am building an ecommerce web and
>when i
>want to view my cart i get this error
>AttributeError: 'NoneType' object has no attribute 'price'
>
>here is my models.py
>class OrderItem(models.Model):
>
>product = models.ForeignKey(Product, on_delete=models.SET_NULL,
>null=True)
> order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
>quantity = models.IntegerField(default=0, null=True, blank=True)
>date_added = models.DateTimeField(auto_now_add=True)
>
>@property
>def get_total(self):
>total = self.product.price * self.quantity
>return total
>
>
>
>AttributeError at /cart/
>
>'NoneType' object has no attribute 'price'
>
>Request Method: GET
>Request URL: http://127.0.0.1:8000/cart/
>Django Version: 3.2
>Exception Type: AttributeError
>Exception Value:
>
>'NoneType' object has no attribute 'price'
>
>Exception Location:
>C:\Users\Admin\PycharmProject\MyProject\Ecommerce\shop\models.py, line
>71,
>in get_total
>Python Executable:
>C:\Users\Admin\PycharmProject\MyProject\venv\Scripts\python.exe
>Python Version: 3.8.2
>Python Path:
>
>['C:\\Users\\Admin\\PycharmProject\\MyProject\\Ecommerce',
>'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\lib',
> 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38',
> 'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv',
>'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv\\lib\\site-packages']
>
>Server time: Wed, 12 May 2021 08:44:09 +

-- 
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/FDF6B1C2-9134-43D2-8057-EA3BCF14C2A1%40fattuba.com.


Attribute error

2021-05-12 Thread Peter Kirieny
can somebody help with this please, am building an ecommerce web and when i
want to view my cart i get this error
AttributeError: 'NoneType' object has no attribute 'price'

here is my models.py
class OrderItem(models.Model):

product = models.ForeignKey(Product, on_delete=models.SET_NULL, null=True)
order = models.ForeignKey(Order, on_delete=models.SET_NULL, null=True)
quantity = models.IntegerField(default=0, null=True, blank=True)
date_added = models.DateTimeField(auto_now_add=True)

@property
def get_total(self):
total = self.product.price * self.quantity
return total



AttributeError at /cart/

'NoneType' object has no attribute 'price'

Request Method: GET
Request URL: http://127.0.0.1:8000/cart/
Django Version: 3.2
Exception Type: AttributeError
Exception Value:

'NoneType' object has no attribute 'price'

Exception Location:
C:\Users\Admin\PycharmProject\MyProject\Ecommerce\shop\models.py, line 71,
in get_total
Python Executable:
C:\Users\Admin\PycharmProject\MyProject\venv\Scripts\python.exe
Python Version: 3.8.2
Python Path:

['C:\\Users\\Admin\\PycharmProject\\MyProject\\Ecommerce',
 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\python38.zip',
 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\DLLs',
 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38\\lib',
 'C:\\Users\\Admin\\AppData\\Local\\Programs\\Python\\Python38',
 'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv',
 'C:\\Users\\Admin\\PycharmProject\\MyProject\\venv\\lib\\site-packages']

Server time: Wed, 12 May 2021 08:44:09 +

-- 
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/CAL8t8eqL%3Dq6qMeBnk2Nq_TO%3D%3DivFvpuYuCR%3DkgtXv2H%3DHCkaQg%40mail.gmail.com.


Re: Attribute Error

2020-02-17 Thread maninder singh Kumar
Have you tried putting a print statement in views.py RegisterStudent to get to 
an output in the server.
Perhaps the problem is in the template and the get isn't even coming to the view

Sent from my iPad

> On 17-Feb-2020, at 6:30 PM, Adam Mičuda  wrote:
> 
> Hi,
> you have to return instance of `django.http.HttpResponse` class from you view 
> `RegisterStudent` instead of string: line 98 and line 99.
> 
> see 
> https://docs.djangoproject.com/en/3.0/ref/request-response/#django.http.HttpResponse
> 
> Regards.
> 
> Adam
> 
> 
> po 17. 2. 2020 v 13:49 odesílatel Ernest Thuku  napsal:
>> Hello guys please help on the error. I have been stuck for days now.
>> I am Ernest from Kenya.
>> please look into these files below
>> -- 
>> 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/CAPsfuofNxRkkcP4WtnG7cF-mbrN-GvgD4ene%3D0i_ChK6N8VVcw%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/CAB9%3DGXYFq4HcbGM3vPj8aKYAZd3LWc6mJZ19eKuR7v1xjTHM4Q%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/597EBAE3-0491-4B0A-A59C-791804ED56D4%40gmail.com.


Re: Attribute Error

2020-02-17 Thread Ayser shuhaib
Pleas provide the code for clickjacking.py

On Mon, 17 Feb 2020 at 14:50, Ernest Thuku  wrote:

> Hello guys please help on the error. I have been stuck for days now.
> I am Ernest from Kenya.
> please look into these files below
>
> --
> 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/CAPsfuofNxRkkcP4WtnG7cF-mbrN-GvgD4ene%3D0i_ChK6N8VVcw%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/CAE0AZGJ-VqRLv6oD%2BEHBO6T_DqHq1YinH69k7-EaQz-m33WS7w%40mail.gmail.com.


Re: Attribute Error

2020-02-17 Thread Adam Mičuda
Hi,
you have to return instance of `django.http.HttpResponse` class from you
view `RegisterStudent` instead of string: *line 98* and *line 99*.

see
https://docs.djangoproject.com/en/3.0/ref/request-response/#django.http.HttpResponse

Regards.

Adam


po 17. 2. 2020 v 13:49 odesílatel Ernest Thuku 
napsal:

> Hello guys please help on the error. I have been stuck for days now.
> I am Ernest from Kenya.
> please look into these files below
>
> --
> 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/CAPsfuofNxRkkcP4WtnG7cF-mbrN-GvgD4ene%3D0i_ChK6N8VVcw%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/CAB9%3DGXYFq4HcbGM3vPj8aKYAZd3LWc6mJZ19eKuR7v1xjTHM4Q%40mail.gmail.com.


Attribute Error 'NoneType' object has no attribute '_prefetch_related_lookups'

2019-07-11 Thread Warwick Lewarne
Hi all,

I keep getting the above error and I am not sure what I need to do to 
correct it. An example will assist.

my model:
class Product_Group(models.Model):
customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE)
prod_group = models.CharField(max_length=30, unique = True, 
verbose_name = "product group")


def __str__(self):
return self.prod_group

class Part_Number(models.Model):
customer_id = models.ForeignKey(Customer, on_delete=models.CASCADE, 
related_name = 'customer')
prod_group = models.ForeignKey(Product_Group, 
on_delete=models.DO_NOTHING, related_name='product')
part_number = models.CharField(max_length=40, unique = True)
part_description = models.CharField(max_length=60)
   

def __str__(self):
return self.part_description

My form:
from django import forms
from django.contrib.auth.models import User
from .models import Department, Product_Group, Part_Number, Reject_Reason, 
Return_Reason, Supplier, Consumer
from accounts.models import Customer_User




class Report_GenerateForm(forms.Form):
part_number = forms.ModelChoiceField(queryset=None, label='Part Number')
reject_data = forms.ModelChoiceField(queryset=None)
select_data = forms.ModelChoiceField(queryset=None)

def __init__(self, *args, **kwargs):

customer_id = kwargs.pop('customer_id')
table_select = kwargs.pop('table_select')
product = kwargs.pop('product')
super(Report_GenerateForm, self).__init__(*args, **kwargs)
self.fields['part_number'].queryset = 
Part_Number.objects.filter(customer_id= customer_id, prod_group = 
product).select_related('prod_group')
if table_select == 1:
self.fields['select_data'].queryset = 
Department.objects.filter(customer_id=customer_id)
self.fields['select_data'].label = 'Department'
self.fields['reject_data'].queryset = 
Reject_Reason.objects.all()
self.fields['reject_data'].label = 'Reject Reason'
if table_select == 2:
self.fields['select_data'].queryset = 
Supplier.objects.filter(customer_id=customer_id)
self.fields['select_data'].label = 'Supplier'
self.fields['reject_data'].queryset = 
Return_Reason.objects.all()
self.fields['reject_data'].label = 'Reason for Return'
if table_select == 3:
self.fields['select_data'].queryset = 
Consumer.objects.filter(customer_id=customer_id)
self.fields['select_data'].label = 'Customer'
self.fields['reject_data'].queryset = 
Return_Reason.objects.all()
self.fields['reject_data'].label = 'Reason for Return'

-- 
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/a9fee22e-4e00-4db3-a6ac-9de8312fdcdd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Attribute Error: 'None Type' object has no attribute 'split'

2018-12-17 Thread Richard Balwane
Using reverse to shortcut URLs, addressing compatibilities of sorts
although am running the following;

dj-database-url==0.5.0

Django==2.1.4

django-crispy-forms==1.7.2

gunicorn==19.9.0

mysqlclient==1.3.14

Pillow==5.3.0

psycopg2==2.7.6.1

pytz==2018.7

My problem is that now my "detail" isn't working.

What do I have to do, please, to get the details working?

**Link in template:


{% for obj in object_list %}
 {{ obj }} 
{{ obj.name }} {{ obj.location }} {{ obj.category }} {{
obj.timestamp }} {{ obj.updated }} 
{% endfor %}


*URL in App:

from django.conf.urls import url

from restaurants.views import (
# restaurant_createview,
# restaurant_listview,
RestaurantListView,
RestaurantDetailView,
RestaurantCreateView

)

app_name = 'restaurants'

urlpatterns = [
url(r'$', RestaurantListView.as_view(), name='list'),
url(r'^create/$', RestaurantCreateView.as_view(), name='create'), #
RestaurantCreateView.as_view()),
url(r'^(?P[\w-]+)/$', RestaurantDetailView.as_view(),
name='detail'),
]

*Main URLs

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

from django.contrib.auth.views import LoginView



from restaurants.views import (
restaurant_createview,
restaurant_listview,
RestaurantListView,
RestaurantDetailView,
RestaurantCreateView

)

urlpatterns = [
url('admin/', admin.site.urls),
url(r'^$', TemplateView.as_view(template_name = 'home.html'),
name='home'),
url(r'^login/$', LoginView.as_view(), name='login'),
url('restaurants/', include('restaurants.urls',
namespace='restaurants')),
url(r'^about/$', TemplateView.as_view(template_name = 'about.html'),
name='about'),
url(r'^contact/$', TemplateView.as_view(template_name =
'contact.html'), name='contact'),
]


**Model

from django.conf import settings
from django.db import models
from django.db.models.signals import pre_save, post_save
from django.urls import reverse


from .utils import unique_slug_generator
from .validators import validate_category


User = settings.AUTH_USER_MODEL


class RestaurantLocation(models.Model):
owner  = models.ForeignKey(User, on_delete=models.CASCADE) #
class_instance.model_set.all # check out - Django Models Unleashed
JOINCFE.com
name   = models.CharField(max_length=120)
location   = models.CharField(max_length=120, null=True, blank=True)
category   = models.CharField(max_length=120, null=True, blank=True,
validators=[validate_category])
timestamp  = models.DateTimeField(auto_now_add=True)
updated= models.DateTimeField(auto_now=True)
slug   = models.SlugField(null=True, blank=True)

def __str__(self):
return self.name

def get_absolute_url(self): #get_absolute_url
#return f"/restaurants/{self.slug}" Removed in order to use reverse
- url resolvers
return reverse('restaurants:detail', kwargs={'slug': self.slug})
#changed from restaurants-detailto us the restaurants namespace

@property
def title(self):
return self.name #object.title

def rl_pre_save_receiver(sender, instance, *args, **kwargs):
instance.category = instance.category.capitalize()
if not instance.slug:
instance.slug = unique_slug_generator(instance)

#def rl_post_save_receiver(sender, instance, created, *args, **kwargs):
# print('saved')
# print(instance.timestamp)
# if not instance.slug:
# instance.slug = unique_slug_generator(instance)
#instance.save()

pre_save.connect(rl_pre_save_receiver, sender=RestaurantLocation)
#pre_save.connect(rl_post_save_receiver, sender=RestaurantLocation)


**Views


from django.contrib.auth.decorators import login_required # login
decorator, forces u to login before u see form!
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db.models import Q
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render, get_object_or_404
from django.views import View
from django.views.generic import TemplateView, ListView, DetailView,
CreateView

from .forms import RestaurantCreateForm, RestaurantLocationCreateForm
from .models import RestaurantLocation

# Create your views here.
# class based view

@login_required()
def restaurant_createview(request):
form = RestaurantLocationCreateForm(request.POST or None)
errors = None
if form.is_valid():
# form.save() --- This is done by default in this FBV
if request.user.is_authenticated:
instance = form.save(commit=False)
# customise
# like a pre_save
instance.owner = request.user #  User is of AnonymousUser
classif not logged in
instance.save()
# like a post_save
return HttpResponseRedirect("/restaurants/")
else:
return 

Re: attribute error

2018-08-28 Thread Andréas Kühne
HI,

You are trying to include a view that is called views from the module home
in the app jobs.

I think what you mean is :
path('', jobs.views.home, name='home')

Try that instead.

Regards,

Andréas


Den tis 28 aug. 2018 kl 13:35 skrev Imran Sharief :

> hi every one i am new to django am getting attribute error past from 2
> days i got stuck in this error only i have attached the file also plz do
> help me to resolve this error
>
> --
> 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/ccbece42-238d-411b-854d-e279b9dcb682%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/ccbece42-238d-411b-854d-e279b9dcb682%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/CAK4qSCdHUeouMFu_5S3ZGLVoJ%3Df8YoWdChKUYoZWzVS%3DGa8_cA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


attribute error

2018-08-28 Thread Imran Sharief
hi every one i am new to django am getting attribute error past from 2 days 
i got stuck in this error only i have attached the file also plz do help me 
to resolve this error

-- 
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/ccbece42-238d-411b-854d-e279b9dcb682%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread 岳贝
The date = models.DataTimeField() should be date = models.DateTimeFild() ?
https://docs.djangoproject.com/en/2.0/ref/models/fields/#datetimefield

Caleb Bryson  于2018年5月31日周四 上午9:45写道:

> I am getting a attribute error when i try to run my server. does anyone
> know what i can change in this code to fix that?
>
> from django.db import models
>
> class Post(models.Model) :
> title = models.Charfield(max_length=140)
> body = models.Textfield()
> date = models.DataTimeField()
>
> def __str__(self):
> return self.title
>
> --
> 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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/CAC5CVE1XAmFN-jgjy03Ggn%3D1rtf-1qTDVcpCtb_suJ2-k6gaDA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Spence Patrick
The f in field should be capitalized

On Wed, May 30, 2018, 20:10 Caleb Bryson  wrote:

> it is still saying "AttributeError: model 'django.db.models' has no
> attribute 'Charfeild'
>
> On Wednesday, May 30, 2018 at 10:04:04 PM UTC-4, Mike Dewhirst wrote:
>>
>> On 31/05/2018 11:45 AM, Caleb Bryson wrote:
>> > I am getting a attribute error when i try to run my server. does
>> > anyone know what i can change in this code to fix that?
>>
>> Try indenting the __str__ method so it is within the scope of the Post
>> class
>>
>> >
>> > from django.db import models
>> > class Post(models.Model) :
>> > title = models.Charfield(max_length=140)
>> > body = models.Textfield()
>> > date = models.DataTimeField()
>> > def __str__(self):
>> > return self.title
>> > --
>> > 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
>> > <mailto:django-users+unsubscr...@googlegroups.com>.
>> > To post to this group, send email to django...@googlegroups.com
>> > <mailto:django...@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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
>> > <
>> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/e2d17976-18e1-4120-950d-1457858f012b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/e2d17976-18e1-4120-950d-1457858f012b%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/CAD6-5Chfe5X_J8KbfWs7Otz7W45T4QVfYULW4UDkYU%3D2AAaZrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Caleb Bryson
I think it was because i did not use camel casing so CharField instead of 
Charfield. I will continue the tutorial and see if that works


On Wednesday, May 30, 2018 at 10:04:04 PM UTC-4, Mike Dewhirst wrote:
>
> On 31/05/2018 11:45 AM, Caleb Bryson wrote: 
> > I am getting a attribute error when i try to run my server. does 
> > anyone know what i can change in this code to fix that? 
>
> Try indenting the __str__ method so it is within the scope of the Post 
> class 
>
> > 
> > from django.db import models 
> > class Post(models.Model) : 
> > title = models.Charfield(max_length=140) 
> > body = models.Textfield() 
> > date = models.DataTimeField() 
> > def __str__(self): 
> > return self.title 
> > -- 
> > 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  
> > <mailto:django-users+unsubscr...@googlegroups.com >. 
> > To post to this group, send email to django...@googlegroups.com 
>  
> > <mailto:django...@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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/931b7ebc-430d-4e6c-802f-db0f0c2a1a73%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Caleb Bryson
it is still saying "AttributeError: model 'django.db.models' has no 
attribute 'Charfeild'

On Wednesday, May 30, 2018 at 10:04:04 PM UTC-4, Mike Dewhirst wrote:
>
> On 31/05/2018 11:45 AM, Caleb Bryson wrote: 
> > I am getting a attribute error when i try to run my server. does 
> > anyone know what i can change in this code to fix that? 
>
> Try indenting the __str__ method so it is within the scope of the Post 
> class 
>
> > 
> > from django.db import models 
> > class Post(models.Model) : 
> > title = models.Charfield(max_length=140) 
> > body = models.Textfield() 
> > date = models.DataTimeField() 
> > def __str__(self): 
> > return self.title 
> > -- 
> > 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  
> > <mailto:django-users+unsubscr...@googlegroups.com >. 
> > To post to this group, send email to django...@googlegroups.com 
>  
> > <mailto:django...@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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/e2d17976-18e1-4120-950d-1457858f012b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error

2018-05-30 Thread Mike Dewhirst

On 31/05/2018 11:45 AM, Caleb Bryson wrote:
I am getting a attribute error when i try to run my server. does 
anyone know what i can change in this code to fix that?


Try indenting the __str__ method so it is within the scope of the Post class



from django.db import models
class Post(models.Model) :
title = models.Charfield(max_length=140)
body = models.Textfield()
date = models.DataTimeField()
def __str__(self):
return self.title
--
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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com 
<https://groups.google.com/d/msgid/django-users/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%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/16cd9f05-39ae-735b-d2eb-f9802c043a8e%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Attribute error

2018-05-30 Thread Caleb Bryson
I am getting a attribute error when i try to run my server. does anyone 
know what i can change in this code to fix that?

from django.db import models

class Post(models.Model) :
title = models.Charfield(max_length=140)
body = models.Textfield()
date = models.DataTimeField()

def __str__(self):
return self.title

-- 
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/b0ffbdfa-8eee-4560-9fc1-16849c8fdceb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error at /admin/ by Django

2018-04-06 Thread Melvyn Sopacua
On vrijdag 6 april 2018 09:05:20 CEST Hamroz Jumaev wrote:
> http://dpaste.com/2GDFCG8
No middleware.

-- 
Melvyn Sopacua

-- 
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/56429012.RfAilTTXfn%40fritzbook.
For more options, visit https://groups.google.com/d/optout.


Attribute error at /admin/ by Django

2018-04-06 Thread Hamroz Jumaev
http://dpaste.com/2GDFCG8

-- 
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/fee7278a-3be9-494f-a8df-c86724d24058%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
Thanks for that Michal, I see what you mean. I've bookmarked it. Thanks to
everyone for all the detailed replies it really helps make sense of CBV :)

On Fri, Aug 26, 2016 at 3:48 PM, Michal Petrucha <
michal.petru...@konk.org> wrote:

> On Fri, Aug 26, 2016 at 10:29:16AM -0400, Andromeda Yelton wrote:
> > In my experience, CBVs are useful when the view you want to write is
> > basically a create, read, update, or delete operation on a single
> database
> > item, or a bunch of instances of the same model (...and it turns out a
> lot
> > of web app pages are just that). And they're useful because they let you
> do
> > that with almost no lines of code - they take care of all the things
> you'd
> > have to write over and over, and let you focus on the things that are
> > unique to your use case.
> >
> > The farther away your business logic is from that, the more you need to
> > understand the actual methods available and the inheritance tree and so
> > forth. It took me a while to get over this hurdle too, but now that I
> have
> > I use CBVs exclusively.
>
> I'll just chime in with a reference to http://ccbv.co.uk/, which is an
> invaluable resource whenever you're doing anything with CBVs that
> involves more than setting the ``template_name`` and ``model``
> attributes. In my opinion, CCBV makes a lot of the pain involved in
> dealing with CBVs go away.
>
> Cheers,
>
> Michal
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/django-users/vXAou_bCuhE/unsubscribe.
> To unsubscribe from this group and all its topics, 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/20160826144853.GA6601%40konk.org.
> 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/CACaWuFT1cL7jmsUbmj3g%3Dskp9HK5VtunWxSx8i9M8%2BAqOF2yzg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Sergiy Khohlov
>>>>>> to
>>>>>>> use them when I didn't need to.
>>>>>>>
>>>>>>> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
>>>>>>> andromeda.yel...@gmail.com> wrote:
>>>>>>>
>>>>>>>> The stacktrace is helpful, thanks!
>>>>>>>>
>>>>>>>> The specific message with the AttributeError is helpful here:
>>>>>>>> `AttributeError: 'module' object has no attribute 'DepositView'`
>>>>>>>>
>>>>>>>> The line above it is `  File 
>>>>>>>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py",
>>>>>>>> line 8, in 
>>>>>>>> url(r'^deposit/$', views.DepositView.as_view(),
>>>>>>>> name='deposit'),`
>>>>>>>>
>>>>>>>> So I checked to see if your views.py contains anything named
>>>>>>>> DepositView...and it does not. That's why the AttributeError is 
>>>>>>>> showing up.
>>>>>>>>
>>>>>>>> The `DepositView.as_view()` syntax is suitable for class-based
>>>>>>>> views, which means I expect to see something in your views.py to the 
>>>>>>>> effect
>>>>>>>> of:
>>>>>>>>
>>>>>>>> class DepositView(View):
>>>>>>>>   def post(self, request, *args, **kwargs):
>>>>>>>> // the logic in your deposit() function actually belongs here
>>>>>>>>
>>>>>>>> Have a look at the class-based views documentation to see what the
>>>>>>>> different classes are, and what options they provide you.
>>>>>>>>
>>>>>>>> Alternately, your urls.py could reference views.deposit (which does
>>>>>>>> exist) instead of views.DepositView (which does not).
>>>>>>>>
>>>>>>>> Hope this helps!
>>>>>>>>
>>>>>>>> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>>> Thanks for your speedy reply, I've attached the stack trace
>>>>>>>>>
>>>>>>>>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues
>>>>>>>>> wrote:
>>>>>>>>>>
>>>>>>>>>> Could you share the full stack trace you get when trying to run
>>>>>>>>>> the server ?
>>>>>>>>>> The attribute error should come with a ton of information like
>>>>>>>>>> the
>>>>>>>>>> file and the line where the error occur.
>>>>>>>>>>
>>>>>>>>>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com>:
>>>>>>>>>> > I've beem working on a simple banking app based on the Django
>>>>>>>>>> tutorial.
>>>>>>>>>> > Thanks to your help it almost works now. It was working using
>>>>>>>>>> templates but
>>>>>>>>>> > after making some changes to get HttpResponseRedirect to work I
>>>>>>>>>> changed what
>>>>>>>>>> > was in the urls file like it shows in the tutorial. Now, the
>>>>>>>>>> server doesn't
>>>>>>>>>> > run. It says there's an attribute error. I've temporarily left
>>>>>>>>>> the user name
>>>>>>>>>> > and password in at the moment. I had a look at their tutorial
>>>>>>>>>> how to do a
>>>>>>>>>> > use the Django authentication system (thanks for telling me
>>>>>>>>>> about that) and
>>>>>>>>>> > I'm going to change that after I understand what's going on
>>>>>>>>>> here. It's
>>>>>>>>>> > amazing how much you can do with Django. Do you think with time
>>>>>>>>>> you get more
>>>>>>>>>> > used to what different errors mean? The errors seem new and
>>>

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
line 8, in 
>>>>>>> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>>>>>>>
>>>>>>> So I checked to see if your views.py contains anything named
>>>>>>> DepositView...and it does not. That's why the AttributeError is showing 
>>>>>>> up.
>>>>>>>
>>>>>>> The `DepositView.as_view()` syntax is suitable for class-based
>>>>>>> views, which means I expect to see something in your views.py to the 
>>>>>>> effect
>>>>>>> of:
>>>>>>>
>>>>>>> class DepositView(View):
>>>>>>>   def post(self, request, *args, **kwargs):
>>>>>>> // the logic in your deposit() function actually belongs here
>>>>>>>
>>>>>>> Have a look at the class-based views documentation to see what the
>>>>>>> different classes are, and what options they provide you.
>>>>>>>
>>>>>>> Alternately, your urls.py could reference views.deposit (which does
>>>>>>> exist) instead of views.DepositView (which does not).
>>>>>>>
>>>>>>> Hope this helps!
>>>>>>>
>>>>>>> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com>
>>>>>>> wrote:
>>>>>>>
>>>>>>>> Thanks for your speedy reply, I've attached the stack trace
>>>>>>>>
>>>>>>>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues
>>>>>>>> wrote:
>>>>>>>>>
>>>>>>>>> Could you share the full stack trace you get when trying to run
>>>>>>>>> the server ?
>>>>>>>>> The attribute error should come with a ton of information like the
>>>>>>>>> file and the line where the error occur.
>>>>>>>>>
>>>>>>>>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com>:
>>>>>>>>> > I've beem working on a simple banking app based on the Django
>>>>>>>>> tutorial.
>>>>>>>>> > Thanks to your help it almost works now. It was working using
>>>>>>>>> templates but
>>>>>>>>> > after making some changes to get HttpResponseRedirect to work I
>>>>>>>>> changed what
>>>>>>>>> > was in the urls file like it shows in the tutorial. Now, the
>>>>>>>>> server doesn't
>>>>>>>>> > run. It says there's an attribute error. I've temporarily left
>>>>>>>>> the user name
>>>>>>>>> > and password in at the moment. I had a look at their tutorial
>>>>>>>>> how to do a
>>>>>>>>> > use the Django authentication system (thanks for telling me
>>>>>>>>> about that) and
>>>>>>>>> > I'm going to change that after I understand what's going on
>>>>>>>>> here. It's
>>>>>>>>> > amazing how much you can do with Django. Do you think with time
>>>>>>>>> you get more
>>>>>>>>> > used to what different errors mean? The errors seem new and
>>>>>>>>> confusing to me
>>>>>>>>> > at the moment. Any help would be very much appreciated. Thanks
>>>>>>>>> in advnace.
>>>>>>>>> >
>>>>>>>>> > --
>>>>>>>>> > 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 https://groups.google.com/group/django-users.
>>>>>>>>>
>>>>>>>>> > To view this discussion on the web visit
>>>>>>>>

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Michal Petrucha
On Fri, Aug 26, 2016 at 10:29:16AM -0400, Andromeda Yelton wrote:
> In my experience, CBVs are useful when the view you want to write is
> basically a create, read, update, or delete operation on a single database
> item, or a bunch of instances of the same model (...and it turns out a lot
> of web app pages are just that). And they're useful because they let you do
> that with almost no lines of code - they take care of all the things you'd
> have to write over and over, and let you focus on the things that are
> unique to your use case.
> 
> The farther away your business logic is from that, the more you need to
> understand the actual methods available and the inheritance tree and so
> forth. It took me a while to get over this hurdle too, but now that I have
> I use CBVs exclusively.

I'll just chime in with a reference to http://ccbv.co.uk/, which is an
invaluable resource whenever you're doing anything with CBVs that
involves more than setting the ``template_name`` and ``model``
attributes. In my opinion, CCBV makes a lot of the pain involved in
dealing with CBVs go away.

Cheers,

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/20160826144853.GA6601%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: Attribute error, with a very basic banking app

2016-08-26 Thread Andromeda Yelton
In my experience, CBVs are useful when the view you want to write is
basically a create, read, update, or delete operation on a single database
item, or a bunch of instances of the same model (...and it turns out a lot
of web app pages are just that). And they're useful because they let you do
that with almost no lines of code - they take care of all the things you'd
have to write over and over, and let you focus on the things that are
unique to your use case.

The farther away your business logic is from that, the more you need to
understand the actual methods available and the inheritance tree and so
forth. It took me a while to get over this hurdle too, but now that I have
I use CBVs exclusively.

On Fri, Aug 26, 2016 at 10:13 AM, Neil Hunt <hunt.n...@gmail.com> wrote:

> heh heh. I don't fully appreciate the usefulness of CBV at the moment.
> Getting a simple example working helps as much as reading the tutorial.
> Thanks again for your help,
>
> Neil
>
> On Fri, Aug 26, 2016 at 2:24 PM, Sergiy Khohlov <skhoh...@gmail.com>
> wrote:
>
>> Never mind.
>>  Few year ago I  was thinking that moving to CBV is bad idea, but
>> suddenly  BUUUHHH !! in my head and everything was clear.
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>> On Fri, Aug 26, 2016 at 3:40 PM, Neil Hunt <hunt.n...@gmail.com> wrote:
>>
>>> Hello Serge,
>>>
>>> I can't believe that's all I have to add to get the class based views to
>>> work. It seems easier to get it to work than I thought it would be. Now
>>> that you've explained it. Thank you so much for that.
>>>
>>> Kind regards,
>>>
>>> Neil
>>>
>>> On Fri, Aug 26, 2016 at 11:46 AM, Sergiy Khohlov <skhoh...@gmail.com>
>>> wrote:
>>>
>>>>  Hello Neil,
>>>>
>>>>  It is nota problem  to use Class based view. Could you please  update
>>>> your views.py  with next code.
>>>>  Look like you would like to have detail  of the deposit in this case
>>>> add next string to the header
>>>>
>>>> from  django.views.generic import DetailView
>>>> from models import Account1, Person
>>>>
>>>>
>>>>  # next  you should create a special view class for each Account1
>>>>
>>>>
>>>>  class Deposit(DetailView):
>>>> model = Account1
>>>>
>>>>
>>>>   Of course  function Deposit is  useless
>>>>
>>>>  thats all.
>>>>
>>>>
>>>>  P.S. Look like better way is adding auth  and receive person using
>>>> auth data. In this case  every authorized person can  connect to his
>>>> account  using auth info and  account id
>>>>
>>>> Many thanks,
>>>>
>>>> Serge
>>>>
>>>>
>>>> +380 636150445
>>>> skype: skhohlov
>>>>
>>>> On Thu, Aug 25, 2016 at 8:27 PM, Neil Hunt <hunt.n...@gmail.com> wrote:
>>>>
>>>>> Thank you so much Andromeda. I didn't know you could use class based
>>>>> views. I'll have a look at the documents. I don't know why I was trying to
>>>>> use them when I didn't need to.
>>>>>
>>>>> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
>>>>> andromeda.yel...@gmail.com> wrote:
>>>>>
>>>>>> The stacktrace is helpful, thanks!
>>>>>>
>>>>>> The specific message with the AttributeError is helpful here:
>>>>>> `AttributeError: 'module' object has no attribute 'DepositView'`
>>>>>>
>>>>>> The line above it is `  File 
>>>>>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py",
>>>>>> line 8, in 
>>>>>> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>>>>>>
>>>>>> So I checked to see if your views.py contains anything named
>>>>>> DepositView...and it does not. That's why the AttributeError is showing 
>>>>>> up.
>>>>>>
>>>>>> The `DepositView.as_view()` syntax is suitable for class-based views,
>>>>>> which means I expect to see something in your views.py to the effect of:
>>>>>>
>>>>>> class DepositView(View):
>>>>>>   def post(self, request, *args, **kwargs):
>>>>>> 

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
heh heh. I don't fully appreciate the usefulness of CBV at the moment.
Getting a simple example working helps as much as reading the tutorial.
Thanks again for your help,

Neil

On Fri, Aug 26, 2016 at 2:24 PM, Sergiy Khohlov <skhoh...@gmail.com> wrote:

> Never mind.
>  Few year ago I  was thinking that moving to CBV is bad idea, but suddenly
>  BUUUHHH !! in my head and everything was clear.
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
> On Fri, Aug 26, 2016 at 3:40 PM, Neil Hunt <hunt.n...@gmail.com> wrote:
>
>> Hello Serge,
>>
>> I can't believe that's all I have to add to get the class based views to
>> work. It seems easier to get it to work than I thought it would be. Now
>> that you've explained it. Thank you so much for that.
>>
>> Kind regards,
>>
>> Neil
>>
>> On Fri, Aug 26, 2016 at 11:46 AM, Sergiy Khohlov <skhoh...@gmail.com>
>> wrote:
>>
>>>  Hello Neil,
>>>
>>>  It is nota problem  to use Class based view. Could you please  update
>>> your views.py  with next code.
>>>  Look like you would like to have detail  of the deposit in this case
>>> add next string to the header
>>>
>>> from  django.views.generic import DetailView
>>> from models import Account1, Person
>>>
>>>
>>>  # next  you should create a special view class for each Account1
>>>
>>>
>>>  class Deposit(DetailView):
>>> model = Account1
>>>
>>>
>>>   Of course  function Deposit is  useless
>>>
>>>  thats all.
>>>
>>>
>>>  P.S. Look like better way is adding auth  and receive person using auth
>>> data. In this case  every authorized person can  connect to his account
>>>  using auth info and  account id
>>>
>>> Many thanks,
>>>
>>> Serge
>>>
>>>
>>> +380 636150445
>>> skype: skhohlov
>>>
>>> On Thu, Aug 25, 2016 at 8:27 PM, Neil Hunt <hunt.n...@gmail.com> wrote:
>>>
>>>> Thank you so much Andromeda. I didn't know you could use class based
>>>> views. I'll have a look at the documents. I don't know why I was trying to
>>>> use them when I didn't need to.
>>>>
>>>> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
>>>> andromeda.yel...@gmail.com> wrote:
>>>>
>>>>> The stacktrace is helpful, thanks!
>>>>>
>>>>> The specific message with the AttributeError is helpful here:
>>>>> `AttributeError: 'module' object has no attribute 'DepositView'`
>>>>>
>>>>> The line above it is `  File 
>>>>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py",
>>>>> line 8, in 
>>>>> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>>>>>
>>>>> So I checked to see if your views.py contains anything named
>>>>> DepositView...and it does not. That's why the AttributeError is showing 
>>>>> up.
>>>>>
>>>>> The `DepositView.as_view()` syntax is suitable for class-based views,
>>>>> which means I expect to see something in your views.py to the effect of:
>>>>>
>>>>> class DepositView(View):
>>>>>   def post(self, request, *args, **kwargs):
>>>>> // the logic in your deposit() function actually belongs here
>>>>>
>>>>> Have a look at the class-based views documentation to see what the
>>>>> different classes are, and what options they provide you.
>>>>>
>>>>> Alternately, your urls.py could reference views.deposit (which does
>>>>> exist) instead of views.DepositView (which does not).
>>>>>
>>>>> Hope this helps!
>>>>>
>>>>> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com>
>>>>> wrote:
>>>>>
>>>>>> Thanks for your speedy reply, I've attached the stack trace
>>>>>>
>>>>>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>>>>>>>
>>>>>>> Could you share the full stack trace you get when trying to run the
>>>>>>> server ?
>>>>>>> The attribute error should come with a ton of information like the
>>>>>>> file and the line where the error occur.
>>>>>&g

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Sergiy Khohlov
Never mind.
 Few year ago I  was thinking that moving to CBV is bad idea, but suddenly
 BUUUHHH !! in my head and everything was clear.

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Fri, Aug 26, 2016 at 3:40 PM, Neil Hunt <hunt.n...@gmail.com> wrote:

> Hello Serge,
>
> I can't believe that's all I have to add to get the class based views to
> work. It seems easier to get it to work than I thought it would be. Now
> that you've explained it. Thank you so much for that.
>
> Kind regards,
>
> Neil
>
> On Fri, Aug 26, 2016 at 11:46 AM, Sergiy Khohlov <skhoh...@gmail.com>
> wrote:
>
>>  Hello Neil,
>>
>>  It is nota problem  to use Class based view. Could you please  update
>> your views.py  with next code.
>>  Look like you would like to have detail  of the deposit in this case add
>> next string to the header
>>
>> from  django.views.generic import DetailView
>> from models import Account1, Person
>>
>>
>>  # next  you should create a special view class for each Account1
>>
>>
>>  class Deposit(DetailView):
>> model = Account1
>>
>>
>>   Of course  function Deposit is  useless
>>
>>  thats all.
>>
>>
>>  P.S. Look like better way is adding auth  and receive person using auth
>> data. In this case  every authorized person can  connect to his account
>>  using auth info and  account id
>>
>> Many thanks,
>>
>> Serge
>>
>>
>> +380 636150445
>> skype: skhohlov
>>
>> On Thu, Aug 25, 2016 at 8:27 PM, Neil Hunt <hunt.n...@gmail.com> wrote:
>>
>>> Thank you so much Andromeda. I didn't know you could use class based
>>> views. I'll have a look at the documents. I don't know why I was trying to
>>> use them when I didn't need to.
>>>
>>> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
>>> andromeda.yel...@gmail.com> wrote:
>>>
>>>> The stacktrace is helpful, thanks!
>>>>
>>>> The specific message with the AttributeError is helpful here:
>>>> `AttributeError: 'module' object has no attribute 'DepositView'`
>>>>
>>>> The line above it is `  File 
>>>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py",
>>>> line 8, in 
>>>> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>>>>
>>>> So I checked to see if your views.py contains anything named
>>>> DepositView...and it does not. That's why the AttributeError is showing up.
>>>>
>>>> The `DepositView.as_view()` syntax is suitable for class-based views,
>>>> which means I expect to see something in your views.py to the effect of:
>>>>
>>>> class DepositView(View):
>>>>   def post(self, request, *args, **kwargs):
>>>> // the logic in your deposit() function actually belongs here
>>>>
>>>> Have a look at the class-based views documentation to see what the
>>>> different classes are, and what options they provide you.
>>>>
>>>> Alternately, your urls.py could reference views.deposit (which does
>>>> exist) instead of views.DepositView (which does not).
>>>>
>>>> Hope this helps!
>>>>
>>>> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com>
>>>> wrote:
>>>>
>>>>> Thanks for your speedy reply, I've attached the stack trace
>>>>>
>>>>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>>>>>>
>>>>>> Could you share the full stack trace you get when trying to run the
>>>>>> server ?
>>>>>> The attribute error should come with a ton of information like the
>>>>>> file and the line where the error occur.
>>>>>>
>>>>>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com>:
>>>>>> > I've beem working on a simple banking app based on the Django
>>>>>> tutorial.
>>>>>> > Thanks to your help it almost works now. It was working using
>>>>>> templates but
>>>>>> > after making some changes to get HttpResponseRedirect to work I
>>>>>> changed what
>>>>>> > was in the urls file like it shows in the tutorial. Now, the server
>>>>>> doesn't
>>>>>> > run. It says there's an attribute error. I've temporarily left the
>>>>>

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Neil Hunt
Hello Serge,

I can't believe that's all I have to add to get the class based views to
work. It seems easier to get it to work than I thought it would be. Now
that you've explained it. Thank you so much for that.

Kind regards,

Neil

On Fri, Aug 26, 2016 at 11:46 AM, Sergiy Khohlov <skhoh...@gmail.com> wrote:

>  Hello Neil,
>
>  It is nota problem  to use Class based view. Could you please  update
> your views.py  with next code.
>  Look like you would like to have detail  of the deposit in this case add
> next string to the header
>
> from  django.views.generic import DetailView
> from models import Account1, Person
>
>
>  # next  you should create a special view class for each Account1
>
>
>  class Deposit(DetailView):
> model = Account1
>
>
>   Of course  function Deposit is  useless
>
>  thats all.
>
>
>  P.S. Look like better way is adding auth  and receive person using auth
> data. In this case  every authorized person can  connect to his account
>  using auth info and  account id
>
> Many thanks,
>
> Serge
>
>
> +380 636150445
> skype: skhohlov
>
> On Thu, Aug 25, 2016 at 8:27 PM, Neil Hunt <hunt.n...@gmail.com> wrote:
>
>> Thank you so much Andromeda. I didn't know you could use class based
>> views. I'll have a look at the documents. I don't know why I was trying to
>> use them when I didn't need to.
>>
>> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
>> andromeda.yel...@gmail.com> wrote:
>>
>>> The stacktrace is helpful, thanks!
>>>
>>> The specific message with the AttributeError is helpful here:
>>> `AttributeError: 'module' object has no attribute 'DepositView'`
>>>
>>> The line above it is `  File 
>>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py",
>>> line 8, in 
>>> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>>>
>>> So I checked to see if your views.py contains anything named
>>> DepositView...and it does not. That's why the AttributeError is showing up.
>>>
>>> The `DepositView.as_view()` syntax is suitable for class-based views,
>>> which means I expect to see something in your views.py to the effect of:
>>>
>>> class DepositView(View):
>>>   def post(self, request, *args, **kwargs):
>>> // the logic in your deposit() function actually belongs here
>>>
>>> Have a look at the class-based views documentation to see what the
>>> different classes are, and what options they provide you.
>>>
>>> Alternately, your urls.py could reference views.deposit (which does
>>> exist) instead of views.DepositView (which does not).
>>>
>>> Hope this helps!
>>>
>>> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com> wrote:
>>>
>>>> Thanks for your speedy reply, I've attached the stack trace
>>>>
>>>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>>>>>
>>>>> Could you share the full stack trace you get when trying to run the
>>>>> server ?
>>>>> The attribute error should come with a ton of information like the
>>>>> file and the line where the error occur.
>>>>>
>>>>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com>:
>>>>> > I've beem working on a simple banking app based on the Django
>>>>> tutorial.
>>>>> > Thanks to your help it almost works now. It was working using
>>>>> templates but
>>>>> > after making some changes to get HttpResponseRedirect to work I
>>>>> changed what
>>>>> > was in the urls file like it shows in the tutorial. Now, the server
>>>>> doesn't
>>>>> > run. It says there's an attribute error. I've temporarily left the
>>>>> user name
>>>>> > and password in at the moment. I had a look at their tutorial how to
>>>>> do a
>>>>> > use the Django authentication system (thanks for telling me about
>>>>> that) and
>>>>> > I'm going to change that after I understand what's going on here.
>>>>> It's
>>>>> > amazing how much you can do with Django. Do you think with time you
>>>>> get more
>>>>> > used to what different errors mean? The errors seem new and
>>>>> confusing to me
>>>>> > at the moment. Any help would be very much appreciated. Thanks in
>&g

Re: Attribute error, with a very basic banking app

2016-08-26 Thread Sergiy Khohlov
 Hello Neil,

 It is nota problem  to use Class based view. Could you please  update your
views.py  with next code.
 Look like you would like to have detail  of the deposit in this case add
next string to the header

from  django.views.generic import DetailView
from models import Account1, Person


 # next  you should create a special view class for each Account1


 class Deposit(DetailView):
model = Account1


  Of course  function Deposit is  useless

 thats all.


 P.S. Look like better way is adding auth  and receive person using auth
data. In this case  every authorized person can  connect to his account
 using auth info and  account id

Many thanks,

Serge


+380 636150445
skype: skhohlov

On Thu, Aug 25, 2016 at 8:27 PM, Neil Hunt <hunt.n...@gmail.com> wrote:

> Thank you so much Andromeda. I didn't know you could use class based
> views. I'll have a look at the documents. I don't know why I was trying to
> use them when I didn't need to.
>
> On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
> andromeda.yel...@gmail.com> wrote:
>
>> The stacktrace is helpful, thanks!
>>
>> The specific message with the AttributeError is helpful here:
>> `AttributeError: 'module' object has no attribute 'DepositView'`
>>
>> The line above it is `  File 
>> "/home/soupdragon/DJapps/banking/mybank/banking/urls.py",
>> line 8, in 
>> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>>
>> So I checked to see if your views.py contains anything named
>> DepositView...and it does not. That's why the AttributeError is showing up.
>>
>> The `DepositView.as_view()` syntax is suitable for class-based views,
>> which means I expect to see something in your views.py to the effect of:
>>
>> class DepositView(View):
>>   def post(self, request, *args, **kwargs):
>> // the logic in your deposit() function actually belongs here
>>
>> Have a look at the class-based views documentation to see what the
>> different classes are, and what options they provide you.
>>
>> Alternately, your urls.py could reference views.deposit (which does
>> exist) instead of views.DepositView (which does not).
>>
>> Hope this helps!
>>
>> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com> wrote:
>>
>>> Thanks for your speedy reply, I've attached the stack trace
>>>
>>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>>>>
>>>> Could you share the full stack trace you get when trying to run the
>>>> server ?
>>>> The attribute error should come with a ton of information like the
>>>> file and the line where the error occur.
>>>>
>>>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com>:
>>>> > I've beem working on a simple banking app based on the Django
>>>> tutorial.
>>>> > Thanks to your help it almost works now. It was working using
>>>> templates but
>>>> > after making some changes to get HttpResponseRedirect to work I
>>>> changed what
>>>> > was in the urls file like it shows in the tutorial. Now, the server
>>>> doesn't
>>>> > run. It says there's an attribute error. I've temporarily left the
>>>> user name
>>>> > and password in at the moment. I had a look at their tutorial how to
>>>> do a
>>>> > use the Django authentication system (thanks for telling me about
>>>> that) and
>>>> > I'm going to change that after I understand what's going on here.
>>>> It's
>>>> > amazing how much you can do with Django. Do you think with time you
>>>> get more
>>>> > used to what different errors mean? The errors seem new and confusing
>>>> to me
>>>> > at the moment. Any help would be very much appreciated. Thanks in
>>>> advnace.
>>>> >
>>>> > --
>>>> > 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 https://groups.google.com/group/django-users.
>>>> > To view this discussion on the web visit
>>>> > https://groups.google.com/d/msgid/django-users/b30091ce-fcbf
>>>> -461e-

Re: Attribute error, with a very basic banking app

2016-08-25 Thread Neil Hunt
Thank you so much Andromeda. I didn't know you could use class based views.
I'll have a look at the documents. I don't know why I was trying to use
them when I didn't need to.

On Thu, Aug 25, 2016 at 4:23 PM, Andromeda Yelton <
andromeda.yel...@gmail.com> wrote:

> The stacktrace is helpful, thanks!
>
> The specific message with the AttributeError is helpful here:
> `AttributeError: 'module' object has no attribute 'DepositView'`
>
> The line above it is `  File "/home/soupdragon/DJapps/
> banking/mybank/banking/urls.py", line 8, in 
> url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`
>
> So I checked to see if your views.py contains anything named
> DepositView...and it does not. That's why the AttributeError is showing up.
>
> The `DepositView.as_view()` syntax is suitable for class-based views,
> which means I expect to see something in your views.py to the effect of:
>
> class DepositView(View):
>   def post(self, request, *args, **kwargs):
> // the logic in your deposit() function actually belongs here
>
> Have a look at the class-based views documentation to see what the
> different classes are, and what options they provide you.
>
> Alternately, your urls.py could reference views.deposit (which does exist)
> instead of views.DepositView (which does not).
>
> Hope this helps!
>
> On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com> wrote:
>
>> Thanks for your speedy reply, I've attached the stack trace
>>
>> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>>>
>>> Could you share the full stack trace you get when trying to run the
>>> server ?
>>> The attribute error should come with a ton of information like the
>>> file and the line where the error occur.
>>>
>>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com>:
>>> > I've beem working on a simple banking app based on the Django
>>> tutorial.
>>> > Thanks to your help it almost works now. It was working using
>>> templates but
>>> > after making some changes to get HttpResponseRedirect to work I
>>> changed what
>>> > was in the urls file like it shows in the tutorial. Now, the server
>>> doesn't
>>> > run. It says there's an attribute error. I've temporarily left the
>>> user name
>>> > and password in at the moment. I had a look at their tutorial how to
>>> do a
>>> > use the Django authentication system (thanks for telling me about
>>> that) and
>>> > I'm going to change that after I understand what's going on here. It's
>>> > amazing how much you can do with Django. Do you think with time you
>>> get more
>>> > used to what different errors mean? The errors seem new and confusing
>>> to me
>>> > at the moment. Any help would be very much appreciated. Thanks in
>>> advnace.
>>> >
>>> > --
>>> > 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 https://groups.google.com/group/django-users.
>>> > To view this discussion on the web visit
>>> > https://groups.google.com/d/msgid/django-users/b30091ce-fcbf
>>> -461e-869e-bba72eb9dcfe%40googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>> --
>>>
>>> Cordialement, Coues Ludovic
>>> +336 148 743 42
>>>
>> --
>> 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/ms
>> gid/django-users/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-users/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com?utm_medium=email_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Andr

Re: Attribute error, with a very basic banking app

2016-08-25 Thread Andromeda Yelton
The stacktrace is helpful, thanks!

The specific message with the AttributeError is helpful here:
`AttributeError: 'module' object has no attribute 'DepositView'`

The line above it is `  File
"/home/soupdragon/DJapps/banking/mybank/banking/urls.py", line 8, in

url(r'^deposit/$', views.DepositView.as_view(), name='deposit'),`

So I checked to see if your views.py contains anything named
DepositView...and it does not. That's why the AttributeError is showing up.

The `DepositView.as_view()` syntax is suitable for class-based views, which
means I expect to see something in your views.py to the effect of:

class DepositView(View):
  def post(self, request, *args, **kwargs):
// the logic in your deposit() function actually belongs here

Have a look at the class-based views documentation to see what the
different classes are, and what options they provide you.

Alternately, your urls.py could reference views.deposit (which does exist)
instead of views.DepositView (which does not).

Hope this helps!

On Thu, Aug 25, 2016 at 11:14 AM, Neil Hunt <hunt.n...@gmail.com> wrote:

> Thanks for your speedy reply, I've attached the stack trace
>
> On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>>
>> Could you share the full stack trace you get when trying to run the
>> server ?
>> The attribute error should come with a ton of information like the
>> file and the line where the error occur.
>>
>> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com>:
>> > I've beem working on a simple banking app based on the Django tutorial.
>> > Thanks to your help it almost works now. It was working using templates
>> but
>> > after making some changes to get HttpResponseRedirect to work I changed
>> what
>> > was in the urls file like it shows in the tutorial. Now, the server
>> doesn't
>> > run. It says there's an attribute error. I've temporarily left the user
>> name
>> > and password in at the moment. I had a look at their tutorial how to do
>> a
>> > use the Django authentication system (thanks for telling me about that)
>> and
>> > I'm going to change that after I understand what's going on here. It's
>> > amazing how much you can do with Django. Do you think with time you get
>> more
>> > used to what different errors mean? The errors seem new and confusing
>> to me
>> > at the moment. Any help would be very much appreciated. Thanks in
>> advnace.
>> >
>> > --
>> > 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 https://groups.google.com/group/django-users.
>> > To view this discussion on the web visit
>> > https://groups.google.com/d/msgid/django-users/b30091ce-fcbf
>> -461e-869e-bba72eb9dcfe%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>>
>> Cordialement, Coues Ludovic
>> +336 148 743 42
>>
> --
> 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/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com?utm_medium=email_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andromeda Yelton
Vice President/President-Elect, Library & Information Technology
Association: http://www.lita.org
http://andromedayelton.com
@ThatAndromeda <http://twitter.com/ThatAndromeda>

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


Re: Attribute error, with a very basic banking app

2016-08-25 Thread Neil Hunt
Thanks for your speedy reply, I've attached the stack trace

On Thursday, August 25, 2016 at 4:00:16 PM UTC+1, ludovic coues wrote:
>
> Could you share the full stack trace you get when trying to run the server 
> ? 
> The attribute error should come with a ton of information like the 
> file and the line where the error occur. 
>
> 2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt...@gmail.com >: 
> > I've beem working on a simple banking app based on the Django tutorial. 
> > Thanks to your help it almost works now. It was working using templates 
> but 
> > after making some changes to get HttpResponseRedirect to work I changed 
> what 
> > was in the urls file like it shows in the tutorial. Now, the server 
> doesn't 
> > run. It says there's an attribute error. I've temporarily left the user 
> name 
> > and password in at the moment. I had a look at their tutorial how to do 
> a 
> > use the Django authentication system (thanks for telling me about that) 
> and 
> > I'm going to change that after I understand what's going on here. It's 
> > amazing how much you can do with Django. Do you think with time you get 
> more 
> > used to what different errors mean? The errors seem new and confusing to 
> me 
> > at the moment. Any help would be very much appreciated. Thanks in 
> advnace. 
> > 
> > -- 
> > 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 https://groups.google.com/group/django-users. 
> > To view this discussion on the web visit 
> > 
> https://groups.google.com/d/msgid/django-users/b30091ce-fcbf-461e-869e-bba72eb9dcfe%40googlegroups.com.
>  
>
> > For more options, visit https://groups.google.com/d/optout. 
>
>
>
> -- 
>
> Cordialement, Coues Ludovic 
> +336 148 743 42 
>

-- 
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/b9b247a9-830d-4cc0-a441-5a8013899f13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


tracext
Description: Binary data


Re: Attribute error, with a very basic banking app

2016-08-25 Thread ludovic coues
Could you share the full stack trace you get when trying to run the server ?
The attribute error should come with a ton of information like the
file and the line where the error occur.

2016-08-25 16:57 GMT+02:00 Neil Hunt <hunt.n...@gmail.com>:
> I've beem working on a simple banking app based on the Django tutorial.
> Thanks to your help it almost works now. It was working using templates but
> after making some changes to get HttpResponseRedirect to work I changed what
> was in the urls file like it shows in the tutorial. Now, the server doesn't
> run. It says there's an attribute error. I've temporarily left the user name
> and password in at the moment. I had a look at their tutorial how to do a
> use the Django authentication system (thanks for telling me about that) and
> I'm going to change that after I understand what's going on here. It's
> amazing how much you can do with Django. Do you think with time you get more
> used to what different errors mean? The errors seem new and confusing to me
> at the moment. Any help would be very much appreciated. Thanks in advnace.
>
> --
> 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/b30091ce-fcbf-461e-869e-bba72eb9dcfe%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTa-x_Dq3_JY68WP%3DPAqdR9QG5HQBuN6zX82fzP9eEK4vQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Attribute error, with a very basic banking app

2016-08-25 Thread Neil Hunt
I've beem working on a simple banking app based on the Django tutorial. 
Thanks to your help it almost works now. It was working using templates but 
after making some changes to get HttpResponseRedirect to work I changed 
what was in the urls file like it shows in the tutorial. Now, the server 
doesn't run. It says there's an attribute error. I've temporarily left the 
user name and password in at the moment. I had a look at their tutorial how 
to do a use the Django authentication system (thanks for telling me about 
that) and I'm going to change that after I understand what's going on here. 
It's amazing how much you can do with Django. Do you think with time you 
get more used to what different errors mean? The errors seem new and 
confusing to me at the moment. Any help would be very much appreciated. 
Thanks in advnace.

-- 
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/b30091ce-fcbf-461e-869e-bba72eb9dcfe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Title: Login
{% load staticfiles %}


 
 





{% csrf_token %}
Your details:

Username:

Password:







from django.shortcuts import get_object_or_404
from django.shortcuts import render
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
#from django.template import loader
from django.views import generic

from .models import Person, Account1

# Create your views here.
def deposit(request):
	selected_rbox = request.POST.get('Account1')
	selected_rbox = request.POST.get('Account2')
	selected_amount = request.POST.get('Amount')
	person = Person
	account1 = Account1
	context = {'account1':account1,'person':person}
	template = loader.get_template('banking/deposit.html')
	return HttpResponse(template.render(context,request))

def hello(request):
	person = Person
	account1 = Account1
	context = {'account1':account1,'person':person}
	#template = loader.get_template('banking/login.html')
	#return HttpResponse(template.render(context,request))
	return render(request, 'banking/login.html')
	#return render(request, 'banking/login.html', {
	#	'person': person,
	#	'error_message': "You didn't select a choice.",
#	})
	
def login(request):
	#account1 = get_object_or_404(Account1) 
	#person = get_object_or_404(Person) 
	account1 = Account1
	person = Person 
	try:
		selected_login = request.POST.get('login')
		selected_username = request.POST.get('username')
		#selected_login = person.choice_set.get(pk=request.POST['login'])
		#selected_password = person.choice_set.get(pk=request.POST['password'])

	# What is Choice object doing in the line below?
	#except (KeyError, Choice.DoesNotExist):
	except (KeyError, Account1.DoesNotExist):
	#except (KeyError, Account1.DoesNotExist):
# Redisplay the question voting form.
		#account1 = get_object_or_404(Account1) 
		#person = get_object_or_404(Person) 
		#person = Person
		#account1 = Account1
		#return render(request, 'banking/login.html', {
	#'person': person,
	#'error_message': "You didn't select a choice.",
		#return render(request, 'banking/login.html')
		return render(request, 'banking/login.html', {
		'person': person,
		'error_message': "You didn't select a choice.",
	})

		#person = Person
		#account1 = Account1
		#context = {'account1':account1,'person':person}
		#template = loader.get_template('banking/login.html')
		#return HttpResponse(template.render(context,request)
	else:
	# Always return an HttpResponseRedirect after successfully dealing
	# with POST data. This prevents data from being posted twice if a
	# user hits the Back button.
		#person = Person
		#account1 = Account1
		#context = {'account1':account1,'person':person}
		#template = loader.get_template('banking/welcome.html')
		#return HttpResponse(template.render(context,request))
		return HttpResponseRedirect(reverse('banking:welcome'))


def transfer(request):
	person = Person
	account1 = Account1
	context = {'account1':account1,'person':person}
	template = loader.get_template('banking/transfer.html')
	return HttpResponse(template.render(context,request))

def welcome(request):
	person = Person
	account1 = Account1
	context = {'account1':account1,'person':person}
	template = loader.get_template('banking/welcome.html')
	return HttpResponse(template.render(context,request))

def withdraw(request):
	person = Person
	account1 = Account1
	context = {'account1':account1,'person':person}
	template = loader.get_template('banking/withdraw.html')
	return HttpRespons

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Hmm...I see. How do you choose what variables are available to which
view? It seems like anything I put in context_processors is available
anywhere, and I'm not sure I want that.

I think I am getting closer, but I am now getting a
SiteProfileNotAvailable error.

Here is my stack trace:

http://dpaste.com/566744/

Thanks for the help.

On Jul 11, 2:01 pm, Andre Terra  wrote:
> You could use a context processor, which is basically a function that adds
> variables to *every* template that gets called from a properly setup view. I
> assume the view you are using does apply context processors, and defining
> one is as easy as:
>
> http://stackoverflow.com/questions/3722174/django-template-inheritanc...
>
> You can try step #3 once you feel confident enough to write views (they are
> very simple!)
>
> Cheers,
> André Terra (airstrike)
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 5:12 PM, Brent  wrote:
> > Sorry, I meant I was hoping to avoid diving into defining my own views
> > until later.
>
> > On Jul 11, 1:08 pm, Brent  wrote:
> > > So I need to create a custom view? (I can't use an existing view)? I
> > > was hoping to avoid diving into templates until later, after I've
> > > become a little more familiar with the python/html code.
>
> > > On Jul 11, 11:48 am, Andre Terra  wrote:
>
> > > > This is done in your view:
>
> > > >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-.
> > ..
>
> > > > Cheers
>
> > > > On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > > > > Is this done in urls.py?
>
> > > > > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > > > > Pass user.get_profile() as a template variable instead by adding it
> > to
> > > > > the
> > > > > > template context.
>
> > > > > > Cheers,
> > > > > > André
>
> > > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent 
> > wrote:
> > > > > > > Okay, thanks. This is really helpful.
>
> > > > > > > I am having trouble calling get_profile() from within my
> > profile.html
> > > > > > > template, though. Here is my stack trace:
>
> > > > > > >http://dpaste.com/566583/
>
> > > > > > > I tried calling get_profile without the (), which got rid of the
> > > > > > > error, but no data showed up.
>
> > > > > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > > > > All you have to do is add the following code to your models.py
> > (or
> > > > > any
> > > > > > > other
> > > > > > > > module that gets loaded by django, for that matter):
>
> > > > > > > > # models.py
> > > > > > > > from django.db.models import signals
>
> > > > > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > > > > >      if created:
> > > > > > > >         UserProfile.objects.create(user=instance)
>
> > > > > > > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > > > > > > (assuming your profile model is called UserProfile, of course).
>
> > > > > > > > When django loads models.py, it will call that connect() method
> > which
> > > > > in
> > > > > > > > turn makes create_user_profile get called every time the sender
> > model
> > > > > > > (User)
> > > > > > > > is saved (hence the 'post_save').
>
> > > > > > > > More on this athttps://
> > docs.djangoproject.com/en/dev/ref/signals/
>
> > > > > > > > Cheers,
> > > > > > > > André Terra
>
> > > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent 
> > wrote:
> > > > > > > > > I am having trouble with this line of the tutorial: "You need
> > to
> > > > > > > > > register a handler for the signal
> > > > > django.db.models.signals.post_save
> > > > > > > > > on the User model, and, in the handler, if created=True,
> > create the
> > > > > > > > > associated user profile."
>
> > > > > > > > > It seems I need to edit the User model. I am confused,
> > though,
> > > > > because
> > > > > > > > > I am using the User model included in django.contrib, and I
> > am very
> > > > > > > > > hesitant to edit files that are not in my project directory.
>
> > > > > > > > > Is this bad design to be using a mix of things I've written
> > on my
> > > > > own,
> > > > > > > > > and things that were already included in Django? (i.e. should
> > I
> > > > > write
> > > > > > > > > everything from scratch?)
>
> > > > > > > > > Thanks.
>
> > > > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz  wrote:
> > > > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > > > > > > How do I use a foreign key, though? In other words, how
> > do I
> > > > > tell
> > > > > > > my
> > > > > > > > > > > code to look at UserProfile rather than just user?
>
> >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > > > > ..
>
> > > > > > > > > > --
> > > > > > > > > > Micha³ (Saviq) Sawicz 
>
> > > > > > > > > >  signature.asc
> > > > > > > > > > < 

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
You could use a context processor, which is basically a function that adds
variables to *every* template that gets called from a properly setup view. I
assume the view you are using does apply context processors, and defining
one is as easy as:

http://stackoverflow.com/questions/3722174/django-template-inheritance-and-context/3731459#3731459

You can try step #3 once you feel confident enough to write views (they are
very simple!)


Cheers,
André Terra (airstrike)

On Mon, Jul 11, 2011 at 5:12 PM, Brent  wrote:

> Sorry, I meant I was hoping to avoid diving into defining my own views
> until later.
>
> On Jul 11, 1:08 pm, Brent  wrote:
> > So I need to create a custom view? (I can't use an existing view)? I
> > was hoping to avoid diving into templates until later, after I've
> > become a little more familiar with the python/html code.
> >
> > On Jul 11, 11:48 am, Andre Terra  wrote:
> >
> >
> >
> >
> >
> >
> >
> > > This is done in your view:
> >
> > >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-.
> ..
> >
> > > Cheers
> >
> > > On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > > > Is this done in urls.py?
> >
> > > > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > > > Pass user.get_profile() as a template variable instead by adding it
> to
> > > > the
> > > > > template context.
> >
> > > > > Cheers,
> > > > > André
> >
> > > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent 
> wrote:
> > > > > > Okay, thanks. This is really helpful.
> >
> > > > > > I am having trouble calling get_profile() from within my
> profile.html
> > > > > > template, though. Here is my stack trace:
> >
> > > > > >http://dpaste.com/566583/
> >
> > > > > > I tried calling get_profile without the (), which got rid of the
> > > > > > error, but no data showed up.
> >
> > > > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > > > All you have to do is add the following code to your models.py
> (or
> > > > any
> > > > > > other
> > > > > > > module that gets loaded by django, for that matter):
> >
> > > > > > > # models.py
> > > > > > > from django.db.models import signals
> >
> > > > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > > > >  if created:
> > > > > > > UserProfile.objects.create(user=instance)
> >
> > > > > > > signals.post_save.connect(create_user_profile, sender=User)
> >
> > > > > > > (assuming your profile model is called UserProfile, of course).
> >
> > > > > > > When django loads models.py, it will call that connect() method
> which
> > > > in
> > > > > > > turn makes create_user_profile get called every time the sender
> model
> > > > > > (User)
> > > > > > > is saved (hence the 'post_save').
> >
> > > > > > > More on this athttps://
> docs.djangoproject.com/en/dev/ref/signals/
> >
> > > > > > > Cheers,
> > > > > > > André Terra
> >
> > > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent 
> wrote:
> > > > > > > > I am having trouble with this line of the tutorial: "You need
> to
> > > > > > > > register a handler for the signal
> > > > django.db.models.signals.post_save
> > > > > > > > on the User model, and, in the handler, if created=True,
> create the
> > > > > > > > associated user profile."
> >
> > > > > > > > It seems I need to edit the User model. I am confused,
> though,
> > > > because
> > > > > > > > I am using the User model included in django.contrib, and I
> am very
> > > > > > > > hesitant to edit files that are not in my project directory.
> >
> > > > > > > > Is this bad design to be using a mix of things I've written
> on my
> > > > own,
> > > > > > > > and things that were already included in Django? (i.e. should
> I
> > > > write
> > > > > > > > everything from scratch?)
> >
> > > > > > > > Thanks.
> >
> > > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz  wrote:
> > > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > > > > > > > > How do I use a foreign key, though? In other words, how
> do I
> > > > tell
> > > > > > my
> > > > > > > > > > code to look at UserProfile rather than just user?
> >
> > > > > >
> https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > > > ..
> >
> > > > > > > > > --
> > > > > > > > > Micha³ (Saviq) Sawicz 
> >
> > > > > > > > >  signature.asc
> > > > > > > > > < 1KViewDownload
> >
> > > > > > > > --
> > > > > > > > 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
> > > > > > > 

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Sorry, I meant I was hoping to avoid diving into defining my own views
until later.

On Jul 11, 1:08 pm, Brent  wrote:
> So I need to create a custom view? (I can't use an existing view)? I
> was hoping to avoid diving into templates until later, after I've
> become a little more familiar with the python/html code.
>
> On Jul 11, 11:48 am, Andre Terra  wrote:
>
>
>
>
>
>
>
> > This is done in your view:
>
> >https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-...
>
> > Cheers
>
> > On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > > Is this done in urls.py?
>
> > > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > > Pass user.get_profile() as a template variable instead by adding it to
> > > the
> > > > template context.
>
> > > > Cheers,
> > > > André
>
> > > > On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > > > > Okay, thanks. This is really helpful.
>
> > > > > I am having trouble calling get_profile() from within my profile.html
> > > > > template, though. Here is my stack trace:
>
> > > > >http://dpaste.com/566583/
>
> > > > > I tried calling get_profile without the (), which got rid of the
> > > > > error, but no data showed up.
>
> > > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > > All you have to do is add the following code to your models.py (or
> > > any
> > > > > other
> > > > > > module that gets loaded by django, for that matter):
>
> > > > > > # models.py
> > > > > > from django.db.models import signals
>
> > > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > > >      if created:
> > > > > >         UserProfile.objects.create(user=instance)
>
> > > > > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > > > > (assuming your profile model is called UserProfile, of course).
>
> > > > > > When django loads models.py, it will call that connect() method 
> > > > > > which
> > > in
> > > > > > turn makes create_user_profile get called every time the sender 
> > > > > > model
> > > > > (User)
> > > > > > is saved (hence the 'post_save').
>
> > > > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> > > > > > Cheers,
> > > > > > André Terra
>
> > > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > > > > I am having trouble with this line of the tutorial: "You need to
> > > > > > > register a handler for the signal
> > > django.db.models.signals.post_save
> > > > > > > on the User model, and, in the handler, if created=True, create 
> > > > > > > the
> > > > > > > associated user profile."
>
> > > > > > > It seems I need to edit the User model. I am confused, though,
> > > because
> > > > > > > I am using the User model included in django.contrib, and I am 
> > > > > > > very
> > > > > > > hesitant to edit files that are not in my project directory.
>
> > > > > > > Is this bad design to be using a mix of things I've written on my
> > > own,
> > > > > > > and things that were already included in Django? (i.e. should I
> > > write
> > > > > > > everything from scratch?)
>
> > > > > > > Thanks.
>
> > > > > > > On Jul 11, 9:54 am, Micha³ Sawicz  wrote:
> > > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > > > > How do I use a foreign key, though? In other words, how do I
> > > tell
> > > > > my
> > > > > > > > > code to look at UserProfile rather than just user?
>
> > > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > > ..
>
> > > > > > > > --
> > > > > > > > Micha³ (Saviq) Sawicz 
>
> > > > > > > >  signature.asc
> > > > > > > > < 1KViewDownload
>
> > > > > > > --
> > > > > > > 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.
>
> > > --
> > > 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, 

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
So I need to create a custom view? (I can't use an existing view)? I
was hoping to avoid diving into templates until later, after I've
become a little more familiar with the python/html code.

On Jul 11, 11:48 am, Andre Terra  wrote:
> This is done in your view:
>
> https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-...
>
> Cheers
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:
> > Is this done in urls.py?
>
> > On Jul 11, 10:55 am, Andre Terra  wrote:
> > > Pass user.get_profile() as a template variable instead by adding it to
> > the
> > > template context.
>
> > > Cheers,
> > > André
>
> > > On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > > > Okay, thanks. This is really helpful.
>
> > > > I am having trouble calling get_profile() from within my profile.html
> > > > template, though. Here is my stack trace:
>
> > > >http://dpaste.com/566583/
>
> > > > I tried calling get_profile without the (), which got rid of the
> > > > error, but no data showed up.
>
> > > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > > All you have to do is add the following code to your models.py (or
> > any
> > > > other
> > > > > module that gets loaded by django, for that matter):
>
> > > > > # models.py
> > > > > from django.db.models import signals
>
> > > > > def create_user_profile(sender, instance, created, **kwargs):
> > > > >      if created:
> > > > >         UserProfile.objects.create(user=instance)
>
> > > > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > > > (assuming your profile model is called UserProfile, of course).
>
> > > > > When django loads models.py, it will call that connect() method which
> > in
> > > > > turn makes create_user_profile get called every time the sender model
> > > > (User)
> > > > > is saved (hence the 'post_save').
>
> > > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> > > > > Cheers,
> > > > > André Terra
>
> > > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > > > I am having trouble with this line of the tutorial: "You need to
> > > > > > register a handler for the signal
> > django.db.models.signals.post_save
> > > > > > on the User model, and, in the handler, if created=True, create the
> > > > > > associated user profile."
>
> > > > > > It seems I need to edit the User model. I am confused, though,
> > because
> > > > > > I am using the User model included in django.contrib, and I am very
> > > > > > hesitant to edit files that are not in my project directory.
>
> > > > > > Is this bad design to be using a mix of things I've written on my
> > own,
> > > > > > and things that were already included in Django? (i.e. should I
> > write
> > > > > > everything from scratch?)
>
> > > > > > Thanks.
>
> > > > > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > > > How do I use a foreign key, though? In other words, how do I
> > tell
> > > > my
> > > > > > > > code to look at UserProfile rather than just user?
>
> > > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> > ..
>
> > > > > > > --
> > > > > > > Michał (Saviq) Sawicz 
>
> > > > > > >  signature.asc
> > > > > > > < 1KViewDownload
>
> > > > > > --
> > > > > > 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.
>
> > --
> > 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 

Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
This is done in your view:

https://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext


Cheers

On Mon, Jul 11, 2011 at 3:12 PM, Brent  wrote:

> Is this done in urls.py?
>
> On Jul 11, 10:55 am, Andre Terra  wrote:
> > Pass user.get_profile() as a template variable instead by adding it to
> the
> > template context.
> >
> > Cheers,
> > André
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > > Okay, thanks. This is really helpful.
> >
> > > I am having trouble calling get_profile() from within my profile.html
> > > template, though. Here is my stack trace:
> >
> > >http://dpaste.com/566583/
> >
> > > I tried calling get_profile without the (), which got rid of the
> > > error, but no data showed up.
> >
> > > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > > All you have to do is add the following code to your models.py (or
> any
> > > other
> > > > module that gets loaded by django, for that matter):
> >
> > > > # models.py
> > > > from django.db.models import signals
> >
> > > > def create_user_profile(sender, instance, created, **kwargs):
> > > >  if created:
> > > > UserProfile.objects.create(user=instance)
> >
> > > > signals.post_save.connect(create_user_profile, sender=User)
> >
> > > > (assuming your profile model is called UserProfile, of course).
> >
> > > > When django loads models.py, it will call that connect() method which
> in
> > > > turn makes create_user_profile get called every time the sender model
> > > (User)
> > > > is saved (hence the 'post_save').
> >
> > > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
> >
> > > > Cheers,
> > > > André Terra
> >
> > > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > > I am having trouble with this line of the tutorial: "You need to
> > > > > register a handler for the signal
> django.db.models.signals.post_save
> > > > > on the User model, and, in the handler, if created=True, create the
> > > > > associated user profile."
> >
> > > > > It seems I need to edit the User model. I am confused, though,
> because
> > > > > I am using the User model included in django.contrib, and I am very
> > > > > hesitant to edit files that are not in my project directory.
> >
> > > > > Is this bad design to be using a mix of things I've written on my
> own,
> > > > > and things that were already included in Django? (i.e. should I
> write
> > > > > everything from scratch?)
> >
> > > > > Thanks.
> >
> > > > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > > > > > How do I use a foreign key, though? In other words, how do I
> tell
> > > my
> > > > > > > code to look at UserProfile rather than just user?
> >
> > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional.
> ..
> >
> > > > > > --
> > > > > > Michał (Saviq) Sawicz 
> >
> > > > > >  signature.asc
> > > > > > < 1KViewDownload
> >
> > > > > --
> > > > > 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.
>
> --
> 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: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Is this done in urls.py?

On Jul 11, 10:55 am, Andre Terra  wrote:
> Pass user.get_profile() as a template variable instead by adding it to the
> template context.
>
> Cheers,
> André
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:
> > Okay, thanks. This is really helpful.
>
> > I am having trouble calling get_profile() from within my profile.html
> > template, though. Here is my stack trace:
>
> >http://dpaste.com/566583/
>
> > I tried calling get_profile without the (), which got rid of the
> > error, but no data showed up.
>
> > On Jul 11, 10:15 am, Andre Terra  wrote:
> > > All you have to do is add the following code to your models.py (or any
> > other
> > > module that gets loaded by django, for that matter):
>
> > > # models.py
> > > from django.db.models import signals
>
> > > def create_user_profile(sender, instance, created, **kwargs):
> > >      if created:
> > >         UserProfile.objects.create(user=instance)
>
> > > signals.post_save.connect(create_user_profile, sender=User)
>
> > > (assuming your profile model is called UserProfile, of course).
>
> > > When django loads models.py, it will call that connect() method which in
> > > turn makes create_user_profile get called every time the sender model
> > (User)
> > > is saved (hence the 'post_save').
>
> > > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> > > Cheers,
> > > André Terra
>
> > > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > > I am having trouble with this line of the tutorial: "You need to
> > > > register a handler for the signal django.db.models.signals.post_save
> > > > on the User model, and, in the handler, if created=True, create the
> > > > associated user profile."
>
> > > > It seems I need to edit the User model. I am confused, though, because
> > > > I am using the User model included in django.contrib, and I am very
> > > > hesitant to edit files that are not in my project directory.
>
> > > > Is this bad design to be using a mix of things I've written on my own,
> > > > and things that were already included in Django? (i.e. should I write
> > > > everything from scratch?)
>
> > > > Thanks.
>
> > > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > > > How do I use a foreign key, though? In other words, how do I tell
> > my
> > > > > > code to look at UserProfile rather than just user?
>
> >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
>
> > > > > --
> > > > > Michał (Saviq) Sawicz 
>
> > > > >  signature.asc
> > > > > < 1KViewDownload
>
> > > > --
> > > > 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.

-- 
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: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Okay, thanks. This is really helpful.

I am having trouble calling get_profile() from within my profile.html
template, though. Here is my stack trace:

http://dpaste.com/566583/

I tried calling get_profile without the (), which got rid of the
error, but no data showed up.

On Jul 11, 10:15 am, Andre Terra  wrote:
> All you have to do is add the following code to your models.py (or any other
> module that gets loaded by django, for that matter):
>
> # models.py
> from django.db.models import signals
>
> def create_user_profile(sender, instance, created, **kwargs):
>      if created:
>         UserProfile.objects.create(user=instance)
>
> signals.post_save.connect(create_user_profile, sender=User)
>
> (assuming your profile model is called UserProfile, of course).
>
> When django loads models.py, it will call that connect() method which in
> turn makes create_user_profile get called every time the sender model (User)
> is saved (hence the 'post_save').
>
> More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
>
> Cheers,
> André Terra
>
>
>
>
>
>
>
> On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > I am having trouble with this line of the tutorial: "You need to
> > register a handler for the signal django.db.models.signals.post_save
> > on the User model, and, in the handler, if created=True, create the
> > associated user profile."
>
> > It seems I need to edit the User model. I am confused, though, because
> > I am using the User model included in django.contrib, and I am very
> > hesitant to edit files that are not in my project directory.
>
> > Is this bad design to be using a mix of things I've written on my own,
> > and things that were already included in Django? (i.e. should I write
> > everything from scratch?)
>
> > Thanks.
>
> > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > > > How do I use a foreign key, though? In other words, how do I tell my
> > > > code to look at UserProfile rather than just user?
>
> > >https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
>
> > > --
> > > Michał (Saviq) Sawicz 
>
> > >  signature.asc
> > > < 1KViewDownload
>
> > --
> > 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: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
Pass user.get_profile() as a template variable instead by adding it to the
template context.


Cheers,
André

On Mon, Jul 11, 2011 at 2:50 PM, Brent  wrote:

> Okay, thanks. This is really helpful.
>
> I am having trouble calling get_profile() from within my profile.html
> template, though. Here is my stack trace:
>
> http://dpaste.com/566583/
>
> I tried calling get_profile without the (), which got rid of the
> error, but no data showed up.
>
> On Jul 11, 10:15 am, Andre Terra  wrote:
> > All you have to do is add the following code to your models.py (or any
> other
> > module that gets loaded by django, for that matter):
> >
> > # models.py
> > from django.db.models import signals
> >
> > def create_user_profile(sender, instance, created, **kwargs):
> >  if created:
> > UserProfile.objects.create(user=instance)
> >
> > signals.post_save.connect(create_user_profile, sender=User)
> >
> > (assuming your profile model is called UserProfile, of course).
> >
> > When django loads models.py, it will call that connect() method which in
> > turn makes create_user_profile get called every time the sender model
> (User)
> > is saved (hence the 'post_save').
> >
> > More on this athttps://docs.djangoproject.com/en/dev/ref/signals/
> >
> > Cheers,
> > André Terra
> >
> >
> >
> >
> >
> >
> >
> > On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:
> > > I am having trouble with this line of the tutorial: "You need to
> > > register a handler for the signal django.db.models.signals.post_save
> > > on the User model, and, in the handler, if created=True, create the
> > > associated user profile."
> >
> > > It seems I need to edit the User model. I am confused, though, because
> > > I am using the User model included in django.contrib, and I am very
> > > hesitant to edit files that are not in my project directory.
> >
> > > Is this bad design to be using a mix of things I've written on my own,
> > > and things that were already included in Django? (i.e. should I write
> > > everything from scratch?)
> >
> > > Thanks.
> >
> > > On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > > > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > > > How do I use a foreign key, though? In other words, how do I tell
> my
> > > > > code to look at UserProfile rather than just user?
> >
> > > >
> https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
> >
> > > > --
> > > > Michał (Saviq) Sawicz 
> >
> > > >  signature.asc
> > > > < 1KViewDownload
> >
> > > --
> > > 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.
>
>

-- 
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: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
All you have to do is add the following code to your models.py (or any other
module that gets loaded by django, for that matter):

# models.py
from django.db.models import signals

def create_user_profile(sender, instance, created, **kwargs):
 if created:
UserProfile.objects.create(user=instance)

signals.post_save.connect(create_user_profile, sender=User)

(assuming your profile model is called UserProfile, of course).

When django loads models.py, it will call that connect() method which in
turn makes create_user_profile get called every time the sender model (User)
is saved (hence the 'post_save').

More on this at https://docs.djangoproject.com/en/dev/ref/signals/


Cheers,
André Terra

On Mon, Jul 11, 2011 at 2:09 PM, Brent  wrote:

> I am having trouble with this line of the tutorial: "You need to
> register a handler for the signal django.db.models.signals.post_save
> on the User model, and, in the handler, if created=True, create the
> associated user profile."
>
> It seems I need to edit the User model. I am confused, though, because
> I am using the User model included in django.contrib, and I am very
> hesitant to edit files that are not in my project directory.
>
> Is this bad design to be using a mix of things I've written on my own,
> and things that were already included in Django? (i.e. should I write
> everything from scratch?)
>
> Thanks.
>
> On Jul 11, 9:54 am, Michał Sawicz  wrote:
> > Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> >
> > > How do I use a foreign key, though? In other words, how do I tell my
> > > code to look at UserProfile rather than just user?
> >
> > https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
> >
> > --
> > Michał (Saviq) Sawicz 
> >
> >  signature.asc
> > < 1KViewDownload
>
> --
> 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: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
I am having trouble with this line of the tutorial: "You need to
register a handler for the signal django.db.models.signals.post_save
on the User model, and, in the handler, if created=True, create the
associated user profile."

It seems I need to edit the User model. I am confused, though, because
I am using the User model included in django.contrib, and I am very
hesitant to edit files that are not in my project directory.

Is this bad design to be using a mix of things I've written on my own,
and things that were already included in Django? (i.e. should I write
everything from scratch?)

Thanks.

On Jul 11, 9:54 am, Michał Sawicz  wrote:
> Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
>
> > How do I use a foreign key, though? In other words, how do I tell my
> > code to look at UserProfile rather than just user?
>
> https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional...
>
> --
> Michał (Saviq) Sawicz 
>
>  signature.asc
> < 1KViewDownload

-- 
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: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Andre Terra
Wherever you would reference a user instance, reference UserProfile.user
instead

If you need to find out a profile from request.user, you can use
request.user.get_profile() or the longer UserProfile.objects.get(user_id=
request.user.id)


Cheers,
André

On Mon, Jul 11, 2011 at 1:48 PM, Brent  wrote:

> Thanks for the responses.
>
> How do I use a foreign key, though? In other words, how do I tell my
> code to look at UserProfile rather than just user?
>
> On Jul 10, 5:08 am, Jonas Geiregat  wrote:
> > Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven:
> >
> >
> >
> > > This is not good design. If you want to store some extra fields for a
> User - i would define just another model called ProfileDetails, FK it to
> User and use it as such.
> >
> > That's also how I would do it, some example code to make it even more
> clear:
> >
> > from django.db import models
> > from django.contrib.auth.models import User
> >
> > class UserProfile(models.Model):
> > user = models.ForeignKey(User, unique=True)
> > url = models.URLField("Website", blank=True)
> > company = models.CharField(max_length=50, blank=True)
>
> --
> 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: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Michał Sawicz
Dnia 2011-07-11, pon o godzinie 09:48 -0700, Brent pisze:
> How do I use a foreign key, though? In other words, how do I tell my
> code to look at UserProfile rather than just user? 

https://docs.djangoproject.com/en/1.3/topics/auth/#storing-additional-information-about-users

-- 
Michał (Saviq) Sawicz 


signature.asc
Description: This is a digitally signed message part


Re: Extending User model with Inheritance - Attribute Error

2011-07-11 Thread Brent
Thanks for the responses.

How do I use a foreign key, though? In other words, how do I tell my
code to look at UserProfile rather than just user?

On Jul 10, 5:08 am, Jonas Geiregat  wrote:
> Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven:
>
>
>
> > This is not good design. If you want to store some extra fields for a User 
> > - i would define just another model called ProfileDetails, FK it to User 
> > and use it as such.
>
> That's also how I would do it, some example code to make it even more clear:
>
> from django.db import models
> from django.contrib.auth.models import User
>
> class UserProfile(models.Model):
>     user = models.ForeignKey(User, unique=True)
>     url = models.URLField("Website", blank=True)
>     company = models.CharField(max_length=50, blank=True)

-- 
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: Extending User model with Inheritance - Attribute Error

2011-07-10 Thread Jonas Geiregat

Op 10-jul-2011, om 12:37 heeft Venkatraman S het volgende geschreven:

> 
> This is not good design. If you want to store some extra fields for a User - 
> i would define just another model called ProfileDetails, FK it to User and 
> use it as such.

That's also how I would do it, some example code to make it even more clear:

from django.db import models
from django.contrib.auth.models import User

class UserProfile(models.Model):
user = models.ForeignKey(User, unique=True)
url = models.URLField("Website", blank=True)
company = models.CharField(max_length=50, blank=True)

-- 
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: Extending User model with Inheritance - Attribute Error

2011-07-10 Thread Venkatraman S
On Sun, Jul 10, 2011 at 1:05 PM, Brent  wrote:

> Hi all,
>
> I am attempting to follow this tutorial:
>
> http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/
>
> But I am receiving this error:
> AttributeError at /login/
> 'NoneType' object has no attribute 'DoesNotExist'
>
> Here is my stack trace:
> http://dpaste.com/565795/
>
> I tried changing the CUSTOM_USER_MODEL field to every permutation of
> paths that could possibly lead to my CustomUser class, but they all
> gave the same error.
>


This is not good design. If you want to store some extra fields for a User -
i would define just another model called ProfileDetails, FK it to User and
use it as such.

Btw, i somehow never liked model-subclassing; but i come from a rdbms
background.

-V

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



Extending User model with Inheritance - Attribute Error

2011-07-10 Thread Brent
Hi all,

I am attempting to follow this tutorial:
http://scottbarnham.com/blog/2008/08/21/extending-the-django-user-model-with-inheritance/

But I am receiving this error:
AttributeError at /login/
'NoneType' object has no attribute 'DoesNotExist'

Here is my stack trace:
http://dpaste.com/565795/

I tried changing the CUSTOM_USER_MODEL field to every permutation of
paths that could possibly lead to my CustomUser class, but they all
gave the same error.

Thanks in advance.

-- 
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: Attribute error

2011-05-01 Thread DJ Ango
Capitalize class names.

class Wish(models.Model):
 the_wish = models.CharField(max_length=100)

On Apr 30, 4:26 pm, Pulkit Mehrotra  wrote:
> changed the name but nothing happened
> the django version is 1.3

-- 
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: Attribute error

2011-04-30 Thread Pulkit Mehrotra
changed the name but nothing happened 
the django version is 1.3

-- 
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: Attribute error

2011-04-30 Thread Karen Tracey
On Sat, Apr 30, 2011 at 3:45 PM, Pulkit Mehrotra
wrote:

> 'module' object has no attribute 'CharField'
>
> What does this error means ???
>
> View for this is:
> from django.shortcuts import render_to_response
> from django.http import HttpResponseRedirect,HttpResponse
> from wishlist.models import wish
> from wishlist.forms import wish
>
>
Somebody else tried to point this out on your previous question, but you
apparently didn't see that answer, or didn't understand it? As long as you
have two different things you are trying to call by the same name, you are
going to get odd errors like this. Change the name of one of your wishes to
something else: you cannot call both the model and the form "wish". And if
you've done the same sort of thing elsewhere, undo it as well. The error
message rather sounds like you've done something similar with re-binding the
name 'models' or 'forms' to your own thing rather than django.db.models and
django.forms.

Karen
-- 
http://tracey.org/kmt/

-- 
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: Attribute error

2011-04-30 Thread Yongning Liang
class wish(models.Model):
wish=models.CharField(max_length=200)


what's your django version


On Sun, May 1, 2011 at 3:45 AM, Pulkit Mehrotra
wrote:

> AttributeError at /mysite/wishlist/
>
> 'module' object has no attribute 'CharField'
>
> What does this error means ???
>
> View for this is:
> from django.shortcuts import render_to_response
> from django.http import HttpResponseRedirect,HttpResponse
> from wishlist.models import wish
> from wishlist.forms import wish
>
> def wishlist(request):
>   wish_list=wish.objects.all()
>   return render_to_response(
>   'wishlist/wishlist.html',
>   {'list':wish_list}
>   )
>
> def wish_form(request):   
>   return render_to_response('wishlist/wish_form.html', {'form': form, })
>
> def search(request):
> if 'q' in request.GET:
> message = 'You searched for: %r' % request.GET['q']
> else:
> message = 'You submitted an empty form.'
> return HttpResponse(message)
>
> The models.py for this is:
> from django.db import models
>
> class wish(models.Model):
>   wish=models.CharField(max_length=200)
>   wish_date=models.DateTimeField('date published')
>
> the urls.py for this is:
> from django.conf.urls.defaults import patterns, include, url
> from mysite.wishlist import views
>
> # Uncomment the next two lines to enable the admin:
> # from django.contrib import admin
> # admin.autodiscover()
>
> urlpatterns = patterns('',
>   (r'^mysite/wishlist/$','wishlist.views.wishlist'),
>   (r'^mysite/wish/$','wishlist.views.wish_form'),
>   (r'^mysite/wishsearch/$','wishlist.views.search'),  
>   # Examples:
> # url(r'^$', 'mysite.views.home', name='home'),
> # url(r'^mysite/', include('mysite.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.
>

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



Attribute error

2011-04-30 Thread Pulkit Mehrotra
AttributeError at /mysite/wishlist/ 

'module' object has no attribute 'CharField'

What does this error means ???

View for this is:
from django.shortcuts import render_to_response
from django.http import HttpResponseRedirect,HttpResponse
from wishlist.models import wish
from wishlist.forms import wish

def wishlist(request):
wish_list=wish.objects.all()
return render_to_response(
'wishlist/wishlist.html',
{'list':wish_list}
)

def wish_form(request): 
return render_to_response('wishlist/wish_form.html', {'form': form, })

def search(request):
if 'q' in request.GET:
message = 'You searched for: %r' % request.GET['q']
else:
message = 'You submitted an empty form.'
return HttpResponse(message)

The models.py for this is:
from django.db import models

class wish(models.Model):
wish=models.CharField(max_length=200)
wish_date=models.DateTimeField('date published')

the urls.py for this is:
from django.conf.urls.defaults import patterns, include, url
from mysite.wishlist import views

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

urlpatterns = patterns('',
(r'^mysite/wishlist/$','wishlist.views.wishlist'),
(r'^mysite/wish/$','wishlist.views.wish_form'),
(r'^mysite/wishsearch/$','wishlist.views.search'),  
# Examples:
# url(r'^$', 'mysite.views.home', name='home'),
# url(r'^mysite/', include('mysite.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.



Generic List View raises Attribute Error: "'function' object has no attribute '_clone'

2011-03-29 Thread dpapathanasiou
I've written a simple search function that uses a db model based on
the one described in The Django Book tutorial (http://
www.djangobook.com/en/2.0/), using a generic list, and a Paginator.

Here is my view function:

def search (request):
"""Search by title or author name"""

if 'q' in request.POST and request.POST['q']:

query_term = request.POST['q']
context = { }

book_list =
Book.objects.filter(Q(authors__name__contains=query_term) |
Q(title__contains=query_term))
if len(book_list) == 0:
context['message'] = 'No matches found'
book_list = Book.objects.all() #
Book.objects.filter(Q(available=True)) also works

paginator = Paginator(book_list, 10) # Show 10 books per page

try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1

try:
books = paginator.page(page)
except (EmptyPage, InvalidPage):
books = paginator.page(paginator.num_pages)

shopping_cart_count = 0
if "cart" in request.session:
   shopping_cart_count = len(request.session['cart'])
context['shopping_cart'] = shopping_cart_count

return list_detail.object_list(request, queryset=books,
template_name='book_list.html', extra_context=context)

When there no matches for the query_term are found, the book_list is
simply Book.objects.all(), and the template is rendered correctly.

When, however, the query_term matches, I get this error:

Attribute Error: "'function' object has no attribute '_clone'

Supposedly, this is because the filtering does not produce a proper
QuerySet, which in turn, cannot be cloned by the generic view.

If, however, I change the no matches QuerySet from Book.objects.all()
to Book.objects.filter(Q(available=True)), the generic view works.

Both of the solutions I found suggest creating a new class which
builds a proper QuerySet from multiple filter lists (http://
djangosnippets.org/snippets/1103/ and
http://stackoverflow.com/questions/431628/how-to-combine-2-or-more-querysets-in-a-django-view/432666#432666),
but even using those gave me the same result.

I also tried removing the Q(authors__name__contains=query_term) filter
on Book, since authors is a ManyToMany relation, but that gave me the
same result as well.

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: ATTRIBUTE ERROR

2010-11-02 Thread Tom Evans
On Tue, Nov 2, 2010 at 11:08 AM, sami nathan  wrote:
> If i am doing anything wrong forgive me i am newbe
>
>
> MY error is
> Exception Type:         AttributeError
> Exception Value:
>
> 'str' object has no attribute 'resolve'
>
> Exception Location:
>        D:\Python25\lib\site-packages\django\core\urlresolvers.py in resolve,
> line 25
>
>
> My url.py  look like this
> from django.conf.urls.defaults import *
> from it.view import current_datetime
>
> # Uncomment the next two lines to enable the admin:
> from django.contrib import admin
> admin.autodiscover()
>
> urlpatterns = patterns('',
>    # Example:
>     (r'^wap/di/sub/$",current_datetime')

This line is wrong ^^^

Quote your strings correctly and you won't get this error.

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



ATTRIBUTE ERROR

2010-11-02 Thread sami nathan
If i am doing anything wrong forgive me i am newbe


MY error is
Exception Type: AttributeError
Exception Value:

'str' object has no attribute 'resolve'

Exception Location:
D:\Python25\lib\site-packages\django\core\urlresolvers.py in resolve,
line 25


My url.py  look like this
from django.conf.urls.defaults import *
from it.view import current_datetime

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

urlpatterns = patterns('',
# Example:
 (r'^wap/di/sub/$",current_datetime')

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

# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls)),
)
~~~
My view.py looks like this
from django.http import *
import urllib

def current_datetime(request):
word = request.GET['word']
message = 
urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'=00submit=Submit',)
return HttpResponse (message)
~~
Thank u for notification

-- 
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: ATTRIBUTE ERROR

2010-10-28 Thread yu xue
Hi, I feel there are some places which need to modify:
1. urlpatterns should be  (r"^wap/di/sub/$", current_datetime),
2. It seems that the view function is endless loop...


2010/10/28 sami nathan 

> My occured Error is
>
> Exception Value:
>
> 'str' object has no attribute 'resolve'
>
> Exception Location:
>C:\Python25\Lib\site-packages\django\core\urlresolvers.py in
> resolve,
> line 217
>
> ~
> MY URLS.PY LOOKS LIKE THIS
> from django.conf.urls.defaults import *
> from flip.view import current_datetime
>
> urlpatterns = ('',
># Example:
>
>   (r"^wap/di/sub",current_datetime)
>
> )
># Uncomment the admin/doc line below to enable admin documentation:
># (r'^admin/doc/', include('django.contrib.admindocs.urls')),
># Uncomment the next line to enable the admin:
># (r'^admin/', include(admin.site.urls))
> My view .py Looks like this
> from django.http import *
> import urllib
>
> def current_datetime(request):
>word = request.GET['word']
>message = urllib.urlopen('
> http://m.broov.com/wap/di/sub?word='+word+'=00submit=Submit
> ',)
>return HttpResponse (message)
>
> Please help me i dont na what happens it was running succesfully but
> noow its not
>
> --
> 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.
>
>


-- 
 此致
敬礼!
   薛宇

   身前身后
   是时间的深渊

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



ATTRIBUTE ERROR

2010-10-28 Thread sami nathan
My occured Error is

Exception Value:

'str' object has no attribute 'resolve'

Exception Location:
C:\Python25\Lib\site-packages\django\core\urlresolvers.py in resolve,
line 217
~
MY URLS.PY LOOKS LIKE THIS
from django.conf.urls.defaults import *
from flip.view import current_datetime

urlpatterns = ('',
# Example:

   (r"^wap/di/sub",current_datetime)

)
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
# (r'^admin/', include(admin.site.urls))
My view .py Looks like this
from django.http import *
import urllib

def current_datetime(request):
word = request.GET['word']
message = 
urllib.urlopen('http://m.broov.com/wap/di/sub?word='+word+'=00submit=Submit',)
return HttpResponse (message)

Please help me i dont na what happens it was running succesfully but
noow its not

-- 
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: Confused by attribute error

2009-03-30 Thread Robocop

Bingo!  Looks like i was lazy with my code and threw decorators on ALL
the functions, not just my views.  There was a lingering decorator on
the send_file function that i did not notice.  Thanks for pointing out
my sloppines;)  You saved me a ton of time today, double thanks!
On Mar 30, 12:02 pm, Karen Tracey  wrote:
> On Mon, Mar 30, 2009 at 2:23 PM, Robocop  wrote:
>
> > So the fun continues.  I realized that i did not need to use the
> > login_required decorator on this function since it's just tossed
> > around in the backend, so i took that out thinking it would prevent
> > decorators.py from being called.
>
> Did you take it out before even posting the code for timesheet_export?
> Because there is no evidence of that function being decorated with
> login_required in what you posted, which is a bit puzzling.
>
> > When i hit the function above now,
> > it posts the same error with a different request (can be viewed here
> >http://dpaste.com/21238/).  The string object it's having trouble
> > with is this:
> > '/home/mipscomp/public_html/support/helpdesk/exported/03_30_09.txt
>
> > I'm pretty confused at this point, as i've never seen this error
> > before.  And the last time i recall working with this code, it worked
> > flawlessly.  Ridicule and ideas are greatly appreciated.
>
> The traceback is not so big it can't be posted:
>
> Traceback:
> File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py"
> in get_response
>     86. response = callback(request, *callback_args, **callback_kwargs)
> File
> "/usr/local/lib/python2.4/site-packages/django/contrib/auth/decorators.py"
> in __call__
>     67. return self.view_func(request, *args, **kwargs)
> File "/home/mipscomp/public_html/support/helpdesk/projects/views.py" in
> audit_sheets_test
>     580. response = send_file(path,None, None)
> File
> "/usr/local/lib/python2.4/site-packages/django/contrib/auth/decorators.py"
> in __call__
>     66. if self.test_func(request.user):
>
> Exception Type: AttributeError at /audit_sheets/TEST/
> Exception Value: 'str' object has no attribute 'user'
>
> So, your code appears to be thinking it's calling a function called
> "send_file" and passing in a path argument (likely the string object you
> list above, as that quite looks like a path) but instead it jumps into
> decorator code.  And the decorator code, instead of getting the request
> object it expects as its first arg, get this path string, and dies a
> horrible death trying to treat a string as a request object.
>
> So it looks like another case of improper decoration. You cannot just
> decorate arbitrary functions with @login_requried -- it expects to be used
> specifically with view functions, that always get request as their first
> argument. If you decorate some other function that doesn't take a request as
> a first argument, you get errors like what you are reporting.
>
> 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: Confused by attribute error

2009-03-30 Thread Karen Tracey
On Mon, Mar 30, 2009 at 2:23 PM, Robocop  wrote:

>
> So the fun continues.  I realized that i did not need to use the
> login_required decorator on this function since it's just tossed
> around in the backend, so i took that out thinking it would prevent
> decorators.py from being called.


Did you take it out before even posting the code for timesheet_export?
Because there is no evidence of that function being decorated with
login_required in what you posted, which is a bit puzzling.


> When i hit the function above now,
> it posts the same error with a different request (can be viewed here
> http://dpaste.com/21238/ ).  The string object it's having trouble
> with is this:
> '/home/mipscomp/public_html/support/helpdesk/exported/03_30_09.txt
>
> I'm pretty confused at this point, as i've never seen this error
> before.  And the last time i recall working with this code, it worked
> flawlessly.  Ridicule and ideas are greatly appreciated.
>

The traceback is not so big it can't be posted:

Traceback:
File "/usr/local/lib/python2.4/site-packages/django/core/handlers/base.py"
in get_response
86. response = callback(request, *callback_args, **callback_kwargs)
File
"/usr/local/lib/python2.4/site-packages/django/contrib/auth/decorators.py"
in __call__
67. return self.view_func(request, *args, **kwargs)
File "/home/mipscomp/public_html/support/helpdesk/projects/views.py" in
audit_sheets_test
580. response = send_file(path,None, None)
File
"/usr/local/lib/python2.4/site-packages/django/contrib/auth/decorators.py"
in __call__
66. if self.test_func(request.user):

Exception Type: AttributeError at /audit_sheets/TEST/
Exception Value: 'str' object has no attribute 'user'

So, your code appears to be thinking it's calling a function called
"send_file" and passing in a path argument (likely the string object you
list above, as that quite looks like a path) but instead it jumps into
decorator code.  And the decorator code, instead of getting the request
object it expects as its first arg, get this path string, and dies a
horrible death trying to treat a string as a request object.

So it looks like another case of improper decoration. You cannot just
decorate arbitrary functions with @login_requried -- it expects to be used
specifically with view functions, that always get request as their first
argument. If you decorate some other function that doesn't take a request as
a first argument, you get errors like what you are reporting.

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: Confused by attribute error

2009-03-30 Thread Robocop

So the fun continues.  I realized that i did not need to use the
login_required decorator on this function since it's just tossed
around in the backend, so i took that out thinking it would prevent
decorators.py from being called.  When i hit the function above now,
it posts the same error with a different request (can be viewed here
http://dpaste.com/21238/ ).  The string object it's having trouble
with is this:
'/home/mipscomp/public_html/support/helpdesk/exported/03_30_09.txt

I'm pretty confused at this point, as i've never seen this error
before.  And the last time i recall working with this code, it worked
flawlessly.  Ridicule and ideas are greatly appreciated.

On Mar 30, 10:33 am, Robocop  wrote:
> Sorry for the delay, i've been sidetracked multiple times in the last
> few days.  The code is post here:
>
> http://dpaste.com/21221/
--~--~-~--~~~---~--~~
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: Confused by attribute error

2009-03-30 Thread Robocop

Sorry for the delay, i've been sidetracked multiple times in the last
few days.  The code is post here:

http://dpaste.com/21221/

--~--~-~--~~~---~--~~
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: Confused by attribute error

2009-03-27 Thread Robocop


Also i don't comment until i put my code into production (bad habit,
yes i know :x), so let me know if you need me to throw in some dirty
comments to make it more readable.
On Mar 27, 3:21 pm, Robocop  wrote:
> On Mar 27, 3:05 pm, Briel  wrote:
>
> > Hi.
> > It would be really helpful to be able to look at your function as
> > well. My
> > Guess is that the problem lies there, since this is happening when you
> > call the function. Even if the problem is within django it would be a
> > lot
> > easier to find when looking through your function to see what it does.
> > Also please post it at dphaste or some other simelar website.
>
> > ~Jakob
>
> I've avoided posting the function just because it's a little long to
> read, and doesn't do anything particularly interesting,  but here you
> go (thanks for the help by the way):
>
> def timesheet_export(timesheets,date):
>   labor={'network_software_service':'NETSFT',
> 'emergency_night':'EMERGN ','emergency_weekend':'EMERG
> ','drop_off_at_mips':'DRPMIPS','consulting_block':'CNSLTNG','delivery':'DELIVERY'}
>   year, month, day =date.strftime("%Y-%M-%d").split("-")
>   path = "/home/mipscomp/public_html/support/helpdesk/
> exported/"+date.strftime("%m_%d_%y")+".txt"
>   output = open(path, "w")
>   counter_list=0
>   timesheets.sort(key= lambda i:(i.department, i.engagement, i.date,
> i.start))
>   for timesheet in timesheets:
>     pad50 = lambda s: s.ljust(50)
>     if counter_list==0:
>       department_name=timesheet.department
>       department=Department.objects.get(name=department_name)
>       dep_code=department.code
>       length=len(dep_code)
>       cust_num='0'*(7-length)+dep_code
>       header_line_raw=date.strftime("%Y/%m/%d")+"\",\""+cust_num
>       progress_line_raw="Progress Billing - "+timesheet.date.strftime
> ("%B, %Y")
>       progress_line=pad50(progress_line_raw)
>       if timesheet.engagement=='':
>         engagment_line_raw="NO SPECIFIC ENGAGEMENT"
>       else:
>         engagement_line_raw=timesheet.engagement.upper() + "
> ENGAGEMENT"
>       try:
>         engagement_line=pad50(engagement_line_raw)
>       except UnboundLocalError:
>         engagement_line_raw="NO SPECIFIC ENGAGEMENT"
>         engagement_line=pad50(engagement_line_raw)
>       output.write("H,\""+header_line_raw+"\"\n")
>       output.write("C,\"C      \",\""+progress_line+"\"\n")
>       output.write("C,\"C      \",\""+engagement_line+"\"\n")
>     else:
>       if timesheet.engagement!=timesheets[counter_list-1].engagement:
>         department_name=timesheet.department
>         department=Department.objects.get(name=department_name)
>         dep_code=department.code
>         length=len(dep_code)
>         cust_num='0'*(7-length)+dep_code
>         header_line_raw=date.strftime("%Y/%m/%d")+"\",\""+cust_num
>         progress_line_raw="Progress Billing - "+timesheet.date.strftime
> ("%B, %Y")
>         progress_line=pad50(progress_line_raw)
>         if timesheet.engagement=='':
>           engagment_line_raw="NO SPECIFIC ENGAGEMENT"
>         else:
>           engagement_line_raw=timesheet.engagement.upper() + "
> ENGAGEMENT"
>         try:
>           engagement_line=pad50(engagement_line_raw)
>         except UnboundLocalError:
>           engagement_line_raw="NO SPECIFIC ENGAGEMENT"
>           engagement_line=pad50(engagement_line_raw)
>         output.write("H,\""+header_line_raw+"\"\n")
>         output.write("C,\"C      \",\""+progress_line+"\"\n")
>         output.write("C,\"C      \",\""+engagement_line+"\"\n")
>     if timesheet.technician != 'No Specific Tech':  #This section
> writes the technician and hours line
>       first, last= timesheet.technician.split(' ')
>       if first=="Danielle" and last=="St. Romain":
>         title="No Specific Title"
>       else:
>         tech=User.objects.get(Q(first_name=first) & Q(last_name=last))
>         userprof_id=(tech.id + 1)
>         userprof=UserProfile.objects.get(id=userprof_id)
>         if userprof.title=='':
>           title="No Specific Title"
>         else:
>           title=userprof.title
>     if timesheet.technician == 'No Specific Tech':
>       title='No Specific Title'
>       tech_hours_raw=title+": "+timesheet.technician+",
> "+timesheet.date.strftime("%m/%d/%y")+", "+ str(timesheet.billtime) +"
> hrs."
>     else:
>       tech_hours_raw=title+": "+first+" "+last+",
> "+timesheet.date.strftime("%m/%d/%y")+", "+ str(timesheet.billtime) +"
> hrs."
>     tech_hours_line=pad50(tech_hours_raw)
>     output.write("S, [Timesheet data for timesheet #"+str(timesheet.id)
> +"]\n")
>     billtime_raw=str(timesheet.billtime)
>     blength=len(billtime_raw)
>     billtime='0'*(8-blength)+billtime_raw
>     if len(str(timesheet.labor_code))>7:
>       labor_code_raw=str(labor[timesheet.labor_code])
>     else:
>       labor_code_raw=str(timesheet.labor_code)
>     llength=len(labor_code_raw)
>     labor_code=labor_code_raw+' '*(7-llength)
>   

Re: Confused by attribute error

2009-03-27 Thread Robocop



On Mar 27, 3:05 pm, Briel  wrote:
> Hi.
> It would be really helpful to be able to look at your function as
> well. My
> Guess is that the problem lies there, since this is happening when you
> call the function. Even if the problem is within django it would be a
> lot
> easier to find when looking through your function to see what it does.
> Also please post it at dphaste or some other simelar website.
>
> ~Jakob
>

I've avoided posting the function just because it's a little long to
read, and doesn't do anything particularly interesting,  but here you
go (thanks for the help by the way):

def timesheet_export(timesheets,date):
  labor={'network_software_service':'NETSFT',
'emergency_night':'EMERGN ','emergency_weekend':'EMERG
','drop_off_at_mips':'DRPMIPS','consulting_block':'CNSLTNG','delivery':'DELIVERY'}
  year, month, day =date.strftime("%Y-%M-%d").split("-")
  path = "/home/mipscomp/public_html/support/helpdesk/
exported/"+date.strftime("%m_%d_%y")+".txt"
  output = open(path, "w")
  counter_list=0
  timesheets.sort(key= lambda i:(i.department, i.engagement, i.date,
i.start))
  for timesheet in timesheets:
pad50 = lambda s: s.ljust(50)
if counter_list==0:
  department_name=timesheet.department
  department=Department.objects.get(name=department_name)
  dep_code=department.code
  length=len(dep_code)
  cust_num='0'*(7-length)+dep_code
  header_line_raw=date.strftime("%Y/%m/%d")+"\",\""+cust_num
  progress_line_raw="Progress Billing - "+timesheet.date.strftime
("%B, %Y")
  progress_line=pad50(progress_line_raw)
  if timesheet.engagement=='':
engagment_line_raw="NO SPECIFIC ENGAGEMENT"
  else:
engagement_line_raw=timesheet.engagement.upper() + "
ENGAGEMENT"
  try:
engagement_line=pad50(engagement_line_raw)
  except UnboundLocalError:
engagement_line_raw="NO SPECIFIC ENGAGEMENT"
engagement_line=pad50(engagement_line_raw)
  output.write("H,\""+header_line_raw+"\"\n")
  output.write("C,\"C  \",\""+progress_line+"\"\n")
  output.write("C,\"C  \",\""+engagement_line+"\"\n")
else:
  if timesheet.engagement!=timesheets[counter_list-1].engagement:
department_name=timesheet.department
department=Department.objects.get(name=department_name)
dep_code=department.code
length=len(dep_code)
cust_num='0'*(7-length)+dep_code
header_line_raw=date.strftime("%Y/%m/%d")+"\",\""+cust_num
progress_line_raw="Progress Billing - "+timesheet.date.strftime
("%B, %Y")
progress_line=pad50(progress_line_raw)
if timesheet.engagement=='':
  engagment_line_raw="NO SPECIFIC ENGAGEMENT"
else:
  engagement_line_raw=timesheet.engagement.upper() + "
ENGAGEMENT"
try:
  engagement_line=pad50(engagement_line_raw)
except UnboundLocalError:
  engagement_line_raw="NO SPECIFIC ENGAGEMENT"
  engagement_line=pad50(engagement_line_raw)
output.write("H,\""+header_line_raw+"\"\n")
output.write("C,\"C  \",\""+progress_line+"\"\n")
output.write("C,\"C  \",\""+engagement_line+"\"\n")
if timesheet.technician != 'No Specific Tech':  #This section
writes the technician and hours line
  first, last= timesheet.technician.split(' ')
  if first=="Danielle" and last=="St. Romain":
title="No Specific Title"
  else:
tech=User.objects.get(Q(first_name=first) & Q(last_name=last))
userprof_id=(tech.id + 1)
userprof=UserProfile.objects.get(id=userprof_id)
if userprof.title=='':
  title="No Specific Title"
else:
  title=userprof.title
if timesheet.technician == 'No Specific Tech':
  title='No Specific Title'
  tech_hours_raw=title+": "+timesheet.technician+",
"+timesheet.date.strftime("%m/%d/%y")+", "+ str(timesheet.billtime) +"
hrs."
else:
  tech_hours_raw=title+": "+first+" "+last+",
"+timesheet.date.strftime("%m/%d/%y")+", "+ str(timesheet.billtime) +"
hrs."
tech_hours_line=pad50(tech_hours_raw)
output.write("S, [Timesheet data for timesheet #"+str(timesheet.id)
+"]\n")
billtime_raw=str(timesheet.billtime)
blength=len(billtime_raw)
billtime='0'*(8-blength)+billtime_raw
if len(str(timesheet.labor_code))>7:
  labor_code_raw=str(labor[timesheet.labor_code])
else:
  labor_code_raw=str(timesheet.labor_code)
llength=len(labor_code_raw)
labor_code=labor_code_raw+' '*(7-llength)
billtime_line=labor_code+"\",\""+billtime
output.write("M,\""+billtime_line+"\"\n")
lines=[]
pre_parse = ''
pre_parse = str(timesheet.description)
if len(pre_parse)<50:
  string=pad50(pre_parse)
  lines.append(string)
  lines.append(50*' ')
else:
  lines = (map(pad50,textwrap.wrap(pre_parse,50)))
counter=0
for line in lines:
  if counter % 2 == 0:
try:
  if lines[counter+1]:

Re: Confused by attribute error

2009-03-27 Thread Briel

Hi.
It would be really helpful to be able to look at your function as
well. My
Guess is that the problem lies there, since this is happening when you
call the function. Even if the problem is within django it would be a
lot
easier to find when looking through your function to see what it does.
Also please post it at dphaste or some other simelar website.

~Jakob

On 27 Mar., 22:52, Robocop  wrote:
> Hello again,
> So i'm working on some of my old code, and a previously (or so i
> remember) function no longer works.  When calling it my django page
> posts the error:
>
> AttributeError at /audit_sheets/TEST/
>
> 'list' object has no attribute 'user'
> Request Method:         POST
> Request URL:    http://support.mipscomputation.com/audit_sheets/TEST/
> Exception Type:         AttributeError
> Exception Value:
>
> 'list' object has no attribute 'user'
>
> Exception Location:     /usr/local/lib/python2.4/site-packages/django/
> contrib/auth/decorators.py in __call__, line 66
> Python Executable:      /usr/local/bin/python
> Python Version:         2.4.3
> Python Path:    ['/home/mipscomp/public_html/support', '/home/mipscomp/
> public_html/support', '/usr/local/lib/python2.4/site-packages/
> MySQL_python-1.2.2-py2.4-linux-i686.egg', '/usr/local/lib/python2.4/
> site-packages/flup-1.0.1-py2.4.egg', '/usr/local/lib/python2.4/site-
> packages/python_memcached-1.43-py2.4.egg', '/usr/local/lib/python2.4/
> site-packages/pycrypto-2.0.1-py2.4-linux-i686.egg', '/usr/local/lib/
> python2.4/site-packages/Reportlab-2.1.0001-py2.5.egg', '/usr/local/lib/
> python2.4/site-packages/django_registration-0.7-py2.4.egg', '/usr/
> local/lib/python2.4/site-packages/elementtree-1.2.7_20070827_preview-
> py2.4.egg', '/usr/local/lib/python2.4/site-packages/docutils-0.5-
> py2.4.egg', '/usr/local/lib/python2.4/site-packages/setuptools-0.6c9-
> py2.4.egg', '/usr/local/lib/python24.zip', '/usr/local/lib/python2.4',
> '/usr/local/lib/python2.4/plat-linux2', '/usr/local/lib/python2.4/lib-
> tk', '/usr/local/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/
> site-packages', '/usr/local/lib/python2.4/site-packages/PIL']
> Server time:    Fri, 27 Mar 2009 16:46:47 -0500
>
> The line in question is:
>
> #  timesheet_export(timesheets,date)
>
> where timesheet_export is my special lil function, and timesheets is a
> list of objects.  Now the error seems to directly come from this:
>
> /usr/local/lib/python2.4/site-packages/django/contrib/auth/
> decorators.py in __call__
>
>   59. update_wrapper(self, view_func)
>   60.
>   61. def __get__(self, obj, cls=None):
>   62. view_func = self.view_func.__get__(obj, cls)
>   63. return _CheckLogin(view_func, self.test_func, self.login_url,
> self.redirect_field_name)
>   64.
>   65. def __call__(self, request, *args, **kwargs):
>
>   66. if self.test_func(request.user): ...
>
>   67. return self.view_func(request, *args, **kwargs)
>   68. path = urlquote(request.get_full_path())
>   69. tup = self.login_url, self.redirect_field_name, path
>   70. return HttpResponseRedirect('%s?%s=%s' % tup)
>
> And right now i'm not sure what the decorators.py file is trying to do
> with regards to my function.  Considering i've never explored the
> inner workings of decorators.py, i'm not sure exactly what it's doing
> in this instance.  All i know is it's looking for user attributes in a
> list of totally unrelated objects.  Any thoughts or ridicule are
> always appreciated!
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Confused by attribute error

2009-03-27 Thread Robocop

Hello again,
So i'm working on some of my old code, and a previously (or so i
remember) function no longer works.  When calling it my django page
posts the error:

AttributeError at /audit_sheets/TEST/

'list' object has no attribute 'user'
Request Method: POST
Request URL:http://support.mipscomputation.com/audit_sheets/TEST/
Exception Type: AttributeError
Exception Value:

'list' object has no attribute 'user'

Exception Location: /usr/local/lib/python2.4/site-packages/django/
contrib/auth/decorators.py in __call__, line 66
Python Executable:  /usr/local/bin/python
Python Version: 2.4.3
Python Path:['/home/mipscomp/public_html/support', '/home/mipscomp/
public_html/support', '/usr/local/lib/python2.4/site-packages/
MySQL_python-1.2.2-py2.4-linux-i686.egg', '/usr/local/lib/python2.4/
site-packages/flup-1.0.1-py2.4.egg', '/usr/local/lib/python2.4/site-
packages/python_memcached-1.43-py2.4.egg', '/usr/local/lib/python2.4/
site-packages/pycrypto-2.0.1-py2.4-linux-i686.egg', '/usr/local/lib/
python2.4/site-packages/Reportlab-2.1.0001-py2.5.egg', '/usr/local/lib/
python2.4/site-packages/django_registration-0.7-py2.4.egg', '/usr/
local/lib/python2.4/site-packages/elementtree-1.2.7_20070827_preview-
py2.4.egg', '/usr/local/lib/python2.4/site-packages/docutils-0.5-
py2.4.egg', '/usr/local/lib/python2.4/site-packages/setuptools-0.6c9-
py2.4.egg', '/usr/local/lib/python24.zip', '/usr/local/lib/python2.4',
'/usr/local/lib/python2.4/plat-linux2', '/usr/local/lib/python2.4/lib-
tk', '/usr/local/lib/python2.4/lib-dynload', '/usr/local/lib/python2.4/
site-packages', '/usr/local/lib/python2.4/site-packages/PIL']
Server time:Fri, 27 Mar 2009 16:46:47 -0500





The line in question is:

#  timesheet_export(timesheets,date)

where timesheet_export is my special lil function, and timesheets is a
list of objects.  Now the error seems to directly come from this:

/usr/local/lib/python2.4/site-packages/django/contrib/auth/
decorators.py in __call__

  59. update_wrapper(self, view_func)
  60.
  61. def __get__(self, obj, cls=None):
  62. view_func = self.view_func.__get__(obj, cls)
  63. return _CheckLogin(view_func, self.test_func, self.login_url,
self.redirect_field_name)
  64.
  65. def __call__(self, request, *args, **kwargs):

  66. if self.test_func(request.user): ...

  67. return self.view_func(request, *args, **kwargs)
  68. path = urlquote(request.get_full_path())
  69. tup = self.login_url, self.redirect_field_name, path
  70. return HttpResponseRedirect('%s?%s=%s' % tup)

And right now i'm not sure what the decorators.py file is trying to do
with regards to my function.  Considering i've never explored the
inner workings of decorators.py, i'm not sure exactly what it's doing
in this instance.  All i know is it's looking for user attributes in a
list of totally unrelated objects.  Any thoughts or ridicule are
always appreciated!




--~--~-~--~~~---~--~~
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: Attribute Error when doing a syncdb.

2008-10-25 Thread ஆமாச்சு

//I'm doing a little blog app and I'm going to be using tagging in it.
So I wen to the google code page and downloaded it, named it tagging
(instead of tagging-0.2.1), and then ran the install.//

Does the unzipped folder had a directory 'tagging' inside with the app
rests?

Please include that to the installed apps and check.

--
Amachu

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



Attribute Error when doing a syncdb.

2008-10-24 Thread Jared

Hello,

I'm doing a little blog app and I'm going to be using tagging in it.
So I wen to the google code page and downloaded it, named it tagging
(instead of tagging-0.2.1), and then ran the install. Once I did that
I made sure both my blog app and the tagging was included in the
installed apps. I then ran the syncdb command from my project folder
and get the following error:

AttributeError: 'module' object has no attribute 'tagging'


If you could point me in the right direction I would appreciate it.

Thanks,
Jared

--~--~-~--~~~---~--~~
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: 'module' object has no attribute 'TabularInLine' Attribute Error in Django 1

2008-09-25 Thread Elliot Tucker

Thanks for being dumb TeenSpirit83, i've just spent 30mins trying to
fix exactly the same typo...small world.

On Sep 11, 2:56 pm, TeenSpirit83 <[EMAIL PROTECTED]> wrote:
> > The L in Inline should not be capitalized.  Is it in some doc you are
> > working from?
>
> > Karen
>
> The docs are correct!
> I'm so dumb, it is the first time I notice the L is not capitalized!
> I was sure of the opposite!
> Thanks a lot 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'module' object has no attribute 'TabularInLine' Attribute Error in Django 1

2008-09-11 Thread TeenSpirit83

>
> The L in Inline should not be capitalized.  Is it in some doc you are
> working from?
>
> Karen

The docs are correct!
I'm so dumb, it is the first time I notice the L is not capitalized!
I was sure of the opposite!
Thanks a lot 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'module' object has no attribute 'TabularInLine' Attribute Error in Django 1

2008-09-11 Thread Karen Tracey
On Thu, Sep 11, 2008 at 9:29 AM, TeenSpirit83
<[EMAIL PROTECTED]>wrote:

>
> I'm trying to upgrade my skills from django 096 to 1.0 so I started a
> new app and tried to create an admin class for a class within its
> model.
> I got the error I specified in the subject. I paste down the
> traceback .Can you help me?
>
> [snipped debug info]


The L in Inline should not be capitalized.  Is it in some doc you are
working from?

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



'module' object has no attribute 'TabularInLine' Attribute Error in Django 1

2008-09-11 Thread TeenSpirit83

I'm trying to upgrade my skills from django 096 to 1.0 so I started a
new app and tried to create an admin class for a class within its
model.
I got the error I specified in the subject. I paste down the
traceback .Can you help me?

Environment:

Request Method: GET
Request URL: http://localhost:8000/admin/
Django Version: 1.0-final-SVN-unknown
Python Version: 2.5.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'django.contrib.admindocs',
 'retailcenter.publicsite']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.locale.LocaleMiddleware')


Traceback:
File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in
get_response
  77. request.path_info)
File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in
resolve
  178. for pattern in self.urlconf_module.urlpatterns:
File "C:\Python25\Lib\site-packages\django\core\urlresolvers.py" in
_get_urlconf_module
  197. self._urlconf_module =
__import__(self.urlconf_name, {}, {}, [''])
File "C:\Django-1.0\retailcenter\..\retailcenter\urls.py" in 
  5. admin.autodiscover()
File "C:\Python25\Lib\site-packages\django\contrib\admin\__init__.py"
in autodiscover
  40. __import__("%s.admin" % app)
File "C:\Django-1.0\retailcenter\publicsite\admin.py" in 
  22. class DocumentoInLine(admin.TabularInLine):

Exception Type: AttributeError at /admin/
Exception Value: 'module' object has no attribute 'TabularInLine'

--~--~-~--~~~---~--~~
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: Attribute Error: 'NoneType' object has no attribute 'get_field_sets'

2008-06-18 Thread Joseph

Molly,
You are on windows. So $ is not applicable to you. Go to command
prompt and type

python manage.py validate

Anyway, I have sent you a mail that points to one of Django
documentation page. See if you have the admin class defined.

If you are new to programming/python/django, I would recommend that
you complete the Django tutorial. That should give you an exposure to
all components of Django. Then make that tutorial into a standalone
script. That way, if you encounter any error, you will be able to
communicate with this forum in much better way.

It might be frustrating to learn all the components. But you will
succeed in the end.

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



Re: Attribute Error: 'NoneType' object has no attribute 'get_field_sets'

2008-06-18 Thread Molly

My bad, I mean I have to import all of the errors it gives me when I
got to run the site..

What do you mean "Have you tried $ python manage.py validate?"

I put that into the cmd if that's what you mean, and it gave me an
error for the $ sign, it said

"'$' is not recognized as an internal or external command,
operable program or batch file."

so I got rid of the $ sign and tried it that way and it launched up
the cmd quick and things ran through it, and closed.

I then tried it, and still same error.

Sorry if I don't understand!

Thanks for the help, aprreciate it :)

Molly

On Jun 18, 12:17 pm, "Florencio Cano" <[EMAIL PROTECTED]>
wrote:
> What do you mean with "importing your models"? Do you mean syncing
> them with the database? Have you tried $ python manage.py validate?
>
> 2008/6/18 Molly <[EMAIL PROTECTED]>:
>
>
>
> > I am creating an app to be run on the desktop,
>
> > I am in the process of importing my models, and I got this error:
>
> > 
>
> > AttributeError at /admin/base/incident/add/
> > 'NoneType' object has no attribute 'get_field_sets'
>
> > Request Method: GET
> > Request URL:http://127.0.0.1:8000/admin/base/incident/add/
> > Exception Type: AttributeError
> > Exception Value: 'NoneType' object has no attribute 'get_field_sets'
> > Exception Location: C:\Python25\lib\site-packages\django\contrib\admin
> > \views\main.py in render_change_form, line 203
> > Python Executable: C:\Python25\pythonw.exe
> > Python Version: 2.5.2
> > Python Path: ['C:\\dev\\incidents2\\hazard_inventory', 'C:\\Python25\
> > \Lib\\idlelib', 'C:\\Python25\\python25.zip', 'C:\\Python25\\DLLs', 'C:
> > \\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\
> > \lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'c:\
> > \dev']
> > Server time: Wed, 18 Jun 2008 11:48:51 -0400
>
> > 
>
> > I am new to programming so i'm not sure what this is.
> > I would really appreciate any help!
>
> > Thanks!!
> > Molly
--~--~-~--~~~---~--~~
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: Attribute Error: 'NoneType' object has no attribute 'get_field_sets'

2008-06-18 Thread Florencio Cano

What do you mean with "importing your models"? Do you mean syncing
them with the database? Have you tried $ python manage.py validate?

2008/6/18 Molly <[EMAIL PROTECTED]>:
>
> I am creating an app to be run on the desktop,
>
> I am in the process of importing my models, and I got this error:
>
> 
>
> AttributeError at /admin/base/incident/add/
> 'NoneType' object has no attribute 'get_field_sets'
>
> Request Method: GET
> Request URL: http://127.0.0.1:8000/admin/base/incident/add/
> Exception Type: AttributeError
> Exception Value: 'NoneType' object has no attribute 'get_field_sets'
> Exception Location: C:\Python25\lib\site-packages\django\contrib\admin
> \views\main.py in render_change_form, line 203
> Python Executable: C:\Python25\pythonw.exe
> Python Version: 2.5.2
> Python Path: ['C:\\dev\\incidents2\\hazard_inventory', 'C:\\Python25\
> \Lib\\idlelib', 'C:\\Python25\\python25.zip', 'C:\\Python25\\DLLs', 'C:
> \\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\
> \lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'c:\
> \dev']
> Server time: Wed, 18 Jun 2008 11:48:51 -0400
>
> 
>
> I am new to programming so i'm not sure what this is.
> I would really appreciate any help!
>
> Thanks!!
> Molly
> >
>

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



Attribute Error: 'NoneType' object has no attribute 'get_field_sets'

2008-06-18 Thread Molly

I am creating an app to be run on the desktop,

I am in the process of importing my models, and I got this error:



AttributeError at /admin/base/incident/add/
'NoneType' object has no attribute 'get_field_sets'

Request Method: GET
Request URL: http://127.0.0.1:8000/admin/base/incident/add/
Exception Type: AttributeError
Exception Value: 'NoneType' object has no attribute 'get_field_sets'
Exception Location: C:\Python25\lib\site-packages\django\contrib\admin
\views\main.py in render_change_form, line 203
Python Executable: C:\Python25\pythonw.exe
Python Version: 2.5.2
Python Path: ['C:\\dev\\incidents2\\hazard_inventory', 'C:\\Python25\
\Lib\\idlelib', 'C:\\Python25\\python25.zip', 'C:\\Python25\\DLLs', 'C:
\\Python25\\lib', 'C:\\Python25\\lib\\plat-win', 'C:\\Python25\\lib\
\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-packages', 'c:\
\dev']
Server time: Wed, 18 Jun 2008 11:48:51 -0400



I am new to programming so i'm not sure what this is.
I would really appreciate any help!

Thanks!!
Molly
--~--~-~--~~~---~--~~
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: user.get_profile() attribute error

2008-01-12 Thread Alex Koshelev

get_profile() uses default profile model manager. So if you profile
model is Profile - exception is Profile.DoesNotExist that is subclass
of ObjectDoesNotExist

On 13 янв, 02:45, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I had the settings.py configured with the wrong Model name.
> useraccount instead of userprofile.
>
> Whoops. Thanks!
>
> Though the documentation might be wrong, in that DoesNotExist doesn't
> seem to be a real exception. ObejctDoesNotExist, as defined in django/
> core/exceptions.py, is the correct exception when a profile doesn't
> exist if user.get_profile() is called.
>
> Ivan
>
> On Jan 12, 3:24 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
>
> > Do you create a profile model and set right value in settings.py 
> > file?http://www.djangoproject.com/documentation/authentication/#storing-ad...
>
> > And User.get_pofile() does not require logged in user. Note that
> > profile instance per user you must create manually.
>
> > On 13 янв, 01:32, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
>
> > > I'm trying to catch any exceptions from user.get_profile() during
> > > account creation in order to create the profile
>
> > > I create the user, authenticate them, log them in, and then try to
> > > get_profile. To start out, the user name is the email and I'm setting
> > > the password to a random string
>
> > > newUser = User.objects.create_user(email, email, randomString )
> > > user = auth.authenticate(username=email, password=randomString)
> > > auth.login(request, user)
> > > userProfile = user.get_profile()
>
> > > This causes an error:
> > > AttributeError("'NoneType' object has no attribute
> > > '_default_manager'",),
>
> > > I expected an ObjectDoesNotExist exception. It looks like the user
> > > object doesn't exist, but I explicitly test for "user is None"
>
> > > What is this about?
>
> > > Thanks,
> > > Ivan
--~--~-~--~~~---~--~~
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: user.get_profile() attribute error

2008-01-12 Thread [EMAIL PROTECTED]

I had the settings.py configured with the wrong Model name.
useraccount instead of userprofile.

Whoops. Thanks!

Though the documentation might be wrong, in that DoesNotExist doesn't
seem to be a real exception. ObejctDoesNotExist, as defined in django/
core/exceptions.py, is the correct exception when a profile doesn't
exist if user.get_profile() is called.

Ivan



On Jan 12, 3:24 pm, Alex Koshelev <[EMAIL PROTECTED]> wrote:
> Do you create a profile model and set right value in settings.py 
> file?http://www.djangoproject.com/documentation/authentication/#storing-ad...
>
> And User.get_pofile() does not require logged in user. Note that
> profile instance per user you must create manually.
>
> On 13 янв, 01:32, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > I'm trying to catch any exceptions from user.get_profile() during
> > account creation in order to create the profile
>
> > I create the user, authenticate them, log them in, and then try to
> > get_profile. To start out, the user name is the email and I'm setting
> > the password to a random string
>
> > newUser = User.objects.create_user(email, email, randomString )
> > user = auth.authenticate(username=email, password=randomString)
> > auth.login(request, user)
> > userProfile = user.get_profile()
>
> > This causes an error:
> > AttributeError("'NoneType' object has no attribute
> > '_default_manager'",),
>
> > I expected an ObjectDoesNotExist exception. It looks like the user
> > object doesn't exist, but I explicitly test for "user is None"
>
> > What is this about?
>
> > Thanks,
> > Ivan
--~--~-~--~~~---~--~~
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: user.get_profile() attribute error

2008-01-12 Thread Alex Koshelev

Do you create a profile model and set right value in settings.py file?
http://www.djangoproject.com/documentation/authentication/#storing-additional-information-about-users

And User.get_pofile() does not require logged in user. Note that
profile instance per user you must create manually.

On 13 янв, 01:32, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I'm trying to catch any exceptions from user.get_profile() during
> account creation in order to create the profile
>
> I create the user, authenticate them, log them in, and then try to
> get_profile. To start out, the user name is the email and I'm setting
> the password to a random string
>
> newUser = User.objects.create_user(email, email, randomString )
> user = auth.authenticate(username=email, password=randomString)
> auth.login(request, user)
> userProfile = user.get_profile()
>
> This causes an error:
> AttributeError("'NoneType' object has no attribute
> '_default_manager'",),
>
> I expected an ObjectDoesNotExist exception. It looks like the user
> object doesn't exist, but I explicitly test for "user is None"
>
> What is this about?
>
> Thanks,
> Ivan
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



user.get_profile() attribute error

2008-01-12 Thread [EMAIL PROTECTED]

I'm trying to catch any exceptions from user.get_profile() during
account creation in order to create the profile

I create the user, authenticate them, log them in, and then try to
get_profile. To start out, the user name is the email and I'm setting
the password to a random string

newUser = User.objects.create_user(email, email, randomString )
user = auth.authenticate(username=email, password=randomString)
auth.login(request, user)
userProfile = user.get_profile()

This causes an error:
AttributeError("'NoneType' object has no attribute
'_default_manager'",),

I expected an ObjectDoesNotExist exception. It looks like the user
object doesn't exist, but I explicitly test for "user is None"

What is this about?

Thanks,
Ivan
--~--~-~--~~~---~--~~
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: Attribute Error on Dumpdata

2007-12-07 Thread Empty

Added ticket http://code.djangoproject.com/ticket/6155 with patch.
Still need to write tests.

Michael

On Dec 7, 2007 3:15 PM, Karen Tracey <[EMAIL PROTECTED]> wrote:
>
> On Dec 7, 2007 2:31 PM, Empty <[EMAIL PROTECTED]> wrote:
>
>
> >
> >
> > > Seems dumpdata is coded to require a Manager named 'objects' for the
> Models
> > > it dumps, even though (as described here:
> > > http://www.djangoproject.com/documentation/model-api/#manager-names),
> Django
> > > does not require that a Manager named objects exists for all Models.
> > > Whether this is just an oversight in dumpdata or a conscious decision I
> > > can't say, though it looks like an oversight to me.
> >
> > You're correct Karen.  This bit of code is the culprit:
> >
> >objects = []
> >for app in app_list:
> >for model in get_models(app):
> >
> >objects.extend(model.objects.all())
> >
> > How would you propose that it be done differently?  I know that
> > through object._meta.admin.manager will give you the first manager
> > like the Admin works off of, but that is only populated if the Admin
> > inner class is defined.  I looked for the logic that does that but I
> > couldn't find it.
> >
>
> I believe it should be using _default_manager, which looks to be set to
> track the first Manager defined for a Model.  I think a (legitimate) Model
> will always have _default_manager, while it may not always have objects.
>
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Attribute Error on Dumpdata

2007-12-07 Thread Karen Tracey
On Dec 7, 2007 2:31 PM, Empty <[EMAIL PROTECTED]> wrote:

>
> > Seems dumpdata is coded to require a Manager named 'objects' for the
> Models
> > it dumps, even though (as described here:
> > http://www.djangoproject.com/documentation/model-api/#manager-names),
> Django
> > does not require that a Manager named objects exists for all Models.
> > Whether this is just an oversight in dumpdata or a conscious decision I
> > can't say, though it looks like an oversight to me.
>
> You're correct Karen.  This bit of code is the culprit:
>
>objects = []
>for app in app_list:
>for model in get_models(app):
>objects.extend(model.objects.all())
>
> How would you propose that it be done differently?  I know that
> through object._meta.admin.manager will give you the first manager
> like the Admin works off of, but that is only populated if the Admin
> inner class is defined.  I looked for the logic that does that but I
> couldn't find it.
>

I believe it should be using _default_manager, which looks to be set to
track the first Manager defined for a Model.  I think a (legitimate) Model
will always have _default_manager, while it may not always have objects.

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



Re: Attribute Error on Dumpdata

2007-12-07 Thread Empty

> Seems dumpdata is coded to require a Manager named 'objects' for the Models
> it dumps, even though (as described here:
> http://www.djangoproject.com/documentation/model-api/#manager-names), Django
> does not require that a Manager named objects exists for all Models.
> Whether this is just an oversight in dumpdata or a conscious decision I
> can't say, though it looks like an oversight to me.

You're correct Karen.  This bit of code is the culprit:

objects = []
for app in app_list:
for model in get_models(app):
objects.extend(model.objects.all())

How would you propose that it be done differently?  I know that
through object._meta.admin.manager will give you the first manager
like the Admin works off of, but that is only populated if the Admin
inner class is defined.  I looked for the logic that does that but I
couldn't find it.

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



Re: Attribute Error on Dumpdata

2007-12-07 Thread Karen Tracey
On Dec 6, 2007 8:01 PM, ttk <[EMAIL PROTECTED]> wrote:

>
> I think I found my problem...
>
> I failed to add "objects = models.Manager()" into my models which
> would explain why that attribute isn't found.
>
> I'll try this out but if anyone has additional suggestions, I'm all
> ears.


Seems dumpdata is coded to require a Manager named 'objects' for the Models
it dumps, even though (as described here:
http://www.djangoproject.com/documentation/model-api/#manager-names), Django
does not require that a Manager named objects exists for all Models.
Whether this is just an oversight in dumpdata or a conscious decision I
can't say, though it looks like an oversight to me.

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



Re: Attribute Error on Dumpdata

2007-12-06 Thread ttk

I think I found my problem...

I failed to add "objects = models.Manager()" into my models which
would explain why that attribute isn't found.

I'll try this out but if anyone has additional suggestions, I'm all
ears.

cheers,
-ttk
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Attribute Error on Dumpdata

2007-12-06 Thread ttk

Hello all,

I'm getting an attribute error when I try running the dumpdata command
on any of my apps.

news = app name
NewsEntry = model

Output:
=
C:\someproject>manage.py dumpdata news
Traceback (most recent call last):
  File "C:\someproject\manage.py", line 11, in 
execute_manager(settings)
  File "C:\Python25\lib\site-packages\django\core\management
\__init__.py", line 277, in execute_manager
utility.execute()
  File "C:\Python25\lib\site-packages\django\core\management
\__init__.py", line 225, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python25\lib\site-packages\django\core\management\base.py",
line 70, in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python25\lib\site-packages\django\core\management\base.py",
line 84, in execute
output = self.handle(*args, **options)
  File "C:\Python25\lib\site-packages\django\core\management\commands
\dumpdata.py", line 37, in handle
objects.extend(model.objects.all())
AttributeError: type object 'NewsEntry' has no attribute 'objects'
==

I suspect this is related somehow my models setup.  However, after
searching, I couldn't find any one with a similar issue.

Model class:

from django.db import models
from django.contrib.auth.models import User
from django.contrib.sites.models import Site
from django.contrib.sites.managers import CurrentSiteManager

class NewsEntry(models.Model):

site = models.ForeignKey(Site)
on_site = CurrentSiteManager()
   ...
===
So I use, for example: NewsEntry.on_site.all() INSTEAD OF
NewsEntry.objects.all()

This is all based off of the Django "Sites Framework" documentation
(http://snipr.com/1uvnz).

Any insight would be appreciated.

Thanks much in advance,
ttk
--~--~-~--~~~---~--~~
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: Attribute Error

2007-08-20 Thread MikeHowarth

Guys

I spent quite a while yesterday reading through the newforms section
of the docs, and thought I'd taken everything in.

As a python novice, I wrote a test script and couldn't replicate the
error, so was beginning to wonder whether I was cracking up! After
reading Malcolm's (comprehensive) response, it does make alot more
sense and I feel to have a better understanding of how the newforms
library hinges together.

I've got to say as someone new to django I'm really impressed at the
level of support you guys have got going on.

On Aug 20, 6:54 am, Malcolm Tredinnick <[EMAIL PROTECTED]>
wrote:
> On Sun, 2007-08-19 at 14:30 -0700, MikeHowarth wrote:
> > I'll take a look at that.
>
> > Even commenting that line out and attempting to access self.title I'm
> > still getting an attribute error thrown: 'Register' object has no
> > attribute 'title'
>
> Doug Ballanc has explained how you should be writing your save() method.
> I thought I might just add something about why what you're doing doesn't
> seem to work, despite looking like perfectly valid Python code.
>
> The newforms Form class has a specialised __new__ method, which is what
> is responsible for attaching attributes to the object you get back from
> calling Form(). In the default case (i.e. pretty much always), what this
> method does is *not* creating attributes for anything that is a
> newforms.fields.Field subclass. Rather, those fields are put into an
> attribute called "base_fields" (which is copied to an attribute called
> "fields" in __init__).
>
> All this metaclass stuff happens in DeclarativeFieldsMetaclass in
> newforms.forms. Replacing the metaclass with something elase to populate
> the base_fields leaves open some interesting possibilities about how to
> initialise form classes for those with imagination.
>
> This might look very strange and, in a way, it is unusual. When I was
> wondering, early on in newforms life, why this was done (I think my
> initial mental question was "what was he smoking?"), I realised there
> isn't a completely natural thing to store in those attributes. Do they
> hold the normalized, cleaned data? The original value? Both, depending
> upon whether clean has been called? If the attribute is None, does that
> mean we don't have that value? We haven't set it yet? Or that the form's
> normalized value is None (possible for some fields)? How would you know
> which fields had errors in them and what would prevent you accidentally
> accessing those attributes and treating the values as real values?
>
> To some extent, it reduces confusion by not having attributes at all for
> fields. Instead, you initialise a form with the raw, submitted data.
> Then you access "cleaned_data" or is_valid() or "errors" whenever you
> like and the raw data is cleaned and normalized (where possible) and
> sent to two dictionaries: Form.cleaned_data and Form.errors.
>
> So, whilst what you were attempting might seem logical on one level,
> hopefully I've explained why it could, in many cases, be more confusing
> and error-prone than convenient. So the design uses a slightly different
> approach from providing access to the form data and errors.
>
> Best wishes,
> Malcolm
>
> --
> Borrow from a pessimist - they don't expect it 
> back.http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Attribute Error

2007-08-19 Thread Malcolm Tredinnick

On Sun, 2007-08-19 at 14:30 -0700, MikeHowarth wrote:
> I'll take a look at that.
> 
> Even commenting that line out and attempting to access self.title I'm
> still getting an attribute error thrown: 'Register' object has no
> attribute 'title'

Doug Ballanc has explained how you should be writing your save() method.
I thought I might just add something about why what you're doing doesn't
seem to work, despite looking like perfectly valid Python code.

The newforms Form class has a specialised __new__ method, which is what
is responsible for attaching attributes to the object you get back from
calling Form(). In the default case (i.e. pretty much always), what this
method does is *not* creating attributes for anything that is a
newforms.fields.Field subclass. Rather, those fields are put into an
attribute called "base_fields" (which is copied to an attribute called
"fields" in __init__).

All this metaclass stuff happens in DeclarativeFieldsMetaclass in
newforms.forms. Replacing the metaclass with something elase to populate
the base_fields leaves open some interesting possibilities about how to
initialise form classes for those with imagination.

This might look very strange and, in a way, it is unusual. When I was
wondering, early on in newforms life, why this was done (I think my
initial mental question was "what was he smoking?"), I realised there
isn't a completely natural thing to store in those attributes. Do they
hold the normalized, cleaned data? The original value? Both, depending
upon whether clean has been called? If the attribute is None, does that
mean we don't have that value? We haven't set it yet? Or that the form's
normalized value is None (possible for some fields)? How would you know
which fields had errors in them and what would prevent you accidentally
accessing those attributes and treating the values as real values?

To some extent, it reduces confusion by not having attributes at all for
fields. Instead, you initialise a form with the raw, submitted data.
Then you access "cleaned_data" or is_valid() or "errors" whenever you
like and the raw data is cleaned and normalized (where possible) and
sent to two dictionaries: Form.cleaned_data and Form.errors.

So, whilst what you were attempting might seem logical on one level,
hopefully I've explained why it could, in many cases, be more confusing
and error-prone than convenient. So the design uses a slightly different
approach from providing access to the form data and errors.

Best wishes,
Malcolm

-- 
Borrow from a pessimist - they don't expect it back. 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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: Attribute Error

2007-08-19 Thread Doug B

I think you've got some misconceptions about newforms.
http://www.djangoproject.com/documentation/newforms/ should give you
the info you need.

Something more like this:

def save(self):
  #set up the objects we are going to populate
   user = User() # you want a new -instance- not another reference to
the User class
   user.title = self.clean_data['title']  # validated data in the
self.clean(ed)_data dict
   return user


--~--~-~--~~~---~--~~
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: Attribute Error

2007-08-19 Thread MikeHowarth

I'll take a look at that.

Even commenting that line out and attempting to access self.title I'm
still getting an attribute error thrown: 'Register' object has no
attribute 'title'

On Aug 19, 10:22 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> As a first guess I'm not sure that user = User is doing what you would
> want.  I think instead you want to instantiate a new User object.  All
> you are doing right now is creating an alias user for User.
>
> On Aug 19, 3:16 pm, MikeHowarth <[EMAIL PROTECTED]> wrote:
>
> > Hi I was wondering whether anyone can help me out.
>
> > I'm currently creating a form to register users, what I'm finding is
> > that when I then attempt to save the user within the Register:save
> > method I'm getting an attribute error when trying to access the title
> > attribute. I've tried referencing both title, and self.title to no
> > avail.
>
> > Can anyone advise me on where I'm going wrong with this?
>
> > class Register(forms.Form):
>
> > def __init__(self, data=None, request=None, *args, **kwargs):
> > if request is None:
> > raise TypeError("Keyword argument 'request' must be 
> > supplied")
> > super(Register, self).__init__(data, *args, **kwargs)
> > self.request = request
>
> > #personal information
> > title = forms.ChoiceField(choices=titlechoice)
>
> > def save(self):
>
> > #set up the objects we are going to populate
> > user = User
> > user.title = self.title


--~--~-~--~~~---~--~~
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: Attribute Error

2007-08-19 Thread [EMAIL PROTECTED]

As a first guess I'm not sure that user = User is doing what you would
want.  I think instead you want to instantiate a new User object.  All
you are doing right now is creating an alias user for User.

On Aug 19, 3:16 pm, MikeHowarth <[EMAIL PROTECTED]> wrote:
> Hi I was wondering whether anyone can help me out.
>
> I'm currently creating a form to register users, what I'm finding is
> that when I then attempt to save the user within the Register:save
> method I'm getting an attribute error when trying to access the title
> attribute. I've tried referencing both title, and self.title to no
> avail.
>
> Can anyone advise me on where I'm going wrong with this?
>
> class Register(forms.Form):
>
> def __init__(self, data=None, request=None, *args, **kwargs):
> if request is None:
> raise TypeError("Keyword argument 'request' must be 
> supplied")
> super(Register, self).__init__(data, *args, **kwargs)
> self.request = request
>
> #personal information
> title = forms.ChoiceField(choices=titlechoice)
>
> def save(self):
>
> #set up the objects we are going to populate
> user = User
> user.title = self.title


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



Attribute Error

2007-08-19 Thread MikeHowarth

Hi I was wondering whether anyone can help me out.

I'm currently creating a form to register users, what I'm finding is
that when I then attempt to save the user within the Register:save
method I'm getting an attribute error when trying to access the title
attribute. I've tried referencing both title, and self.title to no
avail.

Can anyone advise me on where I'm going wrong with this?

class Register(forms.Form):

def __init__(self, data=None, request=None, *args, **kwargs):
if request is None:
raise TypeError("Keyword argument 'request' must be 
supplied")
super(Register, self).__init__(data, *args, **kwargs)
self.request = request


#personal information
title = forms.ChoiceField(choices=titlechoice)

def save(self):

#set up the objects we are going to populate
user = User
user.title = self.title


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