Re: Authentication with Email

2013-03-19 Thread Lachlan Musicman
On 20 March 2013 11:09, fire_water  wrote:
> Hi,
>
> I am fairly new to Django and have started building a website that will
> require users to create an account with a username, email address, and
> password. Users will log in with their email address and password, not
> username.
>
> There has been a lot of discussion about this topic in the past, but I was
> wondering what the current best practice is for solving these problems:
>
> 1. User email address is required and unique
>
> 2. Must log in with email address and password
>
> 3. Add additional fields to models.user
>
> 4. Must not impact other built-in apps or third-party apps
>
> One approach is to extend models.user by way of a one-to-one relationship,
> as described in the docs. But that does not solve #1 and #2.
>
> Which approach do you recommend as a long-term solution?


Since the adjustable user model has only just been introduced, best
practice may change. But for your requirements, the docs (and 2
scoops) spell it out pretty well. I did this just yesterday, and here
are my brief notes:

1. re #3 Add additional fields to models.user, most likely best
practice will be keep auth.user small, create a profile with extras.

2. For 1 + 2, you will need to subclass AbstractBaseUser. It is not
enough to subclass AbstractUser and change USERNAME_FIELD to 'email'
since the email field in AbstractUser is neither unique=True nor
db_index=True.

3. What I did was, essentially, subclass AbstractBaseUser and copied
AbstractUser almost verbatim from django.contrib.auth.models. With a
few minor changes it works fine.

4. Remember: you will need to create a new MyUserManager as well, and
will need to add some goodly stuff to admin.py - mostly new forms -
again, a lot of this can be grabbed straight from
django.contrib.auth.admin.

The example in the docs,
https://docs.djangoproject.com/en/dev/topics/auth/customizing/#a-full-example
is a good start.

I copied from the original code because I still wanted to use the in
build groups/permissions - the doc's full example changes the
permission model.

I hope that helps
L.


--
The new creativity is pointing, not making. Likewise, in the future,
the best writers will be the best information managers.

http://www.theawl.com/2013/02/an-interview-with-avant-garde-poet-kenneth-goldsmith

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




Re: Django 1.5 & Python 2.7.3 - Not able to view pages

2013-03-19 Thread Kamalakannan Srinivasan
Thanks.

On Tuesday, March 19, 2013 9:05:12 PM UTC+5:30, Kamalakannan Srinivasan 
wrote:

> Hi,
>  
> I have just started learning Django 1.5 and am reading The Django Book 
> Chapter 3: Views and URL Confs.
>  
> I set up the Views.py with the following code:
>  
> *from django.http import HttpResponse
>
> def hello(request):
> return HttpResponse("Hello world")*
>  
> Then I created the urls file with the following code:
>  
> *from django.conf.urls.defaults import *
> from mysite.views import hello
>
> urlpatterns = patterns('',
> ('^hello/$', hello),
> )*
> ** 
> After running the server, when I try to access *
> http://127.0.0.1:8000/hello/* *,* the hello 
> word page does not display.
>  
> What could be the issue? Please advise.
>  
> Thanks and regards,
> Kamal
>  
> * *
> *
>
> *
>
>

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




Re: SESSION_EXPIRE_AT_BROWSER_CLOSE = True, session expiry date wrong when browser closed?

2013-03-19 Thread teddy wang


在 2010年12月10日星期五UTC+8下午9时57分20秒,Tom Evans写道:
>
> On Fri, Dec 10, 2010 at 1:27 PM, Stodge  
> wrote:
> > I have SESSION_EXPIRE_AT_BROWSER_CLOSE set to True in my settings.
> > When the user visits my custom login page a new session is created for
> > them in the database. The expiry time is set to two weeks.
> >
> > If I then close the browser, the expiry hour/minute are adjusted but
> > it's still set to two weeks in the future. Shouldn't the expiry date
> > be set to the current date?
> >
> > If I re-open the browser, login and then close the browser, the
> > session expiry time is still set to two weeks. Shouldn't the expiry
> > date be set to the current date? The session is expired because I have
> > to re-login when I visit the site again.
> >
> > Thanks
> >
>
> SESSION_EXPIRE_AT_BROWSER_CLOSE denotes whether the session cookie is
> set as a session cookie (browser removes the cookie when it closes) or
> whether it is a permanent cookie (with lifetime equal to the expiry
> date set in the model).
>
> It does not affect anything to do with stored sessions, so the session
> expiry date does not change in the DB, your browser just loses the
> session id when it is closed, and so when it is re-opened it can no
> longer access the (still valid, and not expired) session.
>
> Cheers
>
> Tom
>

Thanks, your reply helps me a lot! 

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




Re: save as

2013-03-19 Thread Larry Martell
On Tue, Mar 19, 2013 at 7:07 PM, Tim Chase
 wrote:
> On 2013-03-19 18:42, Larry Martell wrote:
>> https://docs.djangoproject.com/en/dev/howto/outputting-pdf/ which
>> says to use the Content-disposition header to trigger the save as.
>> I've done this, but I don't get a save as dialog box. The file is
>> just downloaded to a download dir with the name I have provided.
>>
>> Is there a way I can specify from my app what directory I want the
>> file saved to?
>
> I believe this is a browser-configuration setting controlled by the
> user, not by HTTP metadata.  In Firefox, I have the option to either
> open the file or save the file, along with a check-box to "always do
> this"; FF also provides me the control to specify where the file goes
> on a per-download basis, or to default to a given location.
>
> tl;dr: I don't think your web-app can take away this control from the
> user.

That's what I thought, but my client wants the file saved to a
specific location. This is an internal app, not something for public
usage. Perhaps I can pass the file back in a context and save it from
javscript.

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




Re: Goodbye, Malcolm

2013-03-19 Thread Emiliano Dalla Verde Marcozzi
My condolences to his family,
Rest in peace.


-- 
"Code without tests is broken by design." - Jacob Kaplan-Moss
Show me the mone ... code!: https://bitbucket.org/edvm

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




Re: save as

2013-03-19 Thread Tim Chase
On 2013-03-19 18:42, Larry Martell wrote:
> https://docs.djangoproject.com/en/dev/howto/outputting-pdf/ which
> says to use the Content-disposition header to trigger the save as.
> I've done this, but I don't get a save as dialog box. The file is
> just downloaded to a download dir with the name I have provided.
> 
> Is there a way I can specify from my app what directory I want the
> file saved to?

I believe this is a browser-configuration setting controlled by the
user, not by HTTP metadata.  In Firefox, I have the option to either
open the file or save the file, along with a check-box to "always do
this"; FF also provides me the control to specify where the file goes
on a per-download basis, or to default to a given location.

tl;dr: I don't think your web-app can take away this control from the
user.

-tkc


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




save as

2013-03-19 Thread Larry Martell
2 questions about saving a file on the user's computer.

Is there a way to trigger a 'save as' dialog box? I've read
https://docs.djangoproject.com/en/dev/howto/outputting-pdf/ which says
to use the Content-disposition header to trigger the save as. I've
done this, but I don't get a save as dialog box. The file is just
downloaded to a download dir with the name I have provided.

Is there a way I can specify from my app what directory I want the
file saved to?

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




Re: Goodbye, Malcolm

2013-03-19 Thread Rafael E. Ferrero
2013/3/19 Satinderpal Singh 

> On Tue, Mar 19, 2013 at 10:31 PM, Jacob Kaplan-Moss 
> wrote:
> > Hello fellow Djangonauts,
> >
> > We have difficult news: Malcolm Tredinnick has passed away.
> >
> > Malcolm was a long-time contributor to Django, a model community member,
> > a brilliant mind, and a friend. His contributions to Django — and to
> > many other open source projects — are nearly impossible to enumerate.
> > Many on the core Django team had their first patches reviewed by him;
> > his mentorship enriched us. His consideration, patience, and dedication
> > will always be an inspiration to us.
> >
> > To say we'll miss him is an understatement.
> >
> > Our thoughts are with Malcolm's friends, colleagues, and family at this
> > difficult time.
> >
> > This came as quite a shock, and we're still sorting out details. We'll
> > update our blog,
> > https://www.djangoproject.com/weblog/2013/mar/19/goodbye-malcolm/,
> > once we know the details of how you can express your condolences to
> > Malcolm's friends and family.
>
> Rest in Peace
>
> > — The Django Core Team
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Django developers" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to django-developers+unsubscr...@googlegroups.com.
> > To post to this group, send email to django-develop...@googlegroups.com.
> > Visit this group at
> http://groups.google.com/group/django-developers?hl=en.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >
> >
>
>
>
> --
> Satinderpal Singh
> http://devplace.in/~satinder/wordpress/
> http://satindergoraya.blogspot.in/
> http://satindergoraya91.blogspot.in/
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
RIP.. my condolences to his family

-- 
Rafael E. Ferrero
Claro: (03562) 15514856

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




Re: Authentication with Email

2013-03-19 Thread Shawn Milochik
Your timing is just about perfect. Django 1.5 was just released, with
a customizable user model. So use that.

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




Authentication with Email

2013-03-19 Thread fire_water
Hi,

I am fairly new to Django and have started building a website that will 
require users to create an account with a username, email address, and 
password. Users will log in with their email address and password, not 
username.

There has been a lot of discussion about this topic in the past, but I was 
wondering what the current best practice is for solving these problems:

1. User email address is required and unique

2. Must log in with email address and password

3. Add additional fields to models.user

4. Must not impact other built-in apps or third-party apps

One approach is to extend models.user by way of a one-to-one relationship, 
as described in the 
docs.
 
But that does not solve #1 and #2.

Which approach do you recommend as a long-term solution?

Thanks!

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




Re: Django 1.5 & Python 2.7.3 - Not able to view pages

2013-03-19 Thread Joel Goldstick
On Tue, Mar 19, 2013 at 11:35 AM, Kamalakannan Srinivasan <
kamalakannan.sriniva...@gmail.com> wrote:

> Hi,
>
> I have just started learning Django 1.5 and am reading The Django Book
> Chapter 3: Views and URL Confs.
>
> I set up the Views.py with the following code:
>
> *from django.http import HttpResponse
>
> def hello(request):
> return HttpResponse("Hello world")*
>
> Then I created the urls file with the following code:
>
> *from django.conf.urls.defaults import *
> from mysite.views import hello
>
> urlpatterns = patterns('',
> ('^hello/$', hello),
> )*
> **
> After running the server, when I try to access *
> http://127.0.0.1:8000/hello/* *,* the hello
> word page does not display.
>

The django book is for an earlier version and there may be some issue
between that and 1.5.  I suggest you go to djangoproject.com and go through
the tutorial.  Its good, and only takes an hour or three.

>
> What could be the issue? Please advise.
>
> Thanks and regards,
> Kamal
>
> * *
> *
>
> *
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Joel Goldstick
http://joelgoldstick.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 post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Error en Dajaxice

2013-03-19 Thread Christian Puchaicela
Failed to load resource: the server responded with a status of 403 
(FORBIDDEN) http://192.168.1.1:8000/dajaxice/administrador.loadImages/
Dajaxice: Something went wrong. 

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




Can't create an object with a foreign key

2013-03-19 Thread Cody Scott
I get the error when I try to make an object.

Cannot assign "u'Category object'": "Course.category" must be a "Category" 
> instance.


here is my admin form

admin.py

admin.site.register(Category, list_display = ('name',))

CATEGORIES = [(category, category.name) for category in Category.objects.all()]
class CourseAdminForm(forms.ModelForm):
class Meta:
model = Course
category = forms.ChoiceField(choices=CATEGORIES)
class CourseAdmin(admin.ModelAdmin):
form = CourseAdminForm
 

admin.site.register(Course, CourseAdmin) 

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




Can't make an object with a foreign key

2013-03-19 Thread Cody Scott
Can't make an object with a foreign key. When I submit it says 

Cannot assign "u'Category object'": "Course.category" must be a "Category" 
> instance.
>
 
Here is my admin form 

admin.py
 

> admin.site.register(Category, list_display = ('name',))
> CATEGORIES = [(category, category.name) for category in Category.objects.
> all()]
>
 

> class CourseAdminForm(forms.ModelForm):
> class Meta:
> model = Course
> category = forms.ChoiceField(choices=CATEGORIES)
>
 

> class CourseAdmin(admin.ModelAdmin):
>  form = CourseAdminForm
>
 

> admin.site.register(Course, CourseAdmin)


 

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




Django 1.5 & Python 2.7.3 - Not able to view pages

2013-03-19 Thread Kamalakannan Srinivasan
Hi,
 
I have just started learning Django 1.5 and am reading The Django Book 
Chapter 3: Views and URL Confs.
 
I set up the Views.py with the following code:
 
*from django.http import HttpResponse

def hello(request):
return HttpResponse("Hello world")*
 
Then I created the urls file with the following code:
 
*from django.conf.urls.defaults import *
from mysite.views import hello

urlpatterns = patterns('',
('^hello/$', hello),
)*
** 
After running the server, when I try to access *http://127.0.0.1:8000/hello/
* *,* the hello word page does not display.
 
What could be the issue? Please advise.
 
Thanks and regards,
Kamal
 
* *
*

*

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




Django 1.5 - admin update user, got message "User with this Username already exists" (Django 1.4 excepted update of the user)

2013-03-19 Thread K van Man
 

*Django 1.5 - admin update user, got message "User with this Username 
already exists" (Django 1.4 excepted update of the user)*

Created a simple polls app, and using the django.contrib.auth in 
INSTALLED_APPS 

When an attempt is made to update a user (in the admin frontend) this 
message is produced: 'User with this Username already exists.'

The same example is working fine (update the user without warnings) in 
Django 1.4

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




Re: How can I get around required fields in admin?

2013-03-19 Thread Mike Dewhirst

On 20/03/2013 12:23am, Javier Guerra Giraldez wrote:

On Tue, Mar 19, 2013 at 8:13 AM, frocco  wrote:

These required fields will not have data until a user checks out.


then they're not required from a database point of view.

regardless of that, they can be required on a form.




or you can program your own precise business logic in the clean() method 
of the model including raising a ValidationError if info doesn't stack up.


https://docs.djangoproject.com/en/1.4/ref/models/instances/#django.db.models.Model.clean

Although you can do it in the form, IMHO the advantage of using the 
clean() method in the model is keeping validation as close to the data 
as possible - where it belongs!


Mike

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




Re: Goodbye, Malcolm

2013-03-19 Thread Satinderpal Singh
On Tue, Mar 19, 2013 at 10:31 PM, Jacob Kaplan-Moss  wrote:
> Hello fellow Djangonauts,
>
> We have difficult news: Malcolm Tredinnick has passed away.
>
> Malcolm was a long-time contributor to Django, a model community member,
> a brilliant mind, and a friend. His contributions to Django — and to
> many other open source projects — are nearly impossible to enumerate.
> Many on the core Django team had their first patches reviewed by him;
> his mentorship enriched us. His consideration, patience, and dedication
> will always be an inspiration to us.
>
> To say we'll miss him is an understatement.
>
> Our thoughts are with Malcolm's friends, colleagues, and family at this
> difficult time.
>
> This came as quite a shock, and we're still sorting out details. We'll
> update our blog,
> https://www.djangoproject.com/weblog/2013/mar/19/goodbye-malcolm/,
> once we know the details of how you can express your condolences to
> Malcolm's friends and family.

Rest in Peace

> — The Django Core Team
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Django developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-developers+unsubscr...@googlegroups.com.
> To post to this group, send email to django-develop...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-developers?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>



-- 
Satinderpal Singh
http://devplace.in/~satinder/wordpress/
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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




Goodbye, Malcolm

2013-03-19 Thread Jacob Kaplan-Moss
Hello fellow Djangonauts,

We have difficult news: Malcolm Tredinnick has passed away.

Malcolm was a long-time contributor to Django, a model community member,
a brilliant mind, and a friend. His contributions to Django — and to
many other open source projects — are nearly impossible to enumerate.
Many on the core Django team had their first patches reviewed by him;
his mentorship enriched us. His consideration, patience, and dedication
will always be an inspiration to us.

To say we'll miss him is an understatement.

Our thoughts are with Malcolm's friends, colleagues, and family at this
difficult time.

This came as quite a shock, and we're still sorting out details. We'll
update our blog,
https://www.djangoproject.com/weblog/2013/mar/19/goodbye-malcolm/,
once we know the details of how you can express your condolences to
Malcolm's friends and family.

— The Django Core Team

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




Re: How can I get around required fields in admin?

2013-03-19 Thread Javier Guerra Giraldez
On Tue, Mar 19, 2013 at 8:28 AM, frocco  wrote:
> I am using forms.ModelForm
>
> So I would have to redo this as just a form.

or you could override some (most?) fields in the modelform.

-- 
Javier

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




Re: How can I get around required fields in admin?

2013-03-19 Thread frocco
ok,

I am using forms.ModelForm

So I would have to redo this as just a form.

On Tuesday, March 19, 2013 9:23:31 AM UTC-4, Javier Guerra wrote:
>
> On Tue, Mar 19, 2013 at 8:13 AM, frocco  
> wrote: 
> > These required fields will not have data until a user checks out. 
>
> then they're not required from a database point of view. 
>
> regardless of that, they can be required on a form. 
>
>
> -- 
> Javier 
>

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




Re: How can I get around required fields in admin?

2013-03-19 Thread Javier Guerra Giraldez
On Tue, Mar 19, 2013 at 8:13 AM, frocco  wrote:
> These required fields will not have data until a user checks out.

then they're not required from a database point of view.

regardless of that, they can be required on a form.


-- 
Javier

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




How can I get around required fields in admin?

2013-03-19 Thread frocco
Hello,

I have a user profile attached to user that has several fields for billing 
info.

When a user check's out, these fields are required.

However there is one field that I want the admin to change, but it will not 
save unless the other required fields are filled.

These required fields will not have data until a user checks out.


I thought about just moving the admin field to another table, but then I 
would have to do another lookup.

Thanks

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




filter_horizontal ordering

2013-03-19 Thread Nicklas af Ekenstam
Hello,

I use a couple of filter_horizontals in my admin but cannot figure out
how to get the data in them sorted alphabetically.
Here is my code:

class PlaceAdmin(admin.ModelAdmin):
list_display = ('place_name', 'area', 'subway',)
filter_horizontal = ('labels', 'cuisine', 'category',)
ordering = ['place_name']

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

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

class CategoryAdmin(admin.ModelAdmin):
list_display = ('category_name',)
ordering = ['category_name']

Say, for an example that I want the labels to be displayed in
alphabetical order; how would I do this? Or if I just want all my
filter_horizontal displays to be in order?

Thanks,
Nicklas

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




Re: Django 1.5 where are the static files of admin site

2013-03-19 Thread Felipe Coelho
2013/3/19 RedJuan 

> I'm setting up nginx to serve static files.
> Route (django / contrib / admin / media / admin) is not on the
> installation path (/ usr/local/lib/python2.7/dist-packages/django)
> Where is it located now?
>

Why don't you run "python manage.py collectstatic" and set the nginx root
for static files from there?
https://docs.djangoproject.com/en/dev/howto/static-files/#deploying-static-files-in-a-nutshell

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




Django 1.5 where are the static files of admin site

2013-03-19 Thread RedJuan
I'm setting up nginx to serve static files.
Route (django / contrib / admin / media / admin) is not on the installation 
path (/ usr/local/lib/python2.7/dist-packages/django)
Where is it located now?

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




Re: How to get ten random records

2013-03-19 Thread frocco

I am doing this.

 featured = Product.objects.filter(is_featured=True, 
is_active=True).order_by('?')[:4]
  
On Tuesday, March 19, 2013 12:03:28 AM UTC-4, Mike Dewhirst wrote:
>
> No really, I want a maximum of ten random records from the database 
> (Django 1.4, Postgres 9.1). 
>
>
> Looking at the docs this seems to be what I want ... 
>
> Items.objects.filter(name__icontains=term).order_by('?')[:10] 
>
> Is there a better way? 
>
> Would .order_by() be quicker if I wasn't too concerned about true 
> randomness? 
>
> Do I need try: except: pass to silence errors if there aren't any results? 
>
> Thanks 
>
> Mike 
>
>
>
>

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




Re: Performance when retrieving data from related models

2013-03-19 Thread Taras D
Thanks again!

On 19 March 2013 13:09, Peter of the Norse  wrote:

> [snip]
>
> We might put the onus on the client to call:
> qs = getTendersForContractor(contractor)
> for tender in list(qs.prefetch_related('project', 'project__contract',
> 'project__contract')):
> print tender, tender.getTotalCost()
>
>
> If this is really what you are doing, then I strongly recommend
> https://docs.djangoproject.com/en/dev/topics/db/aggregation/. This case
> is a single SQL statement.
>
> Not only is this complicated, but this requires the client know how the
> Tender is implemented (the prefetched would become uneccessary if we
> changed the implementation to store the total cost on the actual Tender
> itself at the cost of denormalised data). Note that you wouldn't have these
> problems if the data existed in memory.
>
> These points are making me rethink my data model and API design, and that
> the OO paradigm doesn't always fit well with web apps. In particular the
> slides at
> http://www.slideshare.net/OReillyOSCON/unbreaking-your-django-application:
>
> 23: "Django doesn’t have a good primitive for returning an object graph in
> one call. - multiple db trips required" Implies that object graphs like
> what I've designed is difficult to implement effeciently..?
>
> 24: "So, what do to?  If you almost always return the parent along with
> the related object, consider object inheritance instead.  That does do a
> nice join operation.  Don’t create an insane class graph, though.  If you
> frequently use the related object without reference to the parent object,
> use a foreign key." Not sure what 'object inheritance' is but might be
> useful, and concerned that I might be heading towards an 'insane class
> graph' (the real data model has 6 or 7 more related objects). Am I heading
> down the wrong path of embracing an OO style API and data model?
>
> I don’t know. But I think you have to acknowledge that there is such a
> thing as too OOP. I’m not sure that creating an API on top of Django is a
> good idea. Django is already super high level. I would have to ask myself
> how I expect my users to use what I give them. On some level, you’ll have
> to trust your user to ask for the data they need.
>
>
Getting the total cost isn't exactly what I was doing, I was trying to come
up with a simple example of a function on the class that can't
easily/cleanly be calculated by simply aggregating data from the related
objects. With this I think I've hit an impedance mismatch problem, from
http://blogs.tedneward.com/2006/06/26/The+Vietnam+Of+Computer+Science.aspx

"Unfortunately, fields within the object are only part of the problem--the
other problem we face is that objects are frequently associated with other
objects, in various cardinalities (one-to-one, one-to-many, many-to-one,
many-to-many), and an O/R mapping has to make some up-front decisions about
when to retrieve these associated objects"

Which is exactly the issue I'm having. As you've stated there isn't a
straight forward solution, and I'll have to consider tradeoffs in my design
decisions.

Taras

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