Re: Is there a way to supress blank lines in the HTML?

2014-10-23 Thread termopro

May i ask you why do you need that ?

If you need this for some performance reasons like html compression, you 
are doing it wrong.
Instead you could use server-side GZIP compression when serving html which 
will do the job much more efficiently.

If you are concerned about the structure of the document, the "beauty" of 
indents and spaces - i guess you should google for "html prettify for 
python".

Best regards,
Vladimir

On Thursday, October 23, 2014 2:24:16 AM UTC+3, Daniel Grace wrote:
>
> Hi,
> Is there a way to suppress blank lines in the HTML?
> I tried using the spaceless tag but it is overkill for what I want.
> I just want to suppress the blank lines from the HTML and not all space.
>
> Any ideas?
>
> 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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ec0ca154-f465-4970-b8c4-9b92140a07c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST Framework

2014-10-23 Thread Max Nathaniel Ho
Hi Russell,

Thanks for your reply. As I am fairly new to django and programming in
general, do you mind sharing what REST APIs actually do? Thank you!

On Thu, Oct 23, 2014 at 11:51 AM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> Hi Max,
>
> Django ReST Framework, as the name suggests, is a framework for building
> ReST APIs in Django.
>
> It's not officially part of the Django framework, but it's creator and
> principle maintainer - Tom Christie - is a member of the Django core team.
> Tom recently held a Kickstarter to fund v3 of the framework; that
> Kickstarter was extraordinarily successful due to the support of the
> community.
>
> If you need to write a ReSTful API for your Django app, it's well worth
> your time to take a look at it.
>
> Yours,
> Russ Magee %-)
>
> On Thu, Oct 23, 2014 at 11:14 AM, Max Nathaniel Ho 
> wrote:
>
>> Hi all,
>>
>> I just came across Django REST Framework. From what I have read up so
>> far, its a Web API framework.
>>
>> What does it do and what is the difference between this and the regular
>> Django Web Framework?
>>
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/94c429f5-6028-4e17-9839-4e5c76f99a6d%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/z9FJVsVnK4o/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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJxq84_zzgwEUOM1tw%2B558LrVWjoN_ef__OBwqDUiSjdESTOMQ%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Regards,
Max Nathaniel Ho.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMognGGKu-D576%3DXYYh2yBCEnaEny-fjE%2BNOcjT8%2BZ%3DRVwa_Tw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST Framework

2014-10-23 Thread Andreas Kuhne
Hi Max,

I think you should really just google it a bit and read about it.
http://en.wikipedia.org/wiki/Representational_state_transfer is a good
start.

A simplified version is that a REST API allows you to get information about
your database models in a structured and predictive way. HOW the API should
behave is also documented.

You wouldn't use it for presenting information on the web, but rather for
connecting to your backend via javascript or connecting 2 different
projects over the Internet.

Regards,

Andréas

2014-10-23 10:14 GMT+02:00 Max Nathaniel Ho :

> Hi Russell,
>
> Thanks for your reply. As I am fairly new to django and programming in
> general, do you mind sharing what REST APIs actually do? Thank you!
>
> On Thu, Oct 23, 2014 at 11:51 AM, Russell Keith-Magee <
> russ...@keith-magee.com> wrote:
>
>> Hi Max,
>>
>> Django ReST Framework, as the name suggests, is a framework for building
>> ReST APIs in Django.
>>
>> It's not officially part of the Django framework, but it's creator and
>> principle maintainer - Tom Christie - is a member of the Django core team.
>> Tom recently held a Kickstarter to fund v3 of the framework; that
>> Kickstarter was extraordinarily successful due to the support of the
>> community.
>>
>> If you need to write a ReSTful API for your Django app, it's well worth
>> your time to take a look at it.
>>
>> Yours,
>> Russ Magee %-)
>>
>> On Thu, Oct 23, 2014 at 11:14 AM, Max Nathaniel Ho 
>> wrote:
>>
>>> Hi all,
>>>
>>> I just came across Django REST Framework. From what I have read up so
>>> far, its a Web API framework.
>>>
>>> What does it do and what is the difference between this and the regular
>>> Django Web Framework?
>>>
>>> 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.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/94c429f5-6028-4e17-9839-4e5c76f99a6d%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
>> 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/z9FJVsVnK4o/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 http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAJxq84_zzgwEUOM1tw%2B558LrVWjoN_ef__OBwqDUiSjdESTOMQ%40mail.gmail.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> Regards,
> Max Nathaniel Ho.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAMognGGKu-D576%3DXYYh2yBCEnaEny-fjE%2BNOcjT8%2BZ%3DRVwa_Tw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALXYUb%3D0c1R_%3DsDKSuzDTKOb%2BHKio0DfgaK6PsRGT%3DYLFSvUTQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST Framework

2014-10-23 Thread Max Nathaniel Ho
Hi Andreas,

Thank you. Will read up!

On Thu, Oct 23, 2014 at 4:18 PM, Andreas Kuhne 
wrote:

> Hi Max,
>
> I think you should really just google it a bit and read about it.
> http://en.wikipedia.org/wiki/Representational_state_transfer is a good
> start.
>
> A simplified version is that a REST API allows you to get information
> about your database models in a structured and predictive way. HOW the API
> should behave is also documented.
>
> You wouldn't use it for presenting information on the web, but rather for
> connecting to your backend via javascript or connecting 2 different
> projects over the Internet.
>
> Regards,
>
> Andréas
>
> 2014-10-23 10:14 GMT+02:00 Max Nathaniel Ho :
>
>> Hi Russell,
>>
>> Thanks for your reply. As I am fairly new to django and programming in
>> general, do you mind sharing what REST APIs actually do? Thank you!
>>
>> On Thu, Oct 23, 2014 at 11:51 AM, Russell Keith-Magee <
>> russ...@keith-magee.com> wrote:
>>
>>> Hi Max,
>>>
>>> Django ReST Framework, as the name suggests, is a framework for building
>>> ReST APIs in Django.
>>>
>>> It's not officially part of the Django framework, but it's creator and
>>> principle maintainer - Tom Christie - is a member of the Django core team.
>>> Tom recently held a Kickstarter to fund v3 of the framework; that
>>> Kickstarter was extraordinarily successful due to the support of the
>>> community.
>>>
>>> If you need to write a ReSTful API for your Django app, it's well worth
>>> your time to take a look at it.
>>>
>>> Yours,
>>> Russ Magee %-)
>>>
>>> On Thu, Oct 23, 2014 at 11:14 AM, Max Nathaniel Ho 
>>> wrote:
>>>
 Hi all,

 I just came across Django REST Framework. From what I have read up so
 far, its a Web API framework.

 What does it do and what is the difference between this and the regular
 Django Web Framework?

 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.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/94c429f5-6028-4e17-9839-4e5c76f99a6d%40googlegroups.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>  --
>>> 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/z9FJVsVnK4o/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 http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAJxq84_zzgwEUOM1tw%2B558LrVWjoN_ef__OBwqDUiSjdESTOMQ%40mail.gmail.com
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> --
>> Regards,
>> Max Nathaniel Ho.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAMognGGKu-D576%3DXYYh2yBCEnaEny-fjE%2BNOcjT8%2BZ%3DRVwa_Tw%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/z9FJVsVnK4o/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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALXYUb%3D0c1R_%3DsDKSuzDTK

Re: Is there a way to supress blank lines in the HTML?

2014-10-23 Thread Avraham Serour
I suggest taking a look at google pagespeed, you can add it to nginx or
even apache
But many people like to do this at the django level, you should look for
apps like django compressor

On Thu, Oct 23, 2014 at 9:59 AM, termopro  wrote:

>
> May i ask you why do you need that ?
>
> If you need this for some performance reasons like html compression, you
> are doing it wrong.
> Instead you could use server-side GZIP compression when serving html which
> will do the job much more efficiently.
>
> If you are concerned about the structure of the document, the "beauty" of
> indents and spaces - i guess you should google for "html prettify for
> python".
>
> Best regards,
> Vladimir
>
> On Thursday, October 23, 2014 2:24:16 AM UTC+3, Daniel Grace wrote:
>>
>> Hi,
>> Is there a way to suppress blank lines in the HTML?
>> I tried using the spaceless tag but it is overkill for what I want.
>> I just want to suppress the blank lines from the HTML and not all space.
>>
>> Any ideas?
>>
>> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ec0ca154-f465-4970-b8c4-9b92140a07c5%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFWa6tKVt%3DAKrnKTwe5q%2B_K5nndm46zoC%3DsawisLqz%3Dyd8fwAQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django REST Framework

2014-10-23 Thread Lachlan Musicman
The way I always describe APIs (in a broad, general sense) is:

Image internet service "Twotter" had posts, and each post had a date.

If they had a date API you might be able to get all of the posts for a
month like:

for month in months:
  return "https://twotter.org/%s"; %month

and then you could see all the twotter posts for the month "month".

Of course, it could be any variable on any model - gender or length or
a boolean or whatever

Cheers
L.


On 23 October 2014 19:20, Max Nathaniel Ho  wrote:
> Hi Andreas,
>
> Thank you. Will read up!
>
> On Thu, Oct 23, 2014 at 4:18 PM, Andreas Kuhne 
> wrote:
>>
>> Hi Max,
>>
>> I think you should really just google it a bit and read about it.
>> http://en.wikipedia.org/wiki/Representational_state_transfer is a good
>> start.
>>
>> A simplified version is that a REST API allows you to get information
>> about your database models in a structured and predictive way. HOW the API
>> should behave is also documented.
>>
>> You wouldn't use it for presenting information on the web, but rather for
>> connecting to your backend via javascript or connecting 2 different projects
>> over the Internet.
>>
>> Regards,
>>
>> Andréas
>>
>> 2014-10-23 10:14 GMT+02:00 Max Nathaniel Ho :
>>>
>>> Hi Russell,
>>>
>>> Thanks for your reply. As I am fairly new to django and programming in
>>> general, do you mind sharing what REST APIs actually do? Thank you!
>>>
>>> On Thu, Oct 23, 2014 at 11:51 AM, Russell Keith-Magee
>>>  wrote:

 Hi Max,

 Django ReST Framework, as the name suggests, is a framework for building
 ReST APIs in Django.

 It's not officially part of the Django framework, but it's creator and
 principle maintainer - Tom Christie - is a member of the Django core team.
 Tom recently held a Kickstarter to fund v3 of the framework; that
 Kickstarter was extraordinarily successful due to the support of the
 community.

 If you need to write a ReSTful API for your Django app, it's well worth
 your time to take a look at it.

 Yours,
 Russ Magee %-)

 On Thu, Oct 23, 2014 at 11:14 AM, Max Nathaniel Ho 
 wrote:
>
> Hi all,
>
> I just came across Django REST Framework. From what I have read up so
> far, its a Web API framework.
>
> What does it do and what is the difference between this and the regular
> Django Web Framework?
>
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/94c429f5-6028-4e17-9839-4e5c76f99a6d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.


 --
 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/z9FJVsVnK4o/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 http://groups.google.com/group/django-users.
 To view this discussion on the web visit
 https://groups.google.com/d/msgid/django-users/CAJxq84_zzgwEUOM1tw%2B558LrVWjoN_ef__OBwqDUiSjdESTOMQ%40mail.gmail.com.

 For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Max Nathaniel Ho.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to django-users+unsubscr...@googlegroups.com.
>>> To post to this group, send email to django-users@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/CAMognGGKu-D576%3DXYYh2yBCEnaEny-fjE%2BNOcjT8%2BZ%3DRVwa_Tw%40mail.gmail.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> --
>> 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/z9FJVsVnK4o/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 http://groups.google.com/group/django-user

Re: Django REST Framework

2014-10-23 Thread Max Nathaniel Ho
Hi Lachlan,

Simple and clear explanation. Thanks!

On Thu, Oct 23, 2014 at 5:43 PM, Lachlan Musicman  wrote:

> The way I always describe APIs (in a broad, general sense) is:
>
> Image internet service "Twotter" had posts, and each post had a date.
>
> If they had a date API you might be able to get all of the posts for a
> month like:
>
> for month in months:
>   return "https://twotter.org/%s"; %month
>
> and then you could see all the twotter posts for the month "month".
>
> Of course, it could be any variable on any model - gender or length or
> a boolean or whatever
>
> Cheers
> L.
>
>
> On 23 October 2014 19:20, Max Nathaniel Ho  wrote:
> > Hi Andreas,
> >
> > Thank you. Will read up!
> >
> > On Thu, Oct 23, 2014 at 4:18 PM, Andreas Kuhne <
> andreas.ku...@suitopia.com>
> > wrote:
> >>
> >> Hi Max,
> >>
> >> I think you should really just google it a bit and read about it.
> >> http://en.wikipedia.org/wiki/Representational_state_transfer is a good
> >> start.
> >>
> >> A simplified version is that a REST API allows you to get information
> >> about your database models in a structured and predictive way. HOW the
> API
> >> should behave is also documented.
> >>
> >> You wouldn't use it for presenting information on the web, but rather
> for
> >> connecting to your backend via javascript or connecting 2 different
> projects
> >> over the Internet.
> >>
> >> Regards,
> >>
> >> Andréas
> >>
> >> 2014-10-23 10:14 GMT+02:00 Max Nathaniel Ho :
> >>>
> >>> Hi Russell,
> >>>
> >>> Thanks for your reply. As I am fairly new to django and programming in
> >>> general, do you mind sharing what REST APIs actually do? Thank you!
> >>>
> >>> On Thu, Oct 23, 2014 at 11:51 AM, Russell Keith-Magee
> >>>  wrote:
> 
>  Hi Max,
> 
>  Django ReST Framework, as the name suggests, is a framework for
> building
>  ReST APIs in Django.
> 
>  It's not officially part of the Django framework, but it's creator and
>  principle maintainer - Tom Christie - is a member of the Django core
> team.
>  Tom recently held a Kickstarter to fund v3 of the framework; that
>  Kickstarter was extraordinarily successful due to the support of the
>  community.
> 
>  If you need to write a ReSTful API for your Django app, it's well
> worth
>  your time to take a look at it.
> 
>  Yours,
>  Russ Magee %-)
> 
>  On Thu, Oct 23, 2014 at 11:14 AM, Max Nathaniel Ho <
> maxhow...@gmail.com>
>  wrote:
> >
> > Hi all,
> >
> > I just came across Django REST Framework. From what I have read up so
> > far, its a Web API framework.
> >
> > What does it do and what is the difference between this and the
> regular
> > Django Web Framework?
> >
> > 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.
> > To view this discussion on the web visit
> >
> https://groups.google.com/d/msgid/django-users/94c429f5-6028-4e17-9839-4e5c76f99a6d%40googlegroups.com
> .
> > For more options, visit https://groups.google.com/d/optout.
> 
> 
>  --
>  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/z9FJVsVnK4o/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 http://groups.google.com/group/django-users.
>  To view this discussion on the web visit
> 
> https://groups.google.com/d/msgid/django-users/CAJxq84_zzgwEUOM1tw%2B558LrVWjoN_ef__OBwqDUiSjdESTOMQ%40mail.gmail.com
> .
> 
>  For more options, visit https://groups.google.com/d/optout.
> >>>
> >>>
> >>>
> >>>
> >>> --
> >>> Regards,
> >>> Max Nathaniel Ho.
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Django users" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an
> >>> email to django-users+unsubscr...@googlegroups.com.
> >>> To post to this group, send email to django-users@googlegroups.com.
> >>> Visit this group at http://groups.google.com/group/django-users.
> >>> To view this discussion on the web visit
> >>>
> https://groups.google.com/d/msgid/django-users/CAMognGGKu-D576%3DXYYh2yBCEnaEny-fjE%2BNOcjT8%2BZ%3DRVwa_Tw%40mail.gmail.com
> .
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> >> --
> >> You received this me

Starting a procedure when opening a model in the admin interface

2014-10-23 Thread Victor
I use Django 1.7, admin interface, and PostgreSQL. 
I have, among other things, the following model:

### models.py
class Patients(models.Model):
   surname = models.CharField(max_length=60, db_index=True)
   name = models.CharField(max_length=60,  db_index=True)
   address = models.CharField(max_length=150)
   city = models.CharField(max_length=120)
   zipcode = models.CharField(max_length=15)
   def __unicode__(self):
   return u"%s %s" % (self.surname, self.name)
   class Meta:
   db_table = u'patients'
   ordering=['surname', 'name']

In this phase of test this model is fed by a python procedure which reads the 
fields in a a query from an Oracle DB. This procedure for the time being is run 
manually from time to time when I need to refresh the content of the model.

In production context I would like to start this same python procedure 
automatically each time a user clicks on the model Patients in the list of 
models proposed by the admin interface (I mean the one that appears when you 
call http://localhost:8000/admin) before opening the model itself in order to 
have its content refreshed to the very last item.

How can I do it? 
What kind of signal, if any, should I use?

Ciao
Vittorio

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/D997970F-6532-489D-87FD-EB7E6BCFCBA9%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


DateTimeField: Hide clock

2014-10-23 Thread Oskar Lyrstrand
models.py:
class Post(models.Model):
pub_date = models.DateTimeField

template.html:
{{ post.pub_date }}

output:
 23 october 2014 19:25

Problem is I dont want "19:25" to show. What can I do?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd6c974f-5762-48c1-92c3-65b338345b85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-admin creates the views.py files in the wrong place!

2014-10-23 Thread Daniel Roseman
On Wednesday, 22 October 2014 22:05:07 UTC+1, Aliane Abdelouahab wrote:
>
> Hi,
> Django 1.7 when a beginner runs the first tutorial, he has to change the 
> views.py file outside the app to the whole project itself.
> i found this, 
> http://stackoverflow.com/questions/22011791/importerror-no-module-named-views 
> and it seems it is related to Django 1.6 too?
>

No, there is no need to move any views files. What makes you think there 
is? Please show exactly what you have done and any errors you receive.
--
DR.

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


Re: [AGAIN] Inserting further fields of a foreignkey object into change list view

2014-10-23 Thread Victor
Dear Experts,
following the indications of Collin I was able to see the extra fields I wanted 
to show in the change list view. But there's a little problem.
The character size of the labels of the readonly_fields are bigger than those 
of the printed fields so that the visual effect is that the labels and their 
relating fields don't look aligned (see the attached png file).
How can I modify the size of readonly_fields characters?
Ciao
Vittorio

Il giorno 21/ott/2014, alle ore 19:24, Vittorio ha scritto:

> Great, it works!
> Thanks a lot Collin
> Ciao from Rome
> Vittorio
> Il giorno 21/ott/2014, alle ore 18:00, Collin Anderson ha scritto:
> 
>> Hi Vittorio,
>> 
>> Would this work?
>> 
>> class OperationAdmin(admin.ModelAdmin): 
>>list_display = ('patient','date_of_operation') 
>>fields = ('patient', 'patient_address', 'patient_city_zip', 
>> 'date_of_operation')
>>readonly_field = ['patient_address', 'patient_city_zip']
>>inlines= [DetailsInline] 
>>order_by= ['-date_of_operation'] 
>> 
>>def patient_address(self, operation):
>>return operation.patient.address
>> 
>>def patient_city_zip(self, operation):
>>return '%s %s' % (operation.patient.city, operation.patient.zipcode)
>> 
>> Collin
>> 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0FE333F3-7AC4-46AB-8760-18124FB6153E%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: DateTimeField: Hide clock

2014-10-23 Thread jirka . vejrazka
Look at the "date" filter in template documentation, allows you to customize 
the output.

   HTH

Jirka
-Original Message-
From: Oskar Lyrstrand 
Sender: django-users@googlegroups.com
Date: Thu, 23 Oct 2014 03:28:10 
To: 
Reply-To: django-users@googlegroups.com
Subject: DateTimeField: Hide clock

models.py:
class Post(models.Model):
pub_date = models.DateTimeField

template.html:
{{ post.pub_date }}

output:
 23 october 2014 19:25

Problem is I dont want "19:25" to show. What can I do?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bd6c974f-5762-48c1-92c3-65b338345b85%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2058625486-1414064952-cardhu_decombobulator_blackberry.rim.net-197163-%40b2.c3.bise7.blackberry.
For more options, visit https://groups.google.com/d/optout.


Re: DateTimeField: Hide clock

2014-10-23 Thread Daniel Roseman
On Thursday, 23 October 2014 11:28:10 UTC+1, Oskar Lyrstrand wrote:
>
> models.py:
> class Post(models.Model):
> pub_date = models.DateTimeField
>
> template.html:
> {{ post.pub_date }}
>
> output:
>  23 october 2014 19:25
>
> Problem is I dont want "19:25" to show. What can I do?
>


Why are you using DateTimeField if you don't want the time? Why not just 
use DateField?
--
DR. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc61d3dd-24f1-44cc-9ff4-63974464222c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reverse lookup in search_fields on Admin

2014-10-23 Thread Collin Anderson
Hello,

Your code looks right. Do you have other things in search_fields?

Thanks,
Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/68450f7d-ff04-4b38-8a75-1edb0fa2a7a2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: DateTimeField: Hide clock

2014-10-23 Thread Oskar Lyrstrand
Thank you very much for that point! :D

I am fairly new to Django and Python, just followed the official doc for 
making an app and these kinds of things aren't obvious for me.
To make it more clear: I changed from DateTimeField to DateField and 
updated my browser.. (nothing).., I actually had to think for a second 
before understanding I also had to migrate this change. Now I hold my 
thumbs, hoping this won't affect anything else. You get where I'm coming 
from? :P

Thanks again!


Why are you using DateTimeField if you don't want the time? Why not just 
> use DateField?
> --
> DR. 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/55a304f1-5466-46ef-9eb6-4ad4c1b27420%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to save in inline form total sum

2014-10-23 Thread Collin Anderson
Hello,

I'm not sure what you're trying to do, but to fix the None error set 
default=0 on the total columns.

Or do something like this:
self.total_men = (self.total_men or 0) + (self.men or 0)

Thanks,
Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a9f82650-d1dd-4350-80e7-22ad491c6aa9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: getting 500 131 error on page not found

2014-10-23 Thread Collin Anderson

>
> Where are you located? How long have you been doing Django?
>
South Bend, IN, USA. I've been using Django since 2006, but just started 
posting to the mailing list recently. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c7c8139e-12f9-403f-af47-528260477d8c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Working with Google Analytics API

2014-10-23 Thread Collin Anderson
Hello,

Yes, I think that's right. Here's a deeper link:
https://developers.google.com/analytics/devguides/reporting/core/v3/gdataLibraries

I also found a python specific library here.
https://developers.google.com/api-client-library/python/apis/analytics/v3

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/414dd97f-23f5-4176-b0cf-2d39324f8e33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: no module in error log django-1.3.7

2014-10-23 Thread Collin Anderson
Hello,

I think you have 3 options:
1. Migrate to the new (django 1.5+) project layout like this:
projectname
--manage.py
--projectname
--__init__.py
--settings.py
--urls.py
--appname
--__init__.py
--admin.py
--forms.py
--models.py
--views.py
--tests.py

2. Configure your python path to include both projectname directory, and 
the directory containing projectname
https://www.pythonanywhere.com/wiki/DjangoTutorial#Existing_apps_.2F_manual_config

3. Reference everything using the projectname prefix:
'projectname.appname'  # INSTALLED_APPS
from projectname.appname.models import MyModel

Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/315aa60a-0946-44b5-8a22-f30518e33947%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Import error in settings.py

2014-10-23 Thread Collin Anderson
You can also do this:
import importlib
module_name, name = path.rsplit('.', 1)
return getattr(importlib.import_module(module_name), name)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/11e9ba53-9790-42b1-8f23-250ceda86f1f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How do I display list of pages with a ListView object?

2014-10-23 Thread Collin Anderson
Hi Daniel,

Would this work?
{% for p in page_obj.paginator.page_range %}

{% endfor %}

Collin

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


Re: Starting a procedure when opening a model in the admin interface

2014-10-23 Thread Collin Anderson
Hi Vittorio,

I've done something like this before in the get_queryset() method of 
ModelAdmin.

Thanks,
Collin

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4485e164-00e0-4c5a-8f31-2a60b734c5df%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-admin creates the views.py files in the wrong place!

2014-10-23 Thread Aliane Abdelouahab
i followed exactly by words the tutorial
http://www.tangowithdjango.com/book17/chapters/setup.html#creating-a-django-application
and it seems the problem is about creating the double directory, and when 
doing startapp it creates a directory parallel to the other one created?

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


Re: Installing django on red hat linux box

2014-10-23 Thread Thomas G Lockhart
On Oct 22, 2014, at 9:57 AM, robert brook  wrote:

> I have python 3.3.

If you are running RHEL6, python 2.6 is supported through yum etc. You will 
need to do your own installation if you want a more recent version, but afaik 
you will not need to. 2.6 is sufficient. If it were me, "good enough" would be 
good enough.

I've installed the CentOS and EPEL yum configurations on my RHEL6 boxes and one 
of those repos has virtualenv if RHEL6 does not have it (I don't have access 
atm to check).

RHEL6 is reputed to break badly if you *replace* python with a newer version, 
so you will need to preserve the 2.6 installation anyway.

If you do your own from-source python installation then you can pull that build 
into your virtualenv without difficulty.

hth

- Tom


> 
> Had to coerce red hat to do allow the install  3.3.  Must have been  a 
> stripped down version.
> version 6 came with python 2.6 installed.
> 
> Must be a stripped down version as pip does not come with python 3.3
> 
> I believe I need the package , python3.3-dev, to get the headers to utilize 
> the std   setup.py install
> 
> I am going to follow up with Red Hat.
> 
> Thanks
> 
> 
> On Wednesday, October 22, 2014 12:53:08 PM UTC-4, Pat Claffey wrote:
> Hi,
> I assume you have python installed successfully.  What version?  If you 
> install python 3.4 then pip should install automatically (unless  3.4. is a 
> second python install in which case pip does not install)
> 
> You should be able to see the python (and pip) executables in /usr/bin or 
> /usr/local/bin.  For example on my system I see python2.6 and pip installed 
> on /usr/bin (python is just a link to python2.6).  I manually installed 
> python3.4 and pip3.4.  I see these executables in /usr/local/bin.
> 
> python2.6 was pre-installed on my linux box (red hat).  I installed python3.4 
> and pip3.4 manually.
> 
> 
> 
> On Wednesday, October 22, 2014 5:12:10 PM UTC+1, robert brook wrote:
> 
> I have alot of experience installing packages on windows and mac and it goes 
> very smoothly.
> I do not have alot of experience doing the installs on a Linux box.
> 
> I am running into problems installing 4 packages.
> 
> The Lan team tried yum, but the basic django packages were not available.
> 
> Then I tried installing pip and I got proxy errors using the get-pip.py script
> 
> So I fell back to installing the dowloaded packages with the old standy  
> setup.py install which fails.
> 
> I am attaching the top of the log
> 
> Anyone have any suggestions how to proceed?
> 
> **
> running install
> 
> running bdist_egg
> 
> running egg_info
> 
> writing pyodbc.egg-info/PKG-INFO
> 
> writing top-level names to pyodbc.egg-info/top_level.txt
> 
> writing dependency_links to pyodbc.egg-info/dependency_links.txt
> 
> reading manifest file 'pyodbc.egg-info/SOURCES.txt'
> 
> reading manifest template 'MANIFEST.in'
> 
> warning: no files found matching 'tests/*'
> 
> writing manifest file 'pyodbc.egg-info/SOURCES.txt'
> 
> installing library code to build/bdist.linux-x86_64/egg
> 
> running install_lib
> 
> running build_ext
> 
> building 'pyodbc' extension
> 
> gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 
> -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic 
> -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall 
> -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector 
> --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv 
> -fPIC -DPYODBC_VERSION=3.0.7 -I/usr/include/python2.6 -c 
> /home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.cpp -o 
> build/temp.linux-x86_64-2.6/home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.o 
> -Wno-write-strings
> 
> In file included from /home/rbrook/pyodbc-3.0.7/src/pyodbcmodule.cpp:12:
> 
> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:41:20: error: Python.h: No such file 
> or directory
> 
> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:42:25: error: floatobject.h: No such 
> file or directory
> 
> /home/rbrook/pyodbc-3.0.7/src/pyodbc.h:43:24: error: longobject.h: No such 
> file or directory
> 
> *
> 
> 
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/38b5e63d-7f1b-4564-8c53-3bb99ab3020d%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googl

Importing models in app config module

2014-10-23 Thread Torsten Bronger
Hallöchen!

https://docs.djangoproject.com/en/dev/ref/applications/ says:

You cannot import models in modules that define application
configuration classes, but you can use get_model() to access a
model class by name, like this:

Does this also apply to models of other apps?  In particular, I need
import django.contrib.auth.models in my ready() method.  Importing
it seems to work.  So is this the way to go?

Tschö,
Torsten.

-- 
Torsten BrongerJabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8761faj058.fsf%40physik.rwth-aachen.de.
For more options, visit https://groups.google.com/d/optout.


Re: django-admin creates the views.py files in the wrong place!

2014-10-23 Thread Daniel Roseman
On Thursday, 23 October 2014 15:34:15 UTC+1, Aliane Abdelouahab wrote:
>
> i followed exactly by words the tutorial
>
> http://www.tangowithdjango.com/book17/chapters/setup.html#creating-a-django-application
> and it seems the problem is about creating the double directory, and when 
> doing startapp it creates a directory parallel to the other one created?
>

Sorry, I've no idea what you mean. `startproject` will create the outer 
project directory and the inner settings/urls directory, but doesn't create 
any views. `startapp` will create another directory, inside the project 
directory, containing views and models. None of these need moving anywhere.
--
DR.

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


Re: unit test: AssertionError: 302 != 200

2014-10-23 Thread kenju254
Hi Kim,

I was going through Django 1.7 and noticed that you have to force the 
redirect on this line

response = c.get('/admin/' follow=True)

Regards
Kenneth Kinyanjui



On Saturday, 21 June 2014 05:47:24 UTC+3, Kim wrote:
>
> Hi everyone, 
> I'm new to Django and am running a test. 
>
> For my admintest in tests.py, I have the following:
> --
> class AdminTest(LiveServerTestCase):
> def test_login(self):
> c = Client()
>
> response = c.get('/admin/')
> self.assertEquals(response.status_code,200)
> self.assertTrue('Log in' in response.content)
> c.login(username = 'username',password='password')
> response = c.get('/admin/')
> self.assertEquals(response.status_code,200)
> self.assertTrue('Log out' in response.content)
>
> -
> And I get this error. 
>
> -
> $ python manage.py test
> Creating test database for alias 'default'...
> .F
> ==
> FAIL: test_login (blogengine.tests.AdminTest)
> --
> Traceback (most recent call last):
>   File "/Users/Desktop/Python/1.7/src/blogengine/tests.py", line 35, in 
> test_login
> self.assertEquals(response.status_code,200)
> AssertionError: 302 != 200
>
> --
> Ran 2 tests in 0.510s
>
> FAILED (failures=1)
> Destroying test database for alias 'default'...
> -
>
> Since I checked the admin is actually working(status 200) in my localhost, 
> I thought I should give 200 status instead of 302. 
>
> Please give me some advice to fix this.
>
> Many thanks,
> Kim
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/43ec1d38-f258-42bd-ac8a-2e55fa74cbb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Reverse lookup in search_fields on Admin

2014-10-23 Thread Emanuel
Hi.

Yes, I do have another fields. And thanks a lot. I was focus on that 
particular field that I forgot to see that I had another relation in 
search_fields wich I was not  using the lookup. It works now. 

Thanks


Quinta-feira, 23 de Outubro de 2014 13:11:37 UTC+1, Collin Anderson 
escreveu:
>
> Hello,
>
> Your code looks right. Do you have other things in search_fields?
>
> Thanks,
> Collin
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2fea350b-735b-4325-af49-b0aa5b65c495%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-admin creates the views.py files in the wrong place!

2014-10-23 Thread Daniel Roseman
On Thursday, 23 October 2014 21:45:18 UTC+1, Aliane Abdelouahab wrote:
>
> Try the code like that, it will not work,
>
> now move the views.py from /rango to the initial directory where the is 
> the manage.py (/abdou) and it will work
>

Nope; that is the correct structure, as it is, with no need to move 
anything. The problem is not with the structure, but with your 
rango/urls.py: you did not follow the instructions correctly, and have 
'views.index' in quotes, rather than referring directly to the function as 
shown in section 4.5 of the Tango docs.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/1cd9e0e2-6b0e-44de-9742-0e5fba92620e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


is it possible to detect the end of the django app?

2014-10-23 Thread Michael
Hi,

How to detect that the django app is stopping?

I use some librairies that use a queue (queue.Queue) to store the data that 
will be sent in batch.
They provide a flush method to flush at the end of the program to make sure 
there’s nothing left in the queue.

But where could I call the flush method in django? 

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ddecba43-49b3-493c-ad35-83d02758f95f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django-admin creates the views.py files in the wrong place!

2014-10-23 Thread Aliane Abdelouahab
oh! sorry :D i was dumb! how can i missed this!
thank you again!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9b4a5703-bf03-487a-9d42-8a6440fcebd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: is it possible to detect the end of the django app?

2014-10-23 Thread Russell Keith-Magee
HI Michael,

There's a problem here - Web apps don't have a lifecycle like this. The
only part of the app lifecycle that can be relied upon is the
request-response cycle - someone makes a response, which will eventually be
returned as a response. Outside of that internal lifecycle, not much can be
guaranteed. A process will have to start in order to service a request (and
there are ways to hook into that), but there are no guarantees that this
process will last for 1 request, 10 or 1. And there isn't a coordinated
shutdown of the web process - the web server may choose to shut down a web
worker at any time.

If you're using a queue to perform some sort of external processing, then
that queue should be stored *outside* the web app itself. This means using
a message queue (like RabbitMQ), or a service that provides an analogous
interface (like RQ, layered over Redis). That way, a short lived web
request can push something onto the queue, and then exit immediately. The
web request doesn't need to worry about the lifecycle of the queue - it
just uses the queue as a service.

In short - you need to stop thinking of the web server as a "program" with
a startup, shutdown, and predictable lifecycle, and move to thinking about
it as "a function floating in space that can be invoked" - because, in
practice, that's what it is. If you've got anything long lived, it needs to
live outside the web process.

Yours,
Russ Magee %-)

On Fri, Oct 24, 2014 at 5:18 AM, Michael 
wrote:

> Hi,
>
> How to detect that the django app is stopping?
>
> I use some librairies that use a queue (queue.Queue) to store the data
> that will be sent in batch.
> They provide a flush method to flush at the end of the program to make
> sure there’s nothing left in the queue.
>
> But where could I call the flush method in django?
>
> 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.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ddecba43-49b3-493c-ad35-83d02758f95f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: is it possible to detect the end of the django app?

2014-10-23 Thread Michael Palumbo
Thank you Russell for your response. That confirms what I was thinking.
I am going to use a queue.

On Thu, Oct 23, 2014 at 6:10 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

> HI Michael,
>
> There's a problem here - Web apps don't have a lifecycle like this. The
> only part of the app lifecycle that can be relied upon is the
> request-response cycle - someone makes a response, which will eventually be
> returned as a response. Outside of that internal lifecycle, not much can be
> guaranteed. A process will have to start in order to service a request (and
> there are ways to hook into that), but there are no guarantees that this
> process will last for 1 request, 10 or 1. And there isn't a coordinated
> shutdown of the web process - the web server may choose to shut down a web
> worker at any time.
>
> If you're using a queue to perform some sort of external processing, then
> that queue should be stored *outside* the web app itself. This means using
> a message queue (like RabbitMQ), or a service that provides an analogous
> interface (like RQ, layered over Redis). That way, a short lived web
> request can push something onto the queue, and then exit immediately. The
> web request doesn't need to worry about the lifecycle of the queue - it
> just uses the queue as a service.
>
> In short - you need to stop thinking of the web server as a "program" with
> a startup, shutdown, and predictable lifecycle, and move to thinking about
> it as "a function floating in space that can be invoked" - because, in
> practice, that's what it is. If you've got anything long lived, it needs to
> live outside the web process.
>
> Yours,
> Russ Magee %-)
>
> On Fri, Oct 24, 2014 at 5:18 AM, Michael 
> wrote:
>
>> Hi,
>>
>> How to detect that the django app is stopping?
>>
>> I use some librairies that use a queue (queue.Queue) to store the data
>> that will be sent in batch.
>> They provide a flush method to flush at the end of the program to make
>> sure there’s nothing left in the queue.
>>
>> But where could I call the flush method in django?
>>
>> 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.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/ddecba43-49b3-493c-ad35-83d02758f95f%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> 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/R13mmDcxYRM/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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAJxq848W3m_OkRU9v29bN_AfX%3DoE_0qoh79zv_17sjQ2CSyUPg%40mail.gmail.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALa-rBwA-4Q6GXUW9gZ0kdZinStco%2B-A%2BH_fW3H5EjpOgAL9eg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: is it possible to detect the end of the django app?

2014-10-23 Thread Aliane Abdelouahab

>
> the end of user's task on an internet application can be:
>

Disconnecting: this is clear, disconnects if there is a login, and goes do 
other stuff, simply if the cookie is removed, that means his task is over.

Being idle: you detect with the cookie if there is not a big delta time 
from where he sent the request.

Closing the tab: this must be done with javascript.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f08ded66-6a21-471d-8886-28131b912468%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how to save in inline form total sum

2014-10-23 Thread carlos
Hi +Collin the idea is sum all data for example de model is
class ModelB(models.Model):
choice = models.Integerfield(choices='CHOICE_TYPE')
men = models.IntegerField()
women = models.IntegerField()

total_men = integerField(editable=False)
total_women = integerField(editable=False)

fk_model_a = fk(ModelA)

def save(self, *args, **kwargs): #this is for sum all 3 data put in
admin inlines
self.total_men += self.men
self.total_women += self.women
super(ModelB, self).save(*args, **kwargs)

in the admin look liked this:

ModelB in inline
choice   men   women
option1   6   4
option2   1   3
option3   2  1

i need save in other field total this sum for example men = 9  and women
total is = 8

for this reason i create 2 field more
 total_men = integerField(editable=False)
 total_women = integerField(editable=False)

and create the override save method
def save(self, *args, **kwargs): #this is for sum all 3 data put in admin
inlines
self.total_men += self.men
self.total_women += self.women
super(ModelB, self).save(*args, **kwargs)

but no working :(

any idea to save the sums of the inlines options

Cheers

On Thu, Oct 23, 2014 at 6:15 AM, Collin Anderson 
wrote:

> Hello,
>
> I'm not sure what you're trying to do, but to fix the None error set
> default=0 on the total columns.
>
> Or do something like this:
> self.total_men = (self.total_men or 0) + (self.men or 0)
>
> Thanks,
> Collin
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/a9f82650-d1dd-4350-80e7-22ad491c6aa9%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAM-7rO247oHNayQrW-ZF0yM75Rb3%2BQrzrSiSKtWpuyh1rGy9fA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.