Re: how can i get all values of a field

2014-05-23 Thread Lachlan Musicman
No, that wouldn't work because Category looks like a var on Novel, not
a model in it's own right.

Novels.objects.filter(category="comedy") is how to get a distinct category.

To get the list of categories used, use distinct for a quick hack -
something like:

Novel.objects.order_by('category').distinct('category')

Cheers
L.

On 24 May 2014 12:33, Jonathan Querubina  wrote:
> Hi dota and java,
>
> If your model for the categories is Category, you would use:
>
> Category.objects.all()
>
> Sent from my iPad
>
> On May 23, 2014, at 23:23, dotaandj...@gmail.com wrote:
>
> i can't find a more effective method from the documentation,but thank you
> all the same
>
> 在 2014年5月23日星期五UTC+8下午11时12分13秒,sacrac写道:
>>
>> Hi, you read the documentation?
>> https://docs.djangoproject.com/en/1.6/ref/models/querysets/
>>
>>
>> On Fri, May 23, 2014 at 6:36 AM,  wrote:
>>>
>>> In Models i declare Novel: name,category
>>> table structure:
>>> ---
>>> id|   name   |category
>>> ---
>>>
>>>
>>> now i want to get all category,but i have no idea,who can help me?
>>>
>>> my english is poor,please don't joke me
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/27a36b70-7f89-4a02-97d5-a5e27789068e%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/17e7d1fb-b004-4141-b30b-7578fcf72c2e%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/4800DB60-6DD7-43A1-9B1F-2E518C56242F%40gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
The idea of anathematising all of a person’s good works because of
something else they said or did is just as alien and repellent to us
as our reaction is to someone who wishes Hacker News would die because
Paul Graham is kind of a dick sometimes. ... Sergey Bratus points out
that keeping works by “ideologically impure” persons out of public
view was instrumental to Soviet systems of social control. And as
@puellavulnerata acutely observes, a culture that encourages judging
people unilaterally, rather than judging their actions in context, is
one that allows socially-adept hierarchy climbers to decontextualise
their own self-serving cruelties as “necessary for the cause” and
stage witchcraft trials against the weirdoes on the margin.
---
https://medium.com/p/31895b01e68c

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


Re: how can i get all values of a field

2014-05-23 Thread Jonathan Querubina
Hi dota and java,

If your model for the categories is Category, you would use:

Category.objects.all()

Sent from my iPad

> On May 23, 2014, at 23:23, dotaandj...@gmail.com wrote:
> 
> i can't find a more effective method from the documentation,but thank you all 
> the same
> 
> 在 2014年5月23日星期五UTC+8下午11时12分13秒,sacrac写道:
>> 
>> Hi, you read the documentation? 
>> https://docs.djangoproject.com/en/1.6/ref/models/querysets/
>> 
>> 
>>> On Fri, May 23, 2014 at 6:36 AM,  wrote:
>>> In Models i declare Novel: name,category
>>> table structure:
>>> ---
>>> id|   name   |category
>>> ---
>>> 
>>> 
>>> now i want to get all category,but i have no idea,who can help me?
>>> 
>>> my english is poor,please don't joke me
>>> -- 
>>> You received this message because you are subscribed to the Google Groups 
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an 
>>> email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/27a36b70-7f89-4a02-97d5-a5e27789068e%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/17e7d1fb-b004-4141-b30b-7578fcf72c2e%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/4800DB60-6DD7-43A1-9B1F-2E518C56242F%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how can i get all values of a field

2014-05-23 Thread dotaandjava
i can't find a more effective method from the documentation,but thank you 
all the same

在 2014年5月23日星期五UTC+8下午11时12分13秒,sacrac写道:
>
> Hi, you read the documentation? 
> https://docs.djangoproject.com/en/1.6/ref/models/querysets/
>
>
> On Fri, May 23, 2014 at 6:36 AM, > wrote:
>
>> In Models i declare Novel: name,category
>> table structure:
>> ---
>> id|   name   |category
>> ---
>>
>>
>> now i want to get all category,but i have no idea,who can help me?
>>
>> my english is poor,please don't joke me
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com
>> .
>> Visit this group at http://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/27a36b70-7f89-4a02-97d5-a5e27789068e%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/17e7d1fb-b004-4141-b30b-7578fcf72c2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial to deploy (with install instructions) = django+gunicorn+nginx

2014-05-23 Thread Rob Skidmore
Glad I could help.


On Fri, May 23, 2014 at 3:49 PM, Jonathan Querubina
wrote:

> I have tryied a lot of them, and this one was the salvation
>
>
> http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
>
> Thanks Rob!
>
> On May 23, 2014, at 12:17 PM, carlos  wrote:
>
> Hi, Digital Ocean have many tutorial
> begginner :
> https://www.digitalocean.com/community/articles/how-to-deploy-a-local-django-app-to-a-vps
> advanced:
> https://www.digitalocean.com/community/articles/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
>
> Cheers
>
>
> On Fri, May 23, 2014 at 8:04 AM, Rob Skidmore wrote:
>
>> Found this after a digging for a bit. Might help.
>>
>>
>> http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
>>
>>
>> On Friday, May 23, 2014 4:36:23 AM UTC-6, Jonathan Querubina wrote:
>>
>>> Hi guys, i am on my first deploy and loosing my hair over this.
>>>
>>> Could anyone send me a tutorial on how to make this deploy?
>>>
>>> I am on DigitalOcean, but their tutorial doesnt work, even if i use all
>>> the same configuration, virtualenv names and so on…
>>>
>>> Thanks guys!
>>>
>>>
>> --
>> 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/050612a2-c67b-4835-8a04-7bcd269b831d%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-7rO2fS-de9uxjg2rbQ2JqmCBuUmyzG8pmZ%3D5sw4uX%2BxGReQ%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/AAmQ0pOmPIw/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/27FD68FB-B805-47C8-A793-5C8548E7C297%40gmail.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/CAOXgxfght4tjRy81kR2TmvMYyrPmA9dC2%3DyUwfdgugL5ut%3Dr5A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial to deploy (with install instructions) = django+gunicorn+nginx

2014-05-23 Thread Jonathan Querubina
I have tryied a lot of them, and this one was the salvation

http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/

Thanks Rob!

On May 23, 2014, at 12:17 PM, carlos  wrote:

> Hi, Digital Ocean have many tutorial 
> begginner : 
> https://www.digitalocean.com/community/articles/how-to-deploy-a-local-django-app-to-a-vps
> advanced: 
> https://www.digitalocean.com/community/articles/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
> 
> Cheers
> 
> 
> On Fri, May 23, 2014 at 8:04 AM, Rob Skidmore  wrote:
> Found this after a digging for a bit. Might help.
> 
> http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
> 
> 
> On Friday, May 23, 2014 4:36:23 AM UTC-6, Jonathan Querubina wrote:
> Hi guys, i am on my first deploy and loosing my hair over this. 
> 
> Could anyone send me a tutorial on how to make this deploy? 
> 
> I am on DigitalOcean, but their tutorial doesnt work, even if i use all the 
> same configuration, virtualenv names and so on... 
> 
> Thanks guys! 
> 
> 
> -- 
> 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/050612a2-c67b-4835-8a04-7bcd269b831d%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-7rO2fS-de9uxjg2rbQ2JqmCBuUmyzG8pmZ%3D5sw4uX%2BxGReQ%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/27FD68FB-B805-47C8-A793-5C8548E7C297%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Building and firing a web page as an action under admin

2014-05-23 Thread Victor
Django 1.6.4
I've built an application to manage a medical warehouse resorting exclusively 
to the admin interface and postgresql 9.3.
To put it in a nutshell, among other things I have an admin form using inlines 
that for each patient lists the medical items he/she has been given and the 
date of the delivery.
For a mere matter of control they would like to print (I mean to a printer) a 
concise report selecting the patients they are interested in and clicking on 
the "actions" field to, say, "Print a report". 
I use actions for other purposes with success and I can build views and the 
related url but now I don't know how to fire a webpage built with the selected 
item. 
Could you please give me some directions and suggestions?
Thank you
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/C895CD07-E52D-40F8-9CB5-EE4C9B05F9B0%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Tutorial to deploy (with install instructions) = django+gunicorn+nginx

2014-05-23 Thread carlos
Hi, Digital Ocean have many tutorial
begginner :
https://www.digitalocean.com/community/articles/how-to-deploy-a-local-django-app-to-a-vps
advanced:
https://www.digitalocean.com/community/articles/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn

Cheers


On Fri, May 23, 2014 at 8:04 AM, Rob Skidmore wrote:

> Found this after a digging for a bit. Might help.
>
>
> http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/
>
>
> On Friday, May 23, 2014 4:36:23 AM UTC-6, Jonathan Querubina wrote:
>
>> Hi guys, i am on my first deploy and loosing my hair over this.
>>
>> Could anyone send me a tutorial on how to make this deploy?
>>
>> I am on DigitalOcean, but their tutorial doesnt work, even if i use all
>> the same configuration, virtualenv names and so on…
>>
>> Thanks guys!
>>
>>  --
> 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/050612a2-c67b-4835-8a04-7bcd269b831d%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-7rO2fS-de9uxjg2rbQ2JqmCBuUmyzG8pmZ%3D5sw4uX%2BxGReQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: how can i get all values of a field

2014-05-23 Thread carlos
Hi, you read the documentation?
https://docs.djangoproject.com/en/1.6/ref/models/querysets/


On Fri, May 23, 2014 at 6:36 AM,  wrote:

> In Models i declare Novel: name,category
> table structure:
> ---
> id|   name   |category
> ---
>
>
> now i want to get all category,but i have no idea,who can help me?
>
> my english is poor,please don't joke me
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To 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/27a36b70-7f89-4a02-97d5-a5e27789068e%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-7rO3MNEVpL-o7VyyPzt2nFeVeT4O%3D_VFW71D9OWCwvw20zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Sass and Sass Libraries with Django-Pipeline

2014-05-23 Thread Cal Leeming [Simplicity Media Ltd]
On Fri, May 23, 2014 at 5:25 AM, Wellington Cordeiro
wrote:

> Cal,
>
> I don't have it installed in my static folder, I have the gem installed
> and I was under the impression that Sass could find the installed
> libraries, which I guess I was mistaken.
>
> What would be your recommended tool? Django-Pipeline or Compressor? Or
> maybe another?
>

I'll be honest, I'm yet to find an asset pipeline that suited every use
case.

I've used django-pipeline in the majority of cases, but have also used a
custom pipeline tools (such as gulp.js and one off Python scripts) for more
complex requirements, such as compiling AS3 files as part of the pipeline.

If you find any better alternative to pipeline, let me know :)


> I was trying Compressor at first and had the same issue and thought it
> might have been related to the way it handled Sass. I have the newest
> version of Node installed on my vagrant environment but I'm considering
> taking a look into nodeenv. I'm trying to use three libraries in particular
> Bourbon, Compass and Breakpoint with Django (and I've heard of Neat and
> chose to use Jeet[1] instead.)
>
> Thanks for the help,
>
> Wellington
>
>
> On Thursday, May 22, 2014 8:08:42 AM UTC-6, Cal Leeming [Simplicity Media
> Ltd] wrote:
>
>> Hi Willy,
>>
>> Do you have Bourbon installed in your static folder? If not, you'll need
>> to install the bourbon/compass/sass node packages (see below), or you can
>> download a precompiled dist from the source of each, for example see [1].
>>
>> If you go down the node packages route, be aware, not even the latest
>> bleeding edge version of Ubuntu will allow to use the most up to date
>> bourbon/compass/sass node packages. You will almost certainly want to use a
>> local node install, either through a tool such as nodeenv [2] which re-uses
>> your existing virtualenv, or manually patch your .bashrc to use a locally
>> installed node binary [3].
>>
>> It's also worth mentioning that although django-pipeline is quite
>> awesome, it can also be quite limited.
>>
>> One last thing, check out Bourbon Neat [4].
>>
>> Hope this helps
>>
>> Cal
>>
>> [1] https://github.com/thoughtbot/bourbon/tree/master/dist
>> [2] https://github.com/ekalinin/nodeenv
>> [3] https://github.com/creationix/nvm
>> [4] http://neat.bourbon.io/
>>
>>
>>
>> On Thu, May 22, 2014 at 7:29 AM, Willy  wrote:
>>
>>> I'm trying to use Sass and Sass Libraries with Django-Pipeline but my
>>> @import directives always error out saying they can't find the libraries I
>>> have installed.
>>>
>>> Here is my settings file https://gist.github.com/43b0e4d5c93b943d9760
>>>
>>> Then I have my scss file trying to do
>>>
>>> @import 'bourbon';
>>> @import 'compass';
>>> @import 'breakpoint';
>>>
>>> and it will fail showing this error. https://gist.github.com/
>>> 28e617581fa198a8690d
>>>
>>> Has anyone setup a Django project that's been able to properly import
>>> Sass libraries and if so how would you best do 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>>
>>> Visit this group at http://groups.google.com/group/django-users.
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/django-users/a7fa8151-f216-4e2c-9b23-2f5628a63e8a%
>>> 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/335c90d4-d8ca-4d26-b0b7-255ae73b1d22%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/CAHKQagEX56MNsYscyei-JQ5k%3D45AvzyrECJ78JjzpGxPmB8_rg%40mail.gmail.com.
For more options, visit https

Re: Tutorial to deploy (with install instructions) = django+gunicorn+nginx

2014-05-23 Thread Rob Skidmore
Found this after a digging for a bit. Might help.

http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/

On Friday, May 23, 2014 4:36:23 AM UTC-6, Jonathan Querubina wrote:
>
> Hi guys, i am on my first deploy and loosing my hair over this. 
>
> Could anyone send me a tutorial on how to make this deploy? 
>
> I am on DigitalOcean, but their tutorial doesnt work, even if i use all 
> the same configuration, virtualenv names and so on… 
>
> Thanks guys! 
>
>

-- 
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/050612a2-c67b-4835-8a04-7bcd269b831d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Model Objects and Updating db via XML

2014-05-23 Thread Amirouche Boubekki
Héllo (again),


2014-05-14 22:41 GMT+02:00 Sayth Renshaw :

> Thanks Tom, I have set up a way to extract the elements I want with
> xmltodict and played with lxml.objectify last night and that would work as
> well.
>
> But what exactly in django models am I using to bring in the data?
>

Django knows how to load data from json, xml, whatnot only if it knows
about the format. I don't remember
we considered Django native serialization/unserialization support (see my
mail on Python ML).

The thing is that, in your project, it seems like import is a "one time
thing". So maybe using a framework thingy like django-swallow or a custom
django's fixture thing is too much.

Anyway, here is the "getting started" document of django
swallow,
summed up below:

- Builder class: entry point for an import, this used among other thing to
trigger the import from command line.
- Mapper class: create "mapping object" for the input xml. Basically it
breaks down a xml into sub-documents (if it's rss/atom like xml) or a
single object if it's actually only one document, pythonize the xml data
and make it easily accessible as object properties... no heavy processing
of data or mapping to data already in the database. For instance, if you
have an identifier, that maps to a row in the database, you retrieve the
populator (see below) will retrieve the identifier as an integer or string
and convert it to a Django model...
- Populator class: it helps populating the target django model object. It
implements common operations, like «model.foo = mapper.foo» and other stuff.

The idea behind django swallow, is that an import is breaked down into
several steps:

- parse xml, and turn in into simple python object(s) with python types
(Mapper class)
- populate one django model instance (or several) with based on the data
from the first step (Populator class)

They are extra optional steps ;)

I'm not sure about what is the repository, but for instance you can create
a base mapper, which will populate a plain python objects from xpath and
then the populator can be as simple as:

class Populator(BasePopulator):


_fields_one_to_one = None  # XXX: in this case None means map
every properties of the mapper object to the model fields with the
same name...
_fields_if_instance_already_exists = None
_fields_if_instance_modified_from_last_import = None



It's may seem kind of overkill. But when you have 5+ imports running
everyday, business critical, processing several dozen of files, for
different kind of documents it's helpful to know that the implementation is
built in a canvas, a framework, you know where to look for the code
implementing a behaviour depending on the behaviour... whether it is for
debugging or building new imports...

There is a full but simple example, importing items from an atom file:
https://github.com/liberation/django-swallow/blob/master/example/config.py

HTH,


Amirouche


> Sayth
> On 15/05/2014 1:13 am, "Tom Evans"  wrote:
>
>> On Tue, May 13, 2014 at 8:40 PM, Sayth Renshaw 
>> wrote:
>> > Can I ask for some assistance please.
>> >
>> > For my project I will need to upate the database from an external xml
>> file
>> > consistently. The xml is like this one
>> > http://old.racingnsw.com.au/Site/_content/racebooks/20140515GOSF0.xml
>> > If i have create my model objects, most of which will have a direct
>> > correlation to the xml file, but there will be extra model objects and
>> > fields relating to user input. How can I do updates to my database via
>> xml.
>> >
>> > There are 2 docs I have been reviewing
>> >
>> https://docs.djangoproject.com/en/1.6/howto/initial-data/#providing-initial-data-with-fixtures
>> > and https://docs.djangoproject.com/en/1.6/topics/serialization/.
>> >
>> > The guides talk about creating a fixture but I am not sure it is
>> appropriate
>> > exactly and I am unsure from the guide how I would setup a mapping so
>> that
>> > the xml data went to the correct model object.
>> > How do I do this?
>> >
>>
>> I don't think you want fixtures, even though there are XML fixtures.
>> This is basically a data feed which periodically you wish to import in
>> to your own database. Fixtures are normally exports of your own
>> database. I think it would be very difficult to ensure that your
>> database always matches the contents of an XML file produced by a 3rd
>> party.
>>
>> You could use xslt to transform the 3rd party xml in to the right
>> format for an xml serialisation, but that would involve using xslt.
>>
>> What I would do is write a management command that parses the XML (I
>> like lxml), and then iterates through it, using xpath to pull out
>> relevant parts of the doc, and then use standard django models to
>> create this data in the database, taking care not to insert duplicate
>> data when it exists in both DB and XML.
>>
>> Cheers
>>
>> Tom
>>
>> --
>> You received this message be

Re: int() argument must be a string or a number, not 'datetime.date'

2014-05-23 Thread MikeKJ

*D'oh*  needed to reference back to the date model as in

qs = 
Booking.objects.filter(arrival_date__travel_date__exact=form.cleaned_data['arrival_date'])

arrival_date is a int id reference!!!

sorry and thanks to anyone who was looking at this

-- 
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/b979916c-072a-4bad-bdbb-91dcf29c723a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to find list of blocking issues for django releases?

2014-05-23 Thread Lorenzo Peña
https://code.djangoproject.com/query?status=!closed&severity=Release%20blocker&group=component

-- 
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/022832d7-7af2-43dd-899c-743d5cc18c38%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how can i get all values of a field

2014-05-23 Thread dotaandjava
In Models i declare Novel: name,category
table structure:
---
id|   name   |category
---


now i want to get all category,but i have no idea,who can help me?

my english is poor,please don't joke me

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/27a36b70-7f89-4a02-97d5-a5e27789068e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to find list of blocking issues for django releases?

2014-05-23 Thread Ryan Osborn
How can I go about finding a list of the issues that are blocking a djago 
release?

-- 
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/01eb499e-407d-494f-80f6-061cb7035931%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Dynamically updating field with JQuery

2014-05-23 Thread Jason S
Hi,
I'm sure this has been discussed to death, however the examples i've seen 
involve 3rd party django apps or are very complicated and I haven't been 
able to find a clear example which.I can repurpose.
I'm new to development so am building up a Django website to help grow my 
skills, but have a long way to go and its tough picking up Django, Python 
and JQuery at once.

I would like to show a simple form based off a model, where some fields are 
hidden.
The form includes a category and subcategory field. There is a one to many 
relationship between the fields.
I would like to dynamically update the form to either:

   - Show the hidden "subcategory" field, populated with the queryset based 
   on the selected category.
   - Just populate the subcategory field with a populated queryset based on 
   the selected category

If someone could give a quick example on using JQuery to achieve the above 
it'd be very helpful.
Thanks for any help you can spare.
J

-- 
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/e18db9f3-5bdc-4286-85a7-961e95b7aa0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Tutorial to deploy (with install instructions) = django+gunicorn+nginx

2014-05-23 Thread Jonathan Querubina
Hi guys, i am on my first deploy and loosing my hair over this.

Could anyone send me a tutorial on how to make this deploy?

I am on DigitalOcean, but their tutorial doesnt work, even if i use all the 
same configuration, virtualenv names and so on...

Thanks guys!

-- 
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/1AEC575B-8FDF-4CB2-8F36-27B9054F61AD%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


ImportError: No module named django.core.wsgi

2014-05-23 Thread Satinderpal Singh
ImportError: No module named django.core.wsgi

I am facing the above error while deploying Django with Apache.

Here is my Apacahe conf file contents:


ServerAdmin webmaster@localhost


WSGIPythonPath
/home/user/site:/home/user/.virtualenvs/test/lib/python2.7/site-packages


Options Indexes
Order deny,allow
Allow from all


WSGIPythonHome /home/user/.virtualenvs/test
WSGIScriptAlias /site /home/user/site/site/wsgi.py


Order deny,allow
Allow from all



Alias /static/ /home/user/site/static/

Options -Indexes




and wsgi.py file

import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "site.settings")

from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()


Please help me to resolve the error.

-- 
Satinderpal Singh

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


Django 1.6.4 debug-toolbar confusing error

2014-05-23 Thread Florian Auer
Hi

I am running 2 django 1.6.4 projects, both with debug toolbar enabled.

The first one ist a simple project, following the a cookbook tutorial and 
the toolbar works fine inside.
The second project ist the one, I'll wnated to start the real development 
in.

But there every call to the most panels give me a 500 error:
Internal Server Error: /__debug__/render_panel/
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\django\core\handlers\base.py", line 
114, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "C:\Python33\lib\site-packages\debug_toolbar\views.py", line 19, in 
render_panel
content = panel.content
  File "C:\Python33\lib\site-packages\debug_toolbar\panels\__init__.py", 
line 87, in content
return render_to_string(self.template, self.get_stats())
  File "C:\Python33\lib\site-packages\django\template\loader.py", line 162, 
in render_to_string
t = get_template(template_name)
  File "C:\Python33\lib\site-packages\django\template\loader.py", line 138, 
in get_template
template, origin = find_template(template_name)
  File "C:\Python33\lib\site-packages\django\template\loader.py", line 127, 
in find_template
source, display_name = loader(name, dirs)
  File "C:\Python33\lib\site-packages\django\template\loader.py", line 43, 
in __call__
return self.load_template(template_name, template_dirs)
  File "C:\Python33\lib\site-packages\django\template\loader.py", line 49, 
in load_template
template = get_template_from_string(source, origin, template_name)
  File "C:\Python33\lib\site-packages\django\template\loader.py", line 149, 
in get_template_from_string
return Template(source, origin, name)
  File 
"C:\Python33\lib\site-packages\debug_toolbar\panels\templates\panel.py", 
line 71, in new_template_init
old_template_init(self, template_string, origin, name)
  File "C:\Python33\lib\site-packages\django\template\base.py", line 125, 
in __init__
self.nodelist = compile_string(template_string, origin)
  File "C:\Python33\lib\site-packages\django\template\base.py", line 153, 
in compile_string
return parser.parse()
  File "C:\Python33\lib\site-packages\django\template\base.py", line 278, 
in parse
compiled_result = compile_func(self, token)
  File "C:\Python33\lib\site-packages\django\template\defaulttags.py", line 
806, in do_for
nodelist_loop = parser.parse(('empty', 'endfor',))
  File "C:\Python33\lib\site-packages\django\template\base.py", line 278, 
in parse
compiled_result = compile_func(self, token)
  File "C:\Python33\lib\site-packages\django\template\defaulttags.py", line 
573, in cycle
PendingDeprecationWarning, stacklevel=2)
PendingDeprecationWarning: 'The `cycle` template tag is changing to escape 
its arguments; the non-autoescaping version is deprecated. Load it from the 
`future` tag library to start using the new behavior.
[23/May/2014 11:59:50] "GET 
/__debug__/render_panel/?store_id=e6eeea46ebc04510bf489db8336adf0f&panel_id=SettingsPanel
 
HTTP/1.1" 500 14196

the main difference is with this project, that it has a template 
dependency, using a mysql connector instead of sqlite.
>From my point of view I dont knwo whats the problem.

settings.py:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
SECRET_KEY = 'xxx'
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['127.0.0.1']
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'cockpit',
)

MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
#START addition for DEBUG-TOOLBAR
INSTALLED_APPS += (
'debug_toolbar',
)
MIDDLEWARE_CLASSES += (
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
INTERNAL_IPS = ('127.0.0.1',)
#DEBUG_TOOLBAR_CONFIG = {'INTERCEPT_REDIRECTS': False} #deprecated
#END addition for DEBUG-TOOLBAR

#START addition or userauth app
INSTALLED_APPS += (
'userauth',
)

#START Mobile Detection -> based on mobileESP
MIDDLEWARE_CLASSES += (
'mobileesp.middleware.MobileDetectionMiddleware',
)
#END Mobile Detection

ROOT_URLCONF = 'myProjectName.urls'
WSGI_APPLICATION = 'myProjectName.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'mysql.connector.django',
'NAME': 'myProjectName',
'USER': 'root',
'PASSWORD': 'x',
'HOST': '127.0.0.1',
'PORT': '3306'

Re: int() argument must be a string or a number, not 'datetime.date'

2014-05-23 Thread MikeKJ
Ummm do I need to use Q? just dawned on me

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To 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/d2a6a7ca-fa02-4a54-b895-420f6637d826%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


int() argument must be a string or a number, not 'datetime.date'

2014-05-23 Thread MikeKJ

According to me in the qs line I am looking at, for example, results from 
Booking where 2014-07-17 equals 2014-07-17 as in date field comparison I 
dont even see where an int() argument comes into it

dl_reports.py

class SelectDate(forms.Form):
def __init__(self, *args, **kwargs):
super(SelectDate, self).__init__(*args, **kwargs)
arrival_date = forms.DateField(required=False, 
input_formats=('%d/%m/%Y',), help_text='Enter a date in the format 
DD/MM/')
departure_date = forms.DateField(required=False, 
input_formats=('%d/%m/%Y',), help_text='Enter a date in the format 
DD/MM/')


@staff_member_required
@never_cache
def travel_by_date_report(request, fields=None):
form = SelectDate()
arrival_date = ''
departure_date = ''
if request.GET:
form = SelectDate(request.GET)
if form.is_valid():
if form.cleaned_data.has_key('arrival_date') and 
form.cleaned_data['arrival_date'] != '':
qs = 
Booking.objects.filter(arrival_date=form.cleaned_data['arrival_date'])
//this is line 33
..etc


Booking model:

class Dates(models.Model):
day = models.CharField(choices=DAY_CHOICES, max_length=12)
travel_date = models.DateField()

class Booking(models.Model):
name = models.CharField(max_length=150)
email = models.EmailField()
telephone_mobile = models.CharField(max_length=30, blank=True, 
null=True)
arrival = models.ForeignKey(ArrivalLocations, null=True, blank=True)
arrival_date = models.ForeignKey(Dates, related_name="Date of Arrival", 
blank=True, null=True)


Traceback:
Traceback:
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/core/handlers/base.py" 
in get_response
  111. response = callback(request, *callback_args, 
**callback_kwargs)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/contrib/admin/views/decorators.py"
 
in _checklogin
  19. return view_func(request, *args, **kwargs)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/views/decorators/cache.py" 
in _wrapped_view_func
  79. response = view_func(request, *args, **kwargs)
File "/home/paston2/webapps/latitude/latitude/dl_reports.py" in 
travel_by_date_report
  33. qs = 
Booking.objects.filter(arrival_date__gte=form.cleaned_data['arrival_date']).filter(arrival_date__lte=form.cleaned_data['arrival_date'])
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/manager.py" 
in filter
  141. return self.get_query_set().filter(*args, **kwargs)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/query.py" in 
filter
  550. return self._filter_or_exclude(False, *args, **kwargs)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/query.py" in 
_filter_or_exclude
  568. clone.query.add_q(Q(*args, **kwargs))
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/sql/query.py" 
in add_q
  1194. can_reuse=used_aliases, 
force_having=force_having)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/sql/query.py" 
in add_filter
  1129. connector)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/sql/where.py" 
in add
  67. value = obj.prepare(lookup_type, value)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/sql/where.py" 
in prepare
  316. return self.field.get_prep_lookup(lookup_type, value)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/fields/related.py"
 
in get_prep_lookup
  136. return self._pk_trace(value, 'get_prep_lookup', 
lookup_type)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/fields/related.py"
 
in _pk_trace
  209. v = getattr(field, prep_func)(lookup_type, v, **kwargs)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/fields/__init__.py"
 
in get_prep_lookup
  292. return self.get_prep_value(value)
File 
"/home/paston2/webapps/latitude/lib/python2.7/django/db/models/fields/__init__.py"
 
in get_prep_value
  479. return int(value)

Exception Type: TypeError at /dailyreport/
Exception Value: int() argument must be a string or a number, not 
'datetime.date'

-- 
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/c0b86df1-5034-4df8-b7a2-9a680bedfd80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Why Django Apps Suck

2014-05-23 Thread Delusional Insanity
I've seen enough great reusable packages for Django.

I've also seen a lot of really bad packages and even have been forced to 
use bad apps in production, that you should really either fork or hack in a 
very strange way.

Some awesome packages:

- South https://pypi.python.org/pypi/South
- django-piston https://pypi.python.org/pypi/django-piston
- django-reversion https://pypi.python.org/pypi/django-reversion
- sentry https://pypi.python.org/pypi/sentry
- django-dbtemplates https://pypi.python.org/pypi/django-dbtemplates

Some of my own that in my concern are great and reusable:

- django-dash https://pypi.python.org/pypi/django-dash
- ska (see the contrib package for password-less authentication into 
Django) https://pypi.python.org/pypi/ska

It's just a matter of making the app reusable and flexible enough to adapt 
modifications.

On Tuesday, 21 September 2010 22:26:36 UTC+2, Klaas van Schelven wrote:
>
> Ok here it goes: I don't have a proper platform for my observations / 
> rants so I figured I'd try my luck here. Django has been my favorite 
> framework for developing web applications for about a year and a half, 
> so it comes from a position of love when I say that the Django app 
> really sucks as a level of abstraction. And I'm really looking for a 
> way out so any suggestions are much appreciated. A tl;dr is provided 
> below. 
>
> Others have complained before me. Two particular ones worth mentioning 
> are: 
> http://www.scribd.com/doc/37113340/Why-Django-Sucks-and-How-we-Can-Fix-it 
> which claims that "Apps which provide models are inflexible" and 
>
> http://www.mutualinformation.org/2010/03/why-i-switched-to-pylons-after-using-django-for-six-months/
>  
> Both claim that the Django app provides the wrong level of 
> abstraction, neither goes in too much detail exactly why that is the 
> case. That's the question I'll attempt to answer. 
>
> Before we can answer the question we must first set some reasonable 
> expectations for an "app". I'd say an app is a small package of 
> closely related features as they are presented to the user (in the 
> context of a web project) that can be easily modified/extended for any 
> given project. 
>
> Examples of apps (in my own particular context): 
> * Dealing with customer information (a mini CRM). Adding, editing, 
> useful overviews. 
> * A small news app (Add, edit, overviews) 
> * Our own particular UserProfile app (editing, viewing others, 
> birthday calendars etc.) 
> * A small budgetting tool (creating budgets, see how much money has 
> been used) 
> * Logging time lines (for worked hours), searching them. 
>
> I choose this definition for "app" because it is a very useful one in 
> the context of web projects. At least in my context it works like 
> this: we have a lot of customers with similar intranets and extranets. 
> Each one of them might want a particular subset of the various apps we 
> have "on the shelf". 
>
> By the way: there's other things that can already be reused quite 
> well. Anything pure python for example. Or extensions to Django (extra 
> fields, extra context managers, middleware etc etc.) This is not my 
> concern, mainly because it already works well. 
>
> One thing that deserves extra stress is that apss should be easily 
> extendable. Exactly the fact that every customer want something that 
> is slightly different from the next is how we're able to provide 
> value. (This is also the reason I like Django in the first place: 
> making stuff "your own way" is very easy). So: if no one want exactly 
> the same, extensibility is a major prerequisite for reusability. 
>
> What are some typical things we want to do when extending (modifying) 
> an app for the context of a particular project? 
> * Deal with authorization in the context of the particular django 
> project 
> * Styling for the project 
> * Turn a subset of the functionality on or off for a given project (no 
> docs, no 'advanced features') 
> * Add one or more fields to one or more models and possibly related 
> edit pages, view pages forms etc 
>
> Given this control flow let's try to do some of the typical 
> modifications mentioned above: 
> Authorization: 
> Django has a beautiful mechanism for authorization, which is using 
> decorators (@may_do_a_b_or_c) directly in the views.py. 
> Tempting, but will not be modifyable in any way once you lift the app. 
> (because the decorator will become tied to the view function). Other 
> mechanisms are not presented (in a standardized way). If anyone has 
> ideas about this I'd love to discuss them. 
>
> Styling: 
> This actually works well, by providing sufficient amount of hooks in 
> the templates and extending. 
>
> Turning functionality on and off: 
> This could be made to work by working with a 'url_parts.py' in the 
> reusable app, that provides different url_patterns for the various 
> subsets. So one for the CRUD, one for the docs, one for the simple 
> features and one for the advanced features. Our

Re: URL lookup fails in apache/wsgi unless mapped to server root.

2014-05-23 Thread Spaceman Paul
In case anyone else ends up with same problem, I was using request.path 
instead of request.path_info.

P.

On Friday, 23 May 2014 14:58:11 UTC+10, Spaceman Paul wrote:
>
> Playing around some more, and inserting some trace statements in the 
> django code, I can see
> (for the example ^times$ pattern):
>
> 1) When WSGIScriptAlias is the server root:
>
> The RegexURLResolver.resolve(self,path) method (in 
> django.core.urlresolvers.py) is called three times,
> each time with path="/times" and each time it successfully resolves at the 
> "^times$" pattern.
>
> 2) When WSGIScriptAlias is not server root (i.e. /awma):
>
> The RegexURLResolver.resolve(self,path) method (in 
> django.core.urlresolvers.py) is called four times:
>
> a) The first two times it is called with path="/times" and successfully 
> resolves at the "^times$" pattern.
> b) The third time it is called with path="/awma/times" - not surprisingly 
> it does not resolve.
> c) The fourth time is is called with path="awma/times" - this fails too.
>
> It looks like the fourth call is made from within the third call - it's 
> the call for the admin url include.
>
> Overall result is a 404.
>
> This is looking at the 2.4.13 codebase - although the method is basically 
> the same in 2.6.5 and I
> see the same behaviour there.
>
> Is this a bug?  Surely I can't be the only person using WSGI with a 
> non-root mount point.
>
> P. 
>
> On Friday, 23 May 2014 01:25:03 UTC+1, Spaceman Paul wrote:
>>
>> I've worked around it by creating another A-record and pointing each 
>> application to the server root of the respective 
>> virtual host, but this should not be necessary.
>>
>> On Thursday, 22 May 2014 23:50:57 UTC+1, Spaceman Paul wrote:
>>>
>>> Nothing in wsgi.conf.
>>>
>>> Relevant bits of apache conf:
>>>
>>> 
>>> 
>>> WSGIScriptAlias /awma 
>>> /home/paul/src/awma-apache/internationalguidelines/wsgi.py
>>> 
>>> 
>>>
>>> Nothing in /var/log/apache2/error.log
>>>
>>> Access.log just says:
>>>
>>> 152.91.9.9 - - [23/May/2014:08:27:17 +1000] "GET /awma/ HTTP/1.1" 404 
>>> 1476 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>> 152.91.9.9 - - [23/May/2014:08:27:22 +1000] "GET /awma/times HTTP/1.1" 
>>> 404 1483 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>>
>>> 404 debug pages like:
>>>
>>> Using the URLconf defined in internationalguidelines.urls, Django tried 
>>> these URL patterns, in this order:
>>>
>>>   1.  ^$ [name='index']
>>>   2.  ^times$ [name='times']
>>>   3.  ^admin/
>>>
>>> The current URL, times, didn't match any of these.
>>>
>>> AND: The current URL, , didn't match any of these
>>>
>>> Although weirdly, admin works:
>>>
>>> 152.91.9.9 - - [23/May/2014:08:28:19 +1000] "GET /awma/admin/ HTTP/1.1" 
>>> 200 1450 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>>
>>> But when I change the WSGIScriptAlias to:
>>>
>>>  WSGIScriptAlias / 
>>> /home/paul/src/awma-apache/internationalguidelines/wsgi.py
>>>
>>> Everything works fine:
>>>
>>> 152.91.9.9 - - [23/May/2014:08:37:22 +1000] "GET / HTTP/1.1" 200 1156 
>>> "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>> 152.91.9.9 - - [23/May/2014:08:37:27 +1000] "GET /times HTTP/1.1" 200 
>>> 1550 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>> 152.91.9.9 - - [23/May/2014:08:37:39 +1000] "GET /admin/ HTTP/1.1" 200 
>>> 1446 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>>
>>> WSGI file contains nothing unusual:
>>>
>>> import os
>>> import sys
>>>
>>> sys.path.append('/home/paul/src/awma-apache/')
>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
>>> "internationalguidelines.settings_prod")
>>>
>>> from django.core.wsgi import get_wsgi_application
>>> application = get_wsgi_application()
>>>
>>> I was trying to do some tricky stuff with virtualenv initially, but I 
>>> still see the problem with the 
>>> config stripped back very simple, as described above.
>>>
>>> P.
>>>
>>> On Thursday, 22 May 2014 21:29:02 UTC+1, WongoBongo wrote:

 Maybe post your apache.conf or/and your wsgi file. Maybe check your 
 Apache logs.

 K

 On Wednesday, May 21, 2014 11:01:29 PM UTC-7, Spaceman Paul wrote:
>
> No that's what I've got.
>
> P.
>
>
>>>

-- 
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/f8014e30-aa3e-4b59-ba7e-6783f27802c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: URL lookup fails in apache/wsgi unless mapped to server root.

2014-05-23 Thread Spaceman Paul
Ugh nevermind.

Yes it's a bug - but in my code.  I'll figure it out.

On Friday, 23 May 2014 14:58:11 UTC+10, Spaceman Paul wrote:
>
> Playing around some more, and inserting some trace statements in the 
> django code, I can see
> (for the example ^times$ pattern):
>
> 1) When WSGIScriptAlias is the server root:
>
> The RegexURLResolver.resolve(self,path) method (in 
> django.core.urlresolvers.py) is called three times,
> each time with path="/times" and each time it successfully resolves at the 
> "^times$" pattern.
>
> 2) When WSGIScriptAlias is not server root (i.e. /awma):
>
> The RegexURLResolver.resolve(self,path) method (in 
> django.core.urlresolvers.py) is called four times:
>
> a) The first two times it is called with path="/times" and successfully 
> resolves at the "^times$" pattern.
> b) The third time it is called with path="/awma/times" - not surprisingly 
> it does not resolve.
> c) The fourth time is is called with path="awma/times" - this fails too.
>
> It looks like the fourth call is made from within the third call - it's 
> the call for the admin url include.
>
> Overall result is a 404.
>
> This is looking at the 2.4.13 codebase - although the method is basically 
> the same in 2.6.5 and I
> see the same behaviour there.
>
> Is this a bug?  Surely I can't be the only person using WSGI with a 
> non-root mount point.
>
> P. 
>
> On Friday, 23 May 2014 01:25:03 UTC+1, Spaceman Paul wrote:
>>
>> I've worked around it by creating another A-record and pointing each 
>> application to the server root of the respective 
>> virtual host, but this should not be necessary.
>>
>> On Thursday, 22 May 2014 23:50:57 UTC+1, Spaceman Paul wrote:
>>>
>>> Nothing in wsgi.conf.
>>>
>>> Relevant bits of apache conf:
>>>
>>> 
>>> 
>>> WSGIScriptAlias /awma 
>>> /home/paul/src/awma-apache/internationalguidelines/wsgi.py
>>> 
>>> 
>>>
>>> Nothing in /var/log/apache2/error.log
>>>
>>> Access.log just says:
>>>
>>> 152.91.9.9 - - [23/May/2014:08:27:17 +1000] "GET /awma/ HTTP/1.1" 404 
>>> 1476 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>> 152.91.9.9 - - [23/May/2014:08:27:22 +1000] "GET /awma/times HTTP/1.1" 
>>> 404 1483 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>>
>>> 404 debug pages like:
>>>
>>> Using the URLconf defined in internationalguidelines.urls, Django tried 
>>> these URL patterns, in this order:
>>>
>>>   1.  ^$ [name='index']
>>>   2.  ^times$ [name='times']
>>>   3.  ^admin/
>>>
>>> The current URL, times, didn't match any of these.
>>>
>>> AND: The current URL, , didn't match any of these
>>>
>>> Although weirdly, admin works:
>>>
>>> 152.91.9.9 - - [23/May/2014:08:28:19 +1000] "GET /awma/admin/ HTTP/1.1" 
>>> 200 1450 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>>
>>> But when I change the WSGIScriptAlias to:
>>>
>>>  WSGIScriptAlias / 
>>> /home/paul/src/awma-apache/internationalguidelines/wsgi.py
>>>
>>> Everything works fine:
>>>
>>> 152.91.9.9 - - [23/May/2014:08:37:22 +1000] "GET / HTTP/1.1" 200 1156 
>>> "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>> 152.91.9.9 - - [23/May/2014:08:37:27 +1000] "GET /times HTTP/1.1" 200 
>>> 1550 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>> 152.91.9.9 - - [23/May/2014:08:37:39 +1000] "GET /admin/ HTTP/1.1" 200 
>>> 1446 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:29.0) Gecko/20100101 
>>> Firefox/29.0"
>>>
>>> WSGI file contains nothing unusual:
>>>
>>> import os
>>> import sys
>>>
>>> sys.path.append('/home/paul/src/awma-apache/')
>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
>>> "internationalguidelines.settings_prod")
>>>
>>> from django.core.wsgi import get_wsgi_application
>>> application = get_wsgi_application()
>>>
>>> I was trying to do some tricky stuff with virtualenv initially, but I 
>>> still see the problem with the 
>>> config stripped back very simple, as described above.
>>>
>>> P.
>>>
>>> On Thursday, 22 May 2014 21:29:02 UTC+1, WongoBongo wrote:

 Maybe post your apache.conf or/and your wsgi file. Maybe check your 
 Apache logs.

 K

 On Wednesday, May 21, 2014 11:01:29 PM UTC-7, Spaceman Paul wrote:
>
> No that's what I've got.
>
> P.
>
>
>>>

-- 
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/486eb942-7e6f-4c79-8dc0-fee7ee91e272%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Any job offer for Junior Django Developer?

2014-05-23 Thread Mariusz Dev
Thank you for the feedback :) 
I currently live and work in Poland. 
I'm ready to move to a country in Europe and working remotely with people 
from the USA.

Best

W dniu piątek, 23 maja 2014 01:52:42 UTC+2 użytkownik Russell Keith-Magee 
napisał:
>
>
> On Thu, May 22, 2014 at 10:25 PM, Mariusz Dev 
> 
> > wrote:
>
>> Hello,
>>
>> I'm looking for job for Junior Django Developer. 
>> I have one year of experience in Django and more in technologies 
>> frontendowych: HTML5/CSS3 (Bootstrap), JS. 
>>
>> If anyone is interested, please message - I'll send my resume and 
>> portfolio. 
>>
>> My email: mariusz.d...@gmail.com 
>>
>> Best regards.
>>
>
> If you're going to mail a mailing list with an international audience to 
> request a job, it's usually a good idea to tell people where you live, and 
> whether you're interested or able in relocating.
>
> Yours,
> Russ Magee %-)
>
>

-- 
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/87a3e12e-ee0f-4af5-9a78-5d6b25683b57%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Python Math and Physics problem solving

2014-05-23 Thread Team UK
Hello

We are developing a Django app that has a calculator to calculate prices 
for our products and services on our website. I am looking for someone with 
skills in solving calculator problems and make the solution cover all the 
products. Are you good with Math and physics?
Email us your skype ID

On Thursday, May 22, 2014 6:43:01 AM UTC+1, nishant kashyap wrote:
>
> Hi, 
> I am inetrested, could you please explain more about the work and project..
>
> Thanks,
> Nishant Kashyap
>
> On Wednesday, 21 May 2014 18:31:04 UTC+5:30, Team UK wrote:
>>
>> Looking for a candidate who has experience in Django Python.
>>
>> You must have knowledge in Python Math and Physics problem solving,
>> Linear algebra,nonlinear system modeling and ANN etc.
>>
>>
>>

-- 
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/d1171799-a121-40f9-81ea-fca68b2e4282%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django - Mysql datetime timezone naive and aware

2014-05-23 Thread Gabriel
Hello folks, I've found an abnormal behavior migrating a project from php - 
mysql to django 1.6.x - mysql and timezone naive to aware datetimes, I've 
posted my insights about it in stack overflow, if anyone can help will be 
more than welcome!

Many thanks!

Stackoverflow link -> 
http://stackoverflow.com/questions/23755968/django-mysql-datetime-timezone-naive-and-aware

Stackoverflow Post:

I'm involved in migrating an app from php - mysql to django - mysql, well, 
I've started migrating an inbox app which allows users to send messages 
1to1, after my first data migration (using a insert - select mysql 
statement) I proceed with some data migrations as follows.

   - I've tried to migrate messages statuses: in my "legacy" database the 
   approach used is using a bitwise field with integers suchs as 1 for 
   received, 2 for read, 4 for trash and so on, I've installed django-bitwise 
   to accomplish the same approach but I must migrate those integers to 
   strings like "RECEIVED", "READ", "TRASH", ... since I have millions of rows 
   I cannot use the ORM with an objects.all() and I've had decided to go month 
   by month.

If I try to count messages by month using the following ORM statement:

Message.objects.filter(sent_at__year=2011, sent_at__month=1).count()

It returns 0
--

If I count it directly using the following SQL statement it returns the 
correct number:

select count(*) from inbox_message where year(sent_at) = 2011 and 
month(sent_at) = 1;

Result is 64955
--

After a little bit of digging into Google and Stackoverflow it seems to be 
something related to timezone naive datetimes, so I've tried the following

settings.USE_TZ = FalseMessage.objects.filter(sent_at__year=2011, 
sent_at__month=1).count()

Now It returns 64955 hooray!
--

Known this, I've started to convert 'sent_at' from timezone naive to 
timezone aware, my first approach was to apply the CONVERT_TZ mysql 
function in my insert - select statement but it produces the same result, 
since my original data source is on UTC+1 timezone I've decided to fix this 
as well using:

convert_tz(sent_at, '+01:00', '+00:00')

I'm not using named timezones because I didn't installed the mysql timezone 
tables (as docs says)

After that I've tried to use django.utils.timezone.make_aware to make my 
datetimes timezone aware using a simple python script... nothing changes, 
still having zero when USE_TZ=True, the script looks like:

from django.utils.timezone import is_naive, make_aware, utc
settings.USE_TZ = False
messages = Message.objects.filter(sent_at__year=2011, sent_at__month=1)for m in 
messages:
settings.USE_TZ = True  # Set it to true to avoid errors when datetime 
becomes timezone aware
if is_naive(m.sent_at):
m.sent_at = make_aware(m.sent_at, utc)
m.save()

Same results, filtering by year and month returns 0 elements.

Just to let you know, filtering just by year seems to work okay.

Thanks in advance
--

Adding Model definition answering comments:

class Message(models.Model):
subject = models.CharField(_(u"Subject"), max_length=2200)
body = models.TextField(_(u"Body"))
sender = models.ForeignKey(
get_user_model(),
related_name='sent_messages',
verbose_name=_(u"Sender"))
recipient = models.ForeignKey(
get_user_model(),
related_name='received_messages',
null=True, blank=True, verbose_name=_(u"Recipient"))
parent_msg = models.ForeignKey(
'self',
related_name='next_messages',
null=True, blank=True,
verbose_name=_(u"Parent message"))
sent_at = models.DateTimeField(
_(u"Sent at"), null=True, blank=True, db_index=True)
read_at = models.DateTimeField(
_(u"Read at"), null=True, blank=True, db_index=True)
replied_at = models.DateTimeField(
_(u"Replied at"), null=True, blank=True, db_index=True)
sender_status = BitField(
verbose_name=_(u'Estado sender'),
flags=FLAGS_MESSAGE,
db_index=True)
recipient_status = BitField(
verbose_name=_(u'Estado recipient'),
flags=FLAGS_MESSAGE,
db_index=True)

class Meta:
ordering = ['-sent_at']

-- 
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/57704c0c-1e1a-4841-b82e-0ebca8479637%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to execute query for multiple table using cursor in Django

2014-05-23 Thread Kelvin Wong
https://docs.djangoproject.com/en/1.6/topics/db/sql/

K

On Thursday, May 22, 2014 11:31:26 PM UTC-7, swapnil srivastava wrote:
>
> Hi Experts,
>
> I just want to execute queries and subqueries in Django .
> Can anybody please tell me how to use cursor for execute queries in Django 
> framework in views.py 
>
> Thanks and Regards 
> Swapnil
>

-- 
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/048d65e4-36a8-4850-8aa2-f0f307ed7282%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.