Re: uwsgi install question

2012-09-05 Thread Trevor Joynson
If there's no apt-get, you're probably on an rpm-based distribution
such as CentOS. you can tell what distro you are on via "lsb_release
-a".

Your webhost should already have libxml2 installed as it's required by
nearly everything web dev, but the header files sound like they aren't
installed (the devel packages).

If you don't have root access, you have two options:

1) (Easiest) Find the matching devel package version for the binary
libxml already installed and extract it to a folder, link against the
header files contained within by specified the include path, most
./configure scripts have such an option, something ala
--with-libxml=/path/to/libxml2

2) (More work without more profit) Download libxml2 and compile it,
specify the include path in the same way as above but you'll also need
to put this path in your LD_LIBRARY_PATH env variable.

Good luck!


)) Trevor Joynson (trevorj)
(( Network Ninja


On Thu, Sep 6, 2012 at 12:01 AM, ecs1749  wrote:
> I know this a Django group but uwsgi is blocking my way to seeing the next
> step of my first Django project.  There doesn't seem to be a uwsgi group
> that I can see.  So, I hope you don't mind.
>
> First step for the uwsgi install procedure:
>
> apt-get install build-essential python-dev libxml2-dev
>
> but there is no "apt-get" with the westhost share hosting and uwsgi fails to
> install without libxml2.  Anybody?
>
> Thanks,
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/jH9gjKWraqsJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Development server won't work from a shared web host

2012-09-05 Thread ecs1749
Ok, ok.  I now have a Ubuntu/server with a Ubuntu desktop running using 
oracle vm virtualbox.   I know almost nothing about Linux.  I don't even 
know how to ssh to this beast sitting in front of me.  I  hope this is a 
start...

On Tuesday, September 4, 2012 9:19:57 AM UTC-7, Marcin wrote:
>
> You don't have a computer that you can develop on at all? How are you 
> writing this email? Developing over ssh is going to be a huge pain.
>
> Now, you *maybe* can use the runserver command - if you do add the --help 
> switch it will tell you how to run it to bind to a particular interface and 
> port. It maybe that you can bind it to a port on the localhost interface 
> (and then tunnel that over ssh), or you may be able to have your host 
> allocate you specific ports which you can use to run any kind of web server 
> you like. 
>
> While runserver shouldn't be used for production, I have used it to 
> diagnose specific problems in the production environment, which inevitably 
> will differ from development when using a shared host. This is, of course, 
> fairly insecure, and could even be illegal depending on your data 
> protection obligations. 
>
> On Tue, Sep 4, 2012 at 12:03 PM, ecs1749  >wrote:
>
>> I don't have a local machine I can use to learn Django - just a personal 
>> acct from a shared host.  The question I kept asking was:  How do I get 
>> into admin and follow the tutorial without the development server because 
>> the tutorial doesn't tell me that.
>>
>> Regards,
>>
>>
>> On Monday, September 3, 2012 11:13:53 PM UTC-7, Daniel Roseman wrote:
>>>
>>> On Tuesday, 4 September 2012 03:32:08 UTC+1, ecs1749 wrote:

 Thanks for the reply.  Yes, I saw that message.  I am a bit lost where 
 to go next if I completely ignore that tutorial regarding doing admin from 
 the development server (which I don't have).  Do I dive into tutorial   #3 
 and hope that it will pick up the admin stuff later when it gets to talk 
 about wsgi?  Or is there a "here's what you do if you don't have a 
 development server" tutorial somewhere?


>>> You should not be doing the tutorial - or any development - on your 
>>> server. Install Django locally and do it there, then deploy when you are 
>>> ready and not before.
>>>
>>> However, you are wrong to assume that the admin console has anything to 
>>> do with the development server - it works just fine with any server.
>>> --
>>> DR.
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/UhMFGZB6YS0J.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Marcin Tustin
> Tel: +44 (0) 7773 787 105 (UK)
>+1  917 553 3974 (US)
>
>
>  

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



uwsgi install question

2012-09-05 Thread ecs1749
I know this a Django group but uwsgi is blocking my way to seeing the next 
step of my first Django project.  There doesn't seem to be a uwsgi group 
that I can see.  So, I hope you don't mind.

First step for the uwsgi install procedure:

apt-get install build-essential python-dev libxml2-dev

but there is no "apt-get" with the westhost share hosting and uwsgi fails to 
install without libxml2.  Anybody?

Thanks,


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



Re: Choosing a JS framework to go together with Django

2012-09-05 Thread dotnetCarpenter
@Kelly Nicholes In backbone.js everything is in JS, meaning that there 
could be no conflict between declarative code and Django handled templates. 
If I can expose my python models, through auto serialization (JSON) from 
Django, I can see a productivity win. But I'm a little afraid of the tight 
coupling in data models between back-end and front-end. My main concern is 
that I'll have to rewrite large parts of JS if/when the models change. Have 
you any experience ironing out these issues? Maybe it's not a problem but I 
lack experience with both frameworks.

I'll look more into backbone.js :)

Den onsdag den 5. september 2012 16.34.29 UTC+2 skrev Kelly Nicholes:
>
> It would be a travesty to not mention backbone.js.
>
> On Tuesday, September 4, 2012 7:39:49 AM UTC-6, dotnetCarpenter wrote:
>>
>> Hi all.
>>
>> I'm new here and just took over a Django project for the first time. I'm 
>> still getting to grip with Django but as a front end dev for the past 5 
>> years, I'm also looking for a client-side library/framework to go together 
>> with my project.
>> My requirements for a JS framework is that it:
>>
>>1. is unobtrusive (Django rendered HTML will be shown to scraper bots 
>>like google)
>>2. provides some sort of structure (MVC, MVP, MVVM ect.)
>>3. embraces standards
>>4. doesn't conflict with Django templates or does so intentionally
>>5. ideally uses the same template language as Django
>>
>> In the ideal world a request/response scenario would look like this:
>>
>>1. A client make a (HTTP) request to the (django powered) web site 
>>with (HTTP) Accept header text/html
>>2. Django response in the usual way by rendering the assign View 
>>(django template)
>>3. The view figure out if JS is supported (implemented in JS). If no, 
>>this scenario stays in loop 1-3. If yes, then 4.
>>4. The client (usually a browser) wire up the client-side app 
>>structure, hook in to URI links, add transitions between views, 
>>data-bindings ect.
>>5. Subsequent request are now handle by the JS framework, either user 
>>initiated (e.g. clicking a link) or app initiated (e.g. pulling extra 
>>data), that will modify the request header to Accept header 
>>application/json or application/django-template.
>>6. If django receive a request with an application/django-template 
>>header it will serve the view as plain text. E.g. Content-type: 
>> text/plain. 
>>On the other hand if django receive a request with application/json, it 
>>will send the object model defined in the view as JSON.
>>7. The client-side JS framework will receive a template to render in 
>>the first request and the data to render in the template in the second 
>>request. A promise object could be used to synchronize the two calls.
>>
>> This way django will work as intended for non JS clients and silently 
>> convert to a RIA in clients that supports JS, with minimal double work for 
>> the two execution contexts.
>> A big pro in this is the fact that both django and the JS framework share 
>> template and data (only has to defined once - in django) - we'll duck type 
>> all the way. But does this JS framework exist? Does anyone have any 
>> experience with working with django and JS frameworks? Is there any obvious 
>> pitfalls in my ideal world scenario in regard to Django? And finally, is it 
>> possible to serve templates as plain text with django?
>>  
>>
>> Cheers, Jon and thanks in advance
>>
>> PS. I accidentally cross-posted this to the Django Developers group 
>> before realizing it was the wrong forum. Sorry about that. 
>>
>>

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



Re: Choosing a JS framework to go together with Django

2012-09-05 Thread dotnetCarpenter
@Peith Yes, I can see the advantage of not having to spend time working out 
template conflicts. But you'll have to write two sets of template code, 
right? One for Django and one for KnockoutJS. Or am I missing something?

Cheers, Jon

Den tirsdag den 4. september 2012 16.38.29 UTC+2 skrev Peith:
>
> i've been playing with KnockoutJS lately. one thing i like about it is 
> that it's built-in templating engine has a different syntax than Django's, 
> so there shouldn't have any conflict.
>

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



Re: Choosing a JS framework to go together with Django

2012-09-05 Thread dotnetCarpenter
Hi vicherot.

I'm interested to know how you made the distinction between your dhtml/ 
part of your site to the shtml/ part. It looks like you pretty much used 
the same code base to generate the 2 versions. Can you elaborate on the 
Django specific parts of your implementation?

Cheers, Jon

Den tirsdag den 4. september 2012 16.55.40 UTC+2 skrev vicherot:
>
> men, i use Jquery on www.expoferiasg.com.ar and works quite well.. with 
> any problem.
>
> 2012/9/4 Peith Vergil 
>
>> i've been playing with KnockoutJS lately. one thing i like about it is 
>> that it's built-in templating engine has a different syntax than Django's, 
>> so there shouldn't have any conflict.
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Rafael E. Ferrero
> Claro: (03562) 15514856
>

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



Re: Choosing a JS framework to go together with Django

2012-09-05 Thread dotnetCarpenter
Wow - a lot of answers. Great community!

First of all, just to clearify. My aim is to have smooth user experience 
while utilizing Django and replicate as little code as possible on the 
client and the server. Think, reuse of server code on the client.

I've looked at AngularJS and it has a rendering layer that doesn't work 
without JS. Hence, no google support since google still requires us to 
deliver HTML 
snapshot.
 
Which means it violate my first requirement. AngularJS doesn't seem to 
offer help in this 
regard.https://groups.google.com/forum/?fromgroups=#!topic/angular/yClOeqR5DGc

Almost all JS frameworks in the wild, violate simple SEO rules, so it's not 
confined to AngularJS at all.

jQuery doesn't dictate client-side rendering. but doesn't offer any 
structure at all. Albeit it's great to build your own structure on top of.

Thanks for the list of frameworks. I haven't look at Knockout yet but it 
seems to require JS to do it's data bindings.

Cheers, Jon.

Den onsdag den 5. september 2012 20.14.29 UTC+2 skrev Amyth:
>
> I am not sure what you are exactly trying to achieve. A more issue 
> specific topic would have been easy to understand though i can suggest you 
> following frameworks (in particular order):
>
> 1. KnockoutJS
> 2. BackboneJS
> 3. Cappucino
> 4. Ember.Js
> 5. Sammy.JS
> 6. Spine.JS
> 7. JavascriptMVC
>
> On Wed, Sep 5, 2012 at 8:04 PM, Kelly Nicholes 
>  > wrote:
>
>> It would be a travesty to not mention backbone.js.
>>
>>
>> On Tuesday, September 4, 2012 7:39:49 AM UTC-6, dotnetCarpenter wrote:
>>>
>>> Hi all.
>>>
>>> I'm new here and just took over a Django project for the first time. I'm 
>>> still getting to grip with Django but as a front end dev for the past 5 
>>> years, I'm also looking for a client-side library/framework to go together 
>>> with my project.
>>> My requirements for a JS framework is that it:
>>>
>>>1. is unobtrusive (Django rendered HTML will be shown to scraper 
>>>bots like google)
>>>2. provides some sort of structure (MVC, MVP, MVVM ect.)
>>>3. embraces standards
>>>4. doesn't conflict with Django templates or does so intentionally
>>>5. ideally uses the same template language as Django
>>>
>>> In the ideal world a request/response scenario would look like this:
>>>
>>>1. A client make a (HTTP) request to the (django powered) web site 
>>>with (HTTP) Accept header text/html
>>>2. Django response in the usual way by rendering the assign View 
>>>(django template)
>>>3. The view figure out if JS is supported (implemented in JS). If 
>>>no, this scenario stays in loop 1-3. If yes, then 4.
>>>4. The client (usually a browser) wire up the client-side app 
>>>structure, hook in to URI links, add transitions between views, 
>>>data-bindings ect.
>>>5. Subsequent request are now handle by the JS framework, either 
>>>user initiated (e.g. clicking a link) or app initiated (e.g. pulling 
>>> extra 
>>>data), that will modify the request header to Accept header 
>>>application/json or application/django-template.
>>>6. If django receive a request with an application/django-template 
>>>header it will serve the view as plain text. E.g. Content-type: 
>>> text/plain. 
>>>On the other hand if django receive a request with application/json, it 
>>>will send the object model defined in the view as JSON.
>>>7. The client-side JS framework will receive a template to render in 
>>>the first request and the data to render in the template in the second 
>>>request. A promise object could be used to synchronize the two calls.
>>>
>>> This way django will work as intended for non JS clients and silently 
>>> convert to a RIA in clients that supports JS, with minimal double work for 
>>> the two execution contexts.
>>> A big pro in this is the fact that both django and the JS framework 
>>> share template and data (only has to defined once - in django) - we'll duck 
>>> type all the way. But does this JS framework exist? Does anyone have any 
>>> experience with working with django and JS frameworks? Is there any obvious 
>>> pitfalls in my ideal world scenario in regard to Django? And finally, is it 
>>> possible to serve templates as plain text with django?
>>>  
>>>
>>> Cheers, Jon and thanks in advance
>>>
>>> PS. I accidentally cross-posted this to the Django Developers group 
>>> before realizing it was the wrong forum. Sorry about that. 
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/PF4D-xIEovcJ.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> 

Re: Test driven development in Django framework

2012-09-05 Thread Mike Dewhirst

On 6/09/2012 3:04am, Javier Guerra Giraldez wrote:

On Wed, Sep 5, 2012 at 7:46 AM, jyria  wrote:

What is your experience? Is it worth it, and is it possible?

I tried it and found it quite difficult to follow guideline of unit testing
-- testing a unit of code, a class for example. Maybe Im just ignorant, but
I didnt see, how can I create registration app only with unit tests. The
only way I could drive implementation with tests was using more like an
integration testing approach: calling requests with data and asserting that
new user was registered and that form was valid/invalid etc, but this goes
against TDD as I understand it. So should I not worry about pure "unit
testing" approach and use django client http request to validate
RegistrationForm. Or I should write unit tests for RegistrationForm class?


TDD is not unit-testing


Here is a lovely diagram I found recently - probably by following a link 
someone posted here - which shows the TDD process with unit tests and 
acceptance tests.


IMO it covers pretty much everything in the universe ...

http://www.methodsandtools.com/archive/attready3.jpg



https://www.google.com/webhp?q=tdd%20is%20not%20unit%20testing


in short, it's like you've found: the tests you easily get with TDD
are more (but not exactly) like integration tests, because you test
features, not units.  The "test isolated units" mantra of unit-testing
requires different work.  There's nothing wrong in adding 'real'
unit-tests, but it's not required to do effective TDD.

I guess that since unittesting became so well known so long ago,
almost all test frameworks (including Python's and Django's) call
their base test class "UnitTest", but they're not; they're just tests.
  you make them feature tests, or integration tests, or unit tests, or
whatever kind of test.

now, about the pros/cons of unit-testing vs. other kinds of tests.
that's a whole debate that i'm not going to touch.



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



Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread g1smd.1

The GB number plan is quite complicated, with a variety of number lengths 
and formats.
Some of it is detailed here:
http://www.aa-asterisk.org.uk/index.php/Number_format

I already compiled all the RegEx patterns that are needed. Some are listed 
here:
http://www.aa-asterisk.org.uk/index.php/Regular_Expressions_for_Validating_and_Formatting_UK_Telephone_Numbers

I've already started the process of translating a fully working PHP routine 
(that I wrote from scratch) into python. There will be syntax errors in the 
python version as I don't understand all that much of the python language.

The python functionality so far  
https://github.com/django/django/pull/324/files
or
https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py

The code using an array is probably not quite right, and I guess it would 
be better to return error messages instead of "false" in some places.

However, I'd guess that someone who knows what they were doing could get it 
working in an hour or two.



On Wednesday, September 5, 2012 6:24:42 PM UTC, Amyth wrote:
>
> To be frank, I am not really familiar with all possibilities of GB phone 
> numbers, if you could throw some light on this, I might be able to help ya.
>
> On Wed, Sep 5, 2012 at 5:59 PM, g1smd.1  >wrote:
>
>>
>> Thanks for the reply and information.
>>
>>
>> The jQuery validation routines for GB telephone numbers contain 
>> significant errors and shortcomings. I already posted some patches 
>> correcting many of those problems at least a month ago, but they haven't 
>> been reviewed yet.
>>
>>
>> The new Python/django telephone number validation code I am proposing 
>> here is far more comprehensive and has much more detailed range and length 
>> checking. Similar code already works fine in PHP and Java elsewhere, but I 
>> am having trouble converting it all to Python. 
>>
>> I have added some Python logic and code to the initial RegEx patterns 
>> that I posted yesterday, but I now need help to finish it off and get it 
>> working. I am not at all familiar with the Python syntax and the manual is 
>> somewhat terse and obtuse.
>>
>> I had a problem with GitHub this morning, so the pull request is now at 
>> https://github.com/django/django/pull/324
>>
>> The code so far, can be found at: 
>> https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py
>>
>> I'm guessing that someone proficient in Python could finish it off in a 
>> couple of hours or less.
>>
>> Any volunteers?
>>
>>
>>
>>
>> On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote:
>>>
>>> you can alternatively use jquery to validate the field, i do not have 
>>> the link handy as m on my phone right now but google validation engine, it 
>>> is one of the most powerful jquery validation library which also has 
>>> builtin method of validating uk phone numbers.
>>> On Sep 4, 2012 5:00 AM, "g1smd.1"  wrote:
>>>
  I see that there are routines for validating telephone numbers in 
 forms in Django for several countries.

 The code for that can usually be found in the forms.py file located in 
 the various country folders here:
 https://github.com/django/**django/tree/master/django/**
 contrib/localflavor
  

 So far, there is nothing for GB numbers, here:
 https://github.com/django/**django/tree/master/django/**
 contrib/localflavor/gb

 I've written a bunch of RegEx patterns to get this functionality 
 started. The patterns are 100% fully tested. All that's needed is a few 
 lines of python logic to string them together. The details can be found at:
 https://github.com/django/**django/pull/316/files

 My python foo is almost zero. Anyone care to have a go at getting this 
 to work?

 RegEx 1 checks the user entered something that looks like a GB 
 telephone number:
 020  3000  
 02075  567  234
 0114  223  4567
 01145  345  567
 +44  1213  456  789
 00  44  (0)  1697  73555
 011  44  11  4890  2345
 and several other formats, without worrying if the format is correct 
 for this particular number (but read on). It allows for national or 
 international format, even for two common international dial prefixes. 
 What 
 is most important is that the user enters the right number of digits. 
 Don't 
 constrain the user to use a particular format for entry.
 "Be lenient in what you accept, be strict in what you send." (Postel's 
 Law)

 RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in 
 $2 (so you know if international or national format was used on input), 
 and 
 any extension in $4. Store $2 and $4 for later. Send 

Re: How to use FTP to upload files with Django?

2012-09-05 Thread Mando
here is an example  
http://django-mongodb.org/tutorial.html#uploading-files-to-gridfs it 
suggest using https://github.com/mdirolf/nginx-gridfs in production though

On Wednesday, September 5, 2012 1:25:29 PM UTC-5, Amyth wrote:
>
> To accept i guess as he said , he want his users to be able to upload 
> files...
>
> On Wed, Sep 5, 2012 at 11:53 PM, Kurtis Mullins 
>  > wrote:
>
>> Do you want to use FTP to serve or accept the files?
>>
>> On Wed, Sep 5, 2012 at 2:14 PM, Mando wrote:
>>
>>> Would this work -> nginx-gridfs
>>> ?
>>>
>>>
>>> On Wednesday, September 5, 2012 1:09:25 AM UTC-5, Chaney Lee wrote:

 I just want to allow users uploading some videos to server in my 
 website.I want to use FTP.So ,how to realize it?
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/f-vzQMOMSpoJ.
>>>
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Thanks & Regards
> 
>
> Amyth [Admin - Techstricks]
> Email - aroras@gmail.com , ad...@techstricks.com
> Twitter - @a_myth_
> http://techstricks.com/
>

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



Re: Editable Tables

2012-09-05 Thread Sait Maraşlıoğlu
Thx for greata tutorial, Ive already seen mygrid :)
in my website I will use mainly grid, lots of them, so I was looking for a 
solution to create them automatically, like django do that in its admin 
page.
if I keep doing them manually all grid titles and column names, its almost 
impossible, its not OOP either. and most importantly, it will be impossible 
to maintain it.
Anyways, I will keep searching, if I bump into something, I will drop a 
line. 

On Wednesday, 5 September 2012 19:38:12 UTC+3, MattDale wrote:
>
> I used this tutorial to get me going with the dhtmlx grid.   
> http://www.rkblog.rk.edu.pl/w/p/using-dhtmlxgrid-django-application/ 
> it's easy once you get the hang of it to make custom grids for each view, 
> but not as cut and dry as it seems you are looking for. 
>
> On Wednesday, September 5, 2012 4:27:39 AM UTC-4, Sait Maraşlıoğlu wrote:
>>
>> This is an example how to create and modify admin listing page: This 
>> explains better
>>
>> class BookAdmin(admin.ModelAdmin):
>> list_display = ('title', 'publisher', 'publication_date')
>> list_filter = ('publication_date',)
>> date_hierarchy = 'publication_date'
>> ordering = ('-publication_date',)
>> filter_horizontal = ('authors',)
>> *raw_id_fields = ('publisher',)
>>
>> Lets say , I want to use this kind of command for my frond-end, django 
>> handle the search fields and listing parameters.
>> only with my own table model, lets say its DHTMLX . at the end, I will have 
>> my view, generated with search options and
>> a few buttons to search,view,edit...
>> is it possible, not required to be ready to use, I just looking for a way to 
>> achieve it.
>>
>> thx again.
>> *
>>
>>
>>
>>
>> On Sunday, 2 September 2012 00:58:25 UTC+3, Sait Maraşlıoğlu wrote:
>>>
>>> Just seen a demo page
>>> http://nextgensim.info/grids
>>> so beautiful grids,
>>> lift framework can do that, I guess, havent dig much but as far as I 
>>> seen, its an alternative framework.
>>> Can anybody tell me how to create this kind of interactive tables? What 
>>> django has to offer, if not What keywords, I need to search?
>>> thx
>>>
>>

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



Re: bound field object - dynamic forms

2012-09-05 Thread mjh
yes it is being passed to the template as I can access the label, choices, 
help_text, required items of the boundfield object...

i.e., {{ issue.label }} {{ issue.choices }} {{ issue.help_text }}

I can get everything it seems apart from the form object !!!

{{ issue }} writes to the template: 


???



On Wednesday, 5 September 2012 18:56:17 UTC+1, Amyth wrote:
>
> check if it is being passed to template.
>
> {% if issue %}
>   {{ issue }}
> {% else %}
>   Issue was not passed #Debug
> {% endif %}
>
> On Wed, Sep 5, 2012 at 8:45 PM, Mando wrote:
>
>> are you passing it to the template?
>>
>>
>> On Wednesday, September 5, 2012 7:09:57 AM UTC-5, mjh wrote:
>>>
>>> tried {{ issue.x }} x = 0,1,2,3 but nothing is displayed in the template
>>>
>>> any other thoughts?
>>>
>>> On Monday, 3 September 2012 22:53:03 UTC+1, somecallitblues wrote:

 Try {{ issue.0}} and {{ issue.1}}
 On Sep 4, 2012 5:55 AM, "mjh"  wrote:

> Hi all - not sure how to show the choicefield dropdown in my template?
>
> Am generating a dynamic form (note: for issue in issues in forms.py) and 
> appending the fields to self.issue_list
>
> in the template I am looping over these fields ({% for issue in 
> form.issue_list %}) and can write out the label {{ issue.label }} but if 
> write out {{ issue }} I simply get the bound field object written to 
> template ().
>
> Question is how do I get the html dropdown to display in the template??
>
>
>
> >>> forms.py
> def __init__(self, item, *args, **kwargs):
> super(ItemAnalysisForm, self).__init__(*args, **kwargs)
> issue_choice = (('1', 'Reduced'),
> ('2', 'Maintained'),
> ('3', 'Increased')
> )
> issues = item.issue.all()
>
> self.issue_list = []
> self.a_list = []
> # generate dynamic issue dropdowns...
> for issue in issues:
> self.fields['issue-' + str(issue.pk)] = 
> forms.ChoiceField(label=issue.**name , 
> choices=issue_choice, required=False)
> self.a_list.append(self.**fields['issue-' + str(issue.pk)])
> self.issue_list.append(self.**fields['issue-' + 
> str(issue.pk)])
> self.fields['text'] = forms.CharField(label='text', 
> required=True, widget=forms.Textarea(attrs={'**rows':25,'cols':'100'}))
> self.a_list.append(self.**fields['text'])
>
>
> >>> template
> {% 
> csrf_token %}
> 
> Individual Issue Outcome:
> 
> {% for issue in form.issue_list %}
> 
> {{ issue.label }}: {{ issue }}
> 
> {% endfor %}
> 
> 
> 
> Comment:
> 
> {{ form.text }}
> 
>
> 
>
>  -- 
> You received this message because you are subscribed to the Google 
> Groups "Django users" group.
> To view this discussion on the web visit https://groups.google.com/d/*
> *msg/django-users/-/**XSMbUGOJyvMJ
> .
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.**com.
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/up3KXt_tm2YJ.
>>
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>
>
> -- 
> Thanks & Regards
> 
>
> Amyth [Admin - Techstricks]
> Email - aroras@gmail.com , ad...@techstricks.com
> Twitter - @a_myth_
> http://techstricks.com/
>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/H8fJ3O-vDwQJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
I have timing built into the app using Navigation Timing:

http://www.html5rocks.com/en/tutorials/webperformance/basics/

It gets logged in our database.

On Wed, Sep 5, 2012 at 2:58 PM, Kurtis Mullins  wrote:
> Actually, I take that back. I did some quick reading and found this from
> Selenium's FAQ (http://selenium-grid.seleniumhq.org/faq.html)
>
> "
> Selenium Grid is not designed for performance and load testing, but very
> efficient web acceptance/functional testing. The main reason for this is
> that conducting performance/load testing with real browser is a pretty bad
> idea as it is hard/expensive to scale the load and the actual load is very
> inconsistent.
>
> For load/performance testing I would advise using tools like JMeter, Grinder
> or httperf. What you can do though, is reuse your selenium tests to record
> the use cases you will use for your load testing. If you really want to
> conduct load testing with Selenium, check out Browser Mob.
>
> To simulate 200 concurrent users for instance, you would need 200 concurrent
> browsers with a load testing framework based on Selenium Grid. Even if you
> use Firefox on Linux (so the most efficient setup) you will probably need at
> least 10 machines to generate that kind of load. Quite insane when
> JMeter/Grinder/httperf can generate the same kind of load with a single
> machine.
>
> "
>
> On Wed, Sep 5, 2012 at 2:52 PM, Kurtis Mullins 
> wrote:
>>
>> No problem! Alternatively, you may have some luck with Selenium ...
>> although I have no experience here and am not sure if it can be made to
>> record times or any other indication of performance.
>> http://seleniumhq.org/
>>
>>
>> On Wed, Sep 5, 2012 at 2:48 PM, Larry Martell 
>> wrote:
>>>
>>> Thanks Kurtis!
>>>
>>>
>>> On Wed, Sep 5, 2012 at 2:48 PM, Kurtis Mullins 
>>> wrote:
>>> > Sure,
>>> >
>>> > To submit a cookie, check this out:
>>> >
>>> > http://stackoverflow.com/questions/3334809/python-urllib2-how-to-send-cookie-with-urlopen-request
>>> >
>>> > To harvest a CSRF Token from a page (for example, as part of a form),
>>> > here's
>>> > one example solution I found:
>>> >
>>> > http://stackoverflow.com/questions/3145178/get-contents-of-a-tags-using-python
>>> > -- of course you'd want to grab the appropriate HTML Element.
>>> >
>>> > Here's an example of setting and getting cookies:
>>> >
>>> > http://stackoverflow.com/questions/5606083/how-to-set-and-retrieve-cookie-in-http-header-in-python
>>> >
>>> > Here's some docs on the how to make the CSRF System happy:
>>> > https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-it-works
>>> >
>>> > On Wed, Sep 5, 2012 at 2:38 PM, Larry Martell 
>>> > wrote:
>>> >>
>>> >> I have no idea how that would be done (neither extracting the token
>>> >> nor passing it via urllib). I'm googling this, but if you know and
>>> >> want to share, that would be great.
>>> >>
>>> >> On Wed, Sep 5, 2012 at 1:50 PM, Kurtis Mullins
>>> >> 
>>> >> wrote:
>>> >> > Actually, I've got another idea for you. You mentioned you wanted to
>>> >> > simply
>>> >> > access using urllib. Maybe you could create a small script to
>>> >> > extract a
>>> >> > CSRF
>>> >> > token from the login page, login with a known (test) user, and
>>> >> > continue
>>> >> > passing and extracting the CSRF token as needed?
>>> >> >
>>> >> >
>>> >> > On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell
>>> >> > 
>>> >> > wrote:
>>> >> >>
>>> >> >> Thanks - but now I'm getting
>>> >> >>
>>> >> >> NameError: "global name 'get_backends' is not defined"
>>> >> >>
>>> >> >>
>>> >> >> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>>> >> >>  wrote:
>>> >> >> > Looks like you just need a quick:
>>> >> >> >
>>> >> >> > from django.contrib.auth.models import User
>>> >> >> >
>>> >> >> > towards the top :)
>>> >> >> >
>>> >> >> >
>>> >> >> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell
>>> >> >> > 
>>> >> >> > wrote:
>>> >> >> >>
>>> >> >> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>>> >> >> >>  wrote:
>>> >> >> >> > We are using a middleware to enforce a user login:
>>> >> >> >> >
>>> >> >> >> > class AutoAuthMiddleware(object):
>>> >> >> >> > """
>>> >> >> >> > Middleware for testing purpose only.
>>> >> >> >> > Can enforce the user login.
>>> >> >> >> > """
>>> >> >> >> >
>>> >> >> >> > def process_request(self, request):
>>> >> >> >> > enforce_user = request.GET.get("enforce_user", None)
>>> >> >> >> > if hasattr(request, "user") and not enforce_user:
>>> >> >> >> > return
>>> >> >> >> >
>>> >> >> >> > user = User.objects.filter(username = enforce_user)
>>> >> >> >>
>>> >> >> >>
>>> >> >> >> I'm getting: 'NameError: "global name 'User' is not defined"' on
>>> >> >> >> the
>>> 

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
Actually, I take that back. I did some quick reading and found this from
Selenium's FAQ (http://selenium-grid.seleniumhq.org/faq.html)

"
Selenium Grid is not designed for performance and load testing, but very
efficient web acceptance/functional testing. The main reason for this is
that conducting performance/load testing with real browser is a pretty bad
idea as it is hard/expensive to scale the load and the actual load is very
inconsistent.

For load/performance testing I would advise using tools like JMeter,
Grinder or httperf. What you can do though, is reuse your selenium tests to
record the use cases you will use for your load testing. If you really want
to conduct load testing with Selenium, check out Browser Mob.

To simulate 200 concurrent users for instance, you would need 200
concurrent browsers with a load testing framework based on Selenium Grid.
Even if you use Firefox on Linux (so the most efficient setup) you will
probably need at least 10 machines to generate that kind of load. Quite
insane when JMeter/Grinder/httperf can generate the same kind of load with
a single machine.
"

On Wed, Sep 5, 2012 at 2:52 PM, Kurtis Mullins wrote:

> No problem! Alternatively, you may have some luck with Selenium ...
> although I have no experience here and am not sure if it can be made to
> record times or any other indication of performance.
> http://seleniumhq.org/
>
>
> On Wed, Sep 5, 2012 at 2:48 PM, Larry Martell wrote:
>
>> Thanks Kurtis!
>>
>>
>> On Wed, Sep 5, 2012 at 2:48 PM, Kurtis Mullins 
>> wrote:
>> > Sure,
>> >
>> > To submit a cookie, check this out:
>> >
>> http://stackoverflow.com/questions/3334809/python-urllib2-how-to-send-cookie-with-urlopen-request
>> >
>> > To harvest a CSRF Token from a page (for example, as part of a form),
>> here's
>> > one example solution I found:
>> >
>> http://stackoverflow.com/questions/3145178/get-contents-of-a-tags-using-python
>> > -- of course you'd want to grab the appropriate HTML Element.
>> >
>> > Here's an example of setting and getting cookies:
>> >
>> http://stackoverflow.com/questions/5606083/how-to-set-and-retrieve-cookie-in-http-header-in-python
>> >
>> > Here's some docs on the how to make the CSRF System happy:
>> > https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-it-works
>> >
>> > On Wed, Sep 5, 2012 at 2:38 PM, Larry Martell 
>> > wrote:
>> >>
>> >> I have no idea how that would be done (neither extracting the token
>> >> nor passing it via urllib). I'm googling this, but if you know and
>> >> want to share, that would be great.
>> >>
>> >> On Wed, Sep 5, 2012 at 1:50 PM, Kurtis Mullins <
>> kurtis.mull...@gmail.com>
>> >> wrote:
>> >> > Actually, I've got another idea for you. You mentioned you wanted to
>> >> > simply
>> >> > access using urllib. Maybe you could create a small script to
>> extract a
>> >> > CSRF
>> >> > token from the login page, login with a known (test) user, and
>> continue
>> >> > passing and extracting the CSRF token as needed?
>> >> >
>> >> >
>> >> > On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell <
>> larry.mart...@gmail.com>
>> >> > wrote:
>> >> >>
>> >> >> Thanks - but now I'm getting
>> >> >>
>> >> >> NameError: "global name 'get_backends' is not defined"
>> >> >>
>> >> >>
>> >> >> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>> >> >>  wrote:
>> >> >> > Looks like you just need a quick:
>> >> >> >
>> >> >> > from django.contrib.auth.models import User
>> >> >> >
>> >> >> > towards the top :)
>> >> >> >
>> >> >> >
>> >> >> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell
>> >> >> > 
>> >> >> > wrote:
>> >> >> >>
>> >> >> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>> >> >> >>  wrote:
>> >> >> >> > We are using a middleware to enforce a user login:
>> >> >> >> >
>> >> >> >> > class AutoAuthMiddleware(object):
>> >> >> >> > """
>> >> >> >> > Middleware for testing purpose only.
>> >> >> >> > Can enforce the user login.
>> >> >> >> > """
>> >> >> >> >
>> >> >> >> > def process_request(self, request):
>> >> >> >> > enforce_user = request.GET.get("enforce_user", None)
>> >> >> >> > if hasattr(request, "user") and not enforce_user:
>> >> >> >> > return
>> >> >> >> >
>> >> >> >> > user = User.objects.filter(username = enforce_user)
>> >> >> >>
>> >> >> >>
>> >> >> >> I'm getting: 'NameError: "global name 'User' is not defined"' on
>> the
>> >> >> >> above line. This is the same issue I was running into when I was
>> >> >> >> trying to hard code the initialization of a request.user object.
>> >> >> >> Where
>> >> >> >> is that defined?
>> >> >> >>
>> >> >> >>
>> >> >> >> > if user:
>> >> >> >> > backend = get_backends()[0]
>> >> >> >> > user = user[0]
>> >> >> >> > user.backend = "%s.%s" % (backend.__module__,
>> 

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
No problem! Alternatively, you may have some luck with Selenium ...
although I have no experience here and am not sure if it can be made to
record times or any other indication of performance.
http://seleniumhq.org/

On Wed, Sep 5, 2012 at 2:48 PM, Larry Martell wrote:

> Thanks Kurtis!
>
>
> On Wed, Sep 5, 2012 at 2:48 PM, Kurtis Mullins 
> wrote:
> > Sure,
> >
> > To submit a cookie, check this out:
> >
> http://stackoverflow.com/questions/3334809/python-urllib2-how-to-send-cookie-with-urlopen-request
> >
> > To harvest a CSRF Token from a page (for example, as part of a form),
> here's
> > one example solution I found:
> >
> http://stackoverflow.com/questions/3145178/get-contents-of-a-tags-using-python
> > -- of course you'd want to grab the appropriate HTML Element.
> >
> > Here's an example of setting and getting cookies:
> >
> http://stackoverflow.com/questions/5606083/how-to-set-and-retrieve-cookie-in-http-header-in-python
> >
> > Here's some docs on the how to make the CSRF System happy:
> > https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-it-works
> >
> > On Wed, Sep 5, 2012 at 2:38 PM, Larry Martell 
> > wrote:
> >>
> >> I have no idea how that would be done (neither extracting the token
> >> nor passing it via urllib). I'm googling this, but if you know and
> >> want to share, that would be great.
> >>
> >> On Wed, Sep 5, 2012 at 1:50 PM, Kurtis Mullins <
> kurtis.mull...@gmail.com>
> >> wrote:
> >> > Actually, I've got another idea for you. You mentioned you wanted to
> >> > simply
> >> > access using urllib. Maybe you could create a small script to extract
> a
> >> > CSRF
> >> > token from the login page, login with a known (test) user, and
> continue
> >> > passing and extracting the CSRF token as needed?
> >> >
> >> >
> >> > On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell <
> larry.mart...@gmail.com>
> >> > wrote:
> >> >>
> >> >> Thanks - but now I'm getting
> >> >>
> >> >> NameError: "global name 'get_backends' is not defined"
> >> >>
> >> >>
> >> >> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
> >> >>  wrote:
> >> >> > Looks like you just need a quick:
> >> >> >
> >> >> > from django.contrib.auth.models import User
> >> >> >
> >> >> > towards the top :)
> >> >> >
> >> >> >
> >> >> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell
> >> >> > 
> >> >> > wrote:
> >> >> >>
> >> >> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
> >> >> >>  wrote:
> >> >> >> > We are using a middleware to enforce a user login:
> >> >> >> >
> >> >> >> > class AutoAuthMiddleware(object):
> >> >> >> > """
> >> >> >> > Middleware for testing purpose only.
> >> >> >> > Can enforce the user login.
> >> >> >> > """
> >> >> >> >
> >> >> >> > def process_request(self, request):
> >> >> >> > enforce_user = request.GET.get("enforce_user", None)
> >> >> >> > if hasattr(request, "user") and not enforce_user:
> >> >> >> > return
> >> >> >> >
> >> >> >> > user = User.objects.filter(username = enforce_user)
> >> >> >>
> >> >> >>
> >> >> >> I'm getting: 'NameError: "global name 'User' is not defined"' on
> the
> >> >> >> above line. This is the same issue I was running into when I was
> >> >> >> trying to hard code the initialization of a request.user object.
> >> >> >> Where
> >> >> >> is that defined?
> >> >> >>
> >> >> >>
> >> >> >> > if user:
> >> >> >> > backend = get_backends()[0]
> >> >> >> > user = user[0]
> >> >> >> > user.backend = "%s.%s" % (backend.__module__,
> >> >> >> > backend.__class__.__name__) #fake authentication
> >> >> >> > login(request, user)
> >> >> >> >
> >> >> >> > You can add that to your testing environnement
> MIDDLEWARE_CLASSES.
> >> >> >> >
> >> >> >> > Then you can just go to any url and add ?enforce_user=
> >> >> >> >
> >> >> >> >
> >> >> >> >
> >> >> >> > On 05/09/12 17:56, Larry Martell wrote:
> >> >> >> >
> >> >> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
> >> >> >> > 
> >> >> >> > wrote:
> >> >> >> >
> >> >> >> > I don't see why not.
> >> >> >> >
> >> >> >> > I've been trying to do that, but it's still complaining.
> >> >> >> >
> >> >> >> > Are you running unit tests (testing scripts) or are you
> >> >> >> > just using the browser for testing?
> >> >> >> >
> >> >> >> > I'm trying to do performance measuring. I have a list of all the
> >> >> >> > urls
> >> >> >> > accessed over the past few months by a client, along with
> metrics
> >> >> >> > on
> >> >> >> > their execution times. I want to run all those on a new server
> >> >> >> > we've
> >> >> >> > set up and collect metrics and compare them. I have a python
> >> >> >> > script
> >> >> >> > that uses urllib2 but, I can't run anything without logging in.
> >> >> >> > I've
> >> >> >> > tried to login from python, but I 

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
Thanks Kurtis!


On Wed, Sep 5, 2012 at 2:48 PM, Kurtis Mullins  wrote:
> Sure,
>
> To submit a cookie, check this out:
> http://stackoverflow.com/questions/3334809/python-urllib2-how-to-send-cookie-with-urlopen-request
>
> To harvest a CSRF Token from a page (for example, as part of a form), here's
> one example solution I found:
> http://stackoverflow.com/questions/3145178/get-contents-of-a-tags-using-python
> -- of course you'd want to grab the appropriate HTML Element.
>
> Here's an example of setting and getting cookies:
> http://stackoverflow.com/questions/5606083/how-to-set-and-retrieve-cookie-in-http-header-in-python
>
> Here's some docs on the how to make the CSRF System happy:
> https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-it-works
>
> On Wed, Sep 5, 2012 at 2:38 PM, Larry Martell 
> wrote:
>>
>> I have no idea how that would be done (neither extracting the token
>> nor passing it via urllib). I'm googling this, but if you know and
>> want to share, that would be great.
>>
>> On Wed, Sep 5, 2012 at 1:50 PM, Kurtis Mullins 
>> wrote:
>> > Actually, I've got another idea for you. You mentioned you wanted to
>> > simply
>> > access using urllib. Maybe you could create a small script to extract a
>> > CSRF
>> > token from the login page, login with a known (test) user, and continue
>> > passing and extracting the CSRF token as needed?
>> >
>> >
>> > On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell 
>> > wrote:
>> >>
>> >> Thanks - but now I'm getting
>> >>
>> >> NameError: "global name 'get_backends' is not defined"
>> >>
>> >>
>> >> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>> >>  wrote:
>> >> > Looks like you just need a quick:
>> >> >
>> >> > from django.contrib.auth.models import User
>> >> >
>> >> > towards the top :)
>> >> >
>> >> >
>> >> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >>
>> >> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>> >> >>  wrote:
>> >> >> > We are using a middleware to enforce a user login:
>> >> >> >
>> >> >> > class AutoAuthMiddleware(object):
>> >> >> > """
>> >> >> > Middleware for testing purpose only.
>> >> >> > Can enforce the user login.
>> >> >> > """
>> >> >> >
>> >> >> > def process_request(self, request):
>> >> >> > enforce_user = request.GET.get("enforce_user", None)
>> >> >> > if hasattr(request, "user") and not enforce_user:
>> >> >> > return
>> >> >> >
>> >> >> > user = User.objects.filter(username = enforce_user)
>> >> >>
>> >> >>
>> >> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>> >> >> above line. This is the same issue I was running into when I was
>> >> >> trying to hard code the initialization of a request.user object.
>> >> >> Where
>> >> >> is that defined?
>> >> >>
>> >> >>
>> >> >> > if user:
>> >> >> > backend = get_backends()[0]
>> >> >> > user = user[0]
>> >> >> > user.backend = "%s.%s" % (backend.__module__,
>> >> >> > backend.__class__.__name__) #fake authentication
>> >> >> > login(request, user)
>> >> >> >
>> >> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>> >> >> >
>> >> >> > Then you can just go to any url and add ?enforce_user=
>> >> >> >
>> >> >> >
>> >> >> >
>> >> >> > On 05/09/12 17:56, Larry Martell wrote:
>> >> >> >
>> >> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>> >> >> > 
>> >> >> > wrote:
>> >> >> >
>> >> >> > I don't see why not.
>> >> >> >
>> >> >> > I've been trying to do that, but it's still complaining.
>> >> >> >
>> >> >> > Are you running unit tests (testing scripts) or are you
>> >> >> > just using the browser for testing?
>> >> >> >
>> >> >> > I'm trying to do performance measuring. I have a list of all the
>> >> >> > urls
>> >> >> > accessed over the past few months by a client, along with metrics
>> >> >> > on
>> >> >> > their execution times. I want to run all those on a new server
>> >> >> > we've
>> >> >> > set up and collect metrics and compare them. I have a python
>> >> >> > script
>> >> >> > that uses urllib2 but, I can't run anything without logging in.
>> >> >> > I've
>> >> >> > tried to login from python, but I get a 403. I also tried using
>> >> >> > the
>> >> >> > requests module - that doesn't give me the 403, but doesn't log me
>> >> >> > in
>> >> >> > - it just returns the login page as if the login failed.
>> >> >> >
>> >> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell
>> >> >> > 
>> >> >> > wrote:
>> >> >> >
>> >> >> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
>> >> >> > 
>> >> >> > wrote:
>> >> >> >
>> >> >> > If any of your templates/views depend upon a request.user object,
>> >> >> > you'll

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
Sure,

To submit a cookie, check this out:
http://stackoverflow.com/questions/3334809/python-urllib2-how-to-send-cookie-with-urlopen-request

To harvest a CSRF Token from a page (for example, as part of a form),
here's one example solution I found:
http://stackoverflow.com/questions/3145178/get-contents-of-a-tags-using-python
--
of course you'd want to grab the appropriate HTML Element.

Here's an example of setting and getting cookies:
http://stackoverflow.com/questions/5606083/how-to-set-and-retrieve-cookie-in-http-header-in-python

Here's some docs on the how to make the CSRF System happy:
https://docs.djangoproject.com/en/dev/ref/contrib/csrf/#how-it-works

On Wed, Sep 5, 2012 at 2:38 PM, Larry Martell wrote:

> I have no idea how that would be done (neither extracting the token
> nor passing it via urllib). I'm googling this, but if you know and
> want to share, that would be great.
>
> On Wed, Sep 5, 2012 at 1:50 PM, Kurtis Mullins 
> wrote:
> > Actually, I've got another idea for you. You mentioned you wanted to
> simply
> > access using urllib. Maybe you could create a small script to extract a
> CSRF
> > token from the login page, login with a known (test) user, and continue
> > passing and extracting the CSRF token as needed?
> >
> >
> > On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell 
> > wrote:
> >>
> >> Thanks - but now I'm getting
> >>
> >> NameError: "global name 'get_backends' is not defined"
> >>
> >>
> >> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
> >>  wrote:
> >> > Looks like you just need a quick:
> >> >
> >> > from django.contrib.auth.models import User
> >> >
> >> > towards the top :)
> >> >
> >> >
> >> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell <
> larry.mart...@gmail.com>
> >> > wrote:
> >> >>
> >> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
> >> >>  wrote:
> >> >> > We are using a middleware to enforce a user login:
> >> >> >
> >> >> > class AutoAuthMiddleware(object):
> >> >> > """
> >> >> > Middleware for testing purpose only.
> >> >> > Can enforce the user login.
> >> >> > """
> >> >> >
> >> >> > def process_request(self, request):
> >> >> > enforce_user = request.GET.get("enforce_user", None)
> >> >> > if hasattr(request, "user") and not enforce_user:
> >> >> > return
> >> >> >
> >> >> > user = User.objects.filter(username = enforce_user)
> >> >>
> >> >>
> >> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
> >> >> above line. This is the same issue I was running into when I was
> >> >> trying to hard code the initialization of a request.user object.
> Where
> >> >> is that defined?
> >> >>
> >> >>
> >> >> > if user:
> >> >> > backend = get_backends()[0]
> >> >> > user = user[0]
> >> >> > user.backend = "%s.%s" % (backend.__module__,
> >> >> > backend.__class__.__name__) #fake authentication
> >> >> > login(request, user)
> >> >> >
> >> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
> >> >> >
> >> >> > Then you can just go to any url and add ?enforce_user=
> >> >> >
> >> >> >
> >> >> >
> >> >> > On 05/09/12 17:56, Larry Martell wrote:
> >> >> >
> >> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
> >> >> > 
> >> >> > wrote:
> >> >> >
> >> >> > I don't see why not.
> >> >> >
> >> >> > I've been trying to do that, but it's still complaining.
> >> >> >
> >> >> > Are you running unit tests (testing scripts) or are you
> >> >> > just using the browser for testing?
> >> >> >
> >> >> > I'm trying to do performance measuring. I have a list of all the
> urls
> >> >> > accessed over the past few months by a client, along with metrics
> on
> >> >> > their execution times. I want to run all those on a new server
> we've
> >> >> > set up and collect metrics and compare them. I have a python script
> >> >> > that uses urllib2 but, I can't run anything without logging in.
> I've
> >> >> > tried to login from python, but I get a 403. I also tried using the
> >> >> > requests module - that doesn't give me the 403, but doesn't log me
> in
> >> >> > - it just returns the login page as if the login failed.
> >> >> >
> >> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell
> >> >> > 
> >> >> > wrote:
> >> >> >
> >> >> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
> >> >> > 
> >> >> > wrote:
> >> >> >
> >> >> > If any of your templates/views depend upon a request.user object,
> >> >> > you'll
> >> >> > run
> >> >> > into issues because that will not exist without "logging in". I'm
> not
> >> >> > sure
> >> >> > of a good way around this off-hand without knowing more about your
> >> >> > site.
> >> >> > Sorry!
> >> >> >
> >> >> > Yes, they do depend on a request.user object. Can I hard code the
> >> >> > 

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
I got Anthony's code to work by adding the appropriate imports:

from django.contrib.auth.models import User
from django.contrib.auth import get_backends
from django.contrib.auth import login

Thanks very much!!

On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell  wrote:
> Thanks - but now I'm getting
>
> NameError: "global name 'get_backends' is not defined"
>
>
> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>  wrote:
>> Looks like you just need a quick:
>>
>> from django.contrib.auth.models import User
>>
>> towards the top :)
>>
>>
>> On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
>> wrote:
>>>
>>> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>>>  wrote:
>>> > We are using a middleware to enforce a user login:
>>> >
>>> > class AutoAuthMiddleware(object):
>>> > """
>>> > Middleware for testing purpose only.
>>> > Can enforce the user login.
>>> > """
>>> >
>>> > def process_request(self, request):
>>> > enforce_user = request.GET.get("enforce_user", None)
>>> > if hasattr(request, "user") and not enforce_user:
>>> > return
>>> >
>>> > user = User.objects.filter(username = enforce_user)
>>>
>>>
>>> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>>> above line. This is the same issue I was running into when I was
>>> trying to hard code the initialization of a request.user object. Where
>>> is that defined?
>>>
>>>
>>> > if user:
>>> > backend = get_backends()[0]
>>> > user = user[0]
>>> > user.backend = "%s.%s" % (backend.__module__,
>>> > backend.__class__.__name__) #fake authentication
>>> > login(request, user)
>>> >
>>> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>>> >
>>> > Then you can just go to any url and add ?enforce_user=
>>> >
>>> >
>>> >
>>> > On 05/09/12 17:56, Larry Martell wrote:
>>> >
>>> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>>> > 
>>> > wrote:
>>> >
>>> > I don't see why not.
>>> >
>>> > I've been trying to do that, but it's still complaining.
>>> >
>>> > Are you running unit tests (testing scripts) or are you
>>> > just using the browser for testing?
>>> >
>>> > I'm trying to do performance measuring. I have a list of all the urls
>>> > accessed over the past few months by a client, along with metrics on
>>> > their execution times. I want to run all those on a new server we've
>>> > set up and collect metrics and compare them. I have a python script
>>> > that uses urllib2 but, I can't run anything without logging in. I've
>>> > tried to login from python, but I get a 403. I also tried using the
>>> > requests module - that doesn't give me the 403, but doesn't log me in
>>> > - it just returns the login page as if the login failed.
>>> >
>>> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
>>> > wrote:
>>> >
>>> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
>>> > 
>>> > wrote:
>>> >
>>> > If any of your templates/views depend upon a request.user object, you'll
>>> > run
>>> > into issues because that will not exist without "logging in". I'm not
>>> > sure
>>> > of a good way around this off-hand without knowing more about your site.
>>> > Sorry!
>>> >
>>> > Yes, they do depend on a request.user object. Can I hard code the
>>> > initialization of it?
>>> >
>>> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
>>> > wrote:
>>> >
>>> > We have a django app that requires the users to login. For some
>>> > testing we want to do, we want to disable this so the app can be run
>>> > without logging in. Is there some way to easily do this? I've tried
>>> > commenting out all the @login_required decorations, but then I was
>>> > getting a 403. I tried commenting out the 'if not
>>> > controller.has_access' lines, but then I was getting 'Report.owner"
>>> > must be a "User" instance.' Before I hack up the code any more, is
>>> > there some way to just globally disable the need to login?
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "Django users" group.
>>> > To post to this group, send email to django-users@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > django-users+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/django-users?hl=en.
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "Django users" group.
>>> > To post to this group, send email to django-users@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > django-users+unsubscr...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/django-users?hl=en.
>>> >
>>> > --
>>> > You 

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
I have no idea how that would be done (neither extracting the token
nor passing it via urllib). I'm googling this, but if you know and
want to share, that would be great.

On Wed, Sep 5, 2012 at 1:50 PM, Kurtis Mullins  wrote:
> Actually, I've got another idea for you. You mentioned you wanted to simply
> access using urllib. Maybe you could create a small script to extract a CSRF
> token from the login page, login with a known (test) user, and continue
> passing and extracting the CSRF token as needed?
>
>
> On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell 
> wrote:
>>
>> Thanks - but now I'm getting
>>
>> NameError: "global name 'get_backends' is not defined"
>>
>>
>> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>>  wrote:
>> > Looks like you just need a quick:
>> >
>> > from django.contrib.auth.models import User
>> >
>> > towards the top :)
>> >
>> >
>> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
>> > wrote:
>> >>
>> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>> >>  wrote:
>> >> > We are using a middleware to enforce a user login:
>> >> >
>> >> > class AutoAuthMiddleware(object):
>> >> > """
>> >> > Middleware for testing purpose only.
>> >> > Can enforce the user login.
>> >> > """
>> >> >
>> >> > def process_request(self, request):
>> >> > enforce_user = request.GET.get("enforce_user", None)
>> >> > if hasattr(request, "user") and not enforce_user:
>> >> > return
>> >> >
>> >> > user = User.objects.filter(username = enforce_user)
>> >>
>> >>
>> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>> >> above line. This is the same issue I was running into when I was
>> >> trying to hard code the initialization of a request.user object. Where
>> >> is that defined?
>> >>
>> >>
>> >> > if user:
>> >> > backend = get_backends()[0]
>> >> > user = user[0]
>> >> > user.backend = "%s.%s" % (backend.__module__,
>> >> > backend.__class__.__name__) #fake authentication
>> >> > login(request, user)
>> >> >
>> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>> >> >
>> >> > Then you can just go to any url and add ?enforce_user=
>> >> >
>> >> >
>> >> >
>> >> > On 05/09/12 17:56, Larry Martell wrote:
>> >> >
>> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>> >> > 
>> >> > wrote:
>> >> >
>> >> > I don't see why not.
>> >> >
>> >> > I've been trying to do that, but it's still complaining.
>> >> >
>> >> > Are you running unit tests (testing scripts) or are you
>> >> > just using the browser for testing?
>> >> >
>> >> > I'm trying to do performance measuring. I have a list of all the urls
>> >> > accessed over the past few months by a client, along with metrics on
>> >> > their execution times. I want to run all those on a new server we've
>> >> > set up and collect metrics and compare them. I have a python script
>> >> > that uses urllib2 but, I can't run anything without logging in. I've
>> >> > tried to login from python, but I get a 403. I also tried using the
>> >> > requests module - that doesn't give me the 403, but doesn't log me in
>> >> > - it just returns the login page as if the login failed.
>> >> >
>> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >
>> >> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
>> >> > 
>> >> > wrote:
>> >> >
>> >> > If any of your templates/views depend upon a request.user object,
>> >> > you'll
>> >> > run
>> >> > into issues because that will not exist without "logging in". I'm not
>> >> > sure
>> >> > of a good way around this off-hand without knowing more about your
>> >> > site.
>> >> > Sorry!
>> >> >
>> >> > Yes, they do depend on a request.user object. Can I hard code the
>> >> > initialization of it?
>> >> >
>> >> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >
>> >> > We have a django app that requires the users to login. For some
>> >> > testing we want to do, we want to disable this so the app can be run
>> >> > without logging in. Is there some way to easily do this? I've tried
>> >> > commenting out all the @login_required decorations, but then I was
>> >> > getting a 403. I tried commenting out the 'if not
>> >> > controller.has_access' lines, but then I was getting 'Report.owner"
>> >> > must be a "User" instance.' Before I hack up the code any more, is
>> >> > there some way to just globally disable the need to login?
>> >> >
>> >> > --
>> >> > You received this message because you are subscribed to the Google
>> >> > Groups
>> >> > "Django users" group.
>> >> > To post to this group, send email to django-users@googlegroups.com.
>> >> > To unsubscribe from this group, send email to
>> 

Re: How to use FTP to upload files with Django?

2012-09-05 Thread Amyth Arora
To accept i guess as he said , he want his users to be able to upload
files...

On Wed, Sep 5, 2012 at 11:53 PM, Kurtis Mullins wrote:

> Do you want to use FTP to serve or accept the files?
>
> On Wed, Sep 5, 2012 at 2:14 PM, Mando  wrote:
>
>> Would this work -> nginx-gridfs 
>> ?
>>
>>
>> On Wednesday, September 5, 2012 1:09:25 AM UTC-5, Chaney Lee wrote:
>>>
>>> I just want to allow users uploading some videos to server in my
>>> website.I want to use FTP.So ,how to realize it?
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/f-vzQMOMSpoJ.
>>
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_
http://techstricks.com/

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



Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread Amyth Arora
To be frank , i am not really familiar with all possibilities of GB phone
numbers, if you could throw some light on this, i might be able to help ya.

On Wed, Sep 5, 2012 at 5:59 PM, g1smd.1  wrote:

>
> Thanks for the reply and information.
>
>
> The jQuery validation routines for GB telephone numbers contain
> significant errors and shortcomings. I already posted some patches
> correcting many of those problems at least a month ago, but they haven't
> been reviewed yet.
>
>
> The new Python/django telephone number validation code I am proposing here
> is far more comprehensive and has much more detailed range and length
> checking. Similar code already works fine in PHP and Java elsewhere, but I
> am having trouble converting it all to Python.
>
> I have added some Python logic and code to the initial RegEx patterns that
> I posted yesterday, but I now need help to finish it off and get it
> working. I am not at all familiar with the Python syntax and the manual is
> somewhat terse and obtuse.
>
> I had a problem with GitHub this morning, so the pull request is now at
> https://github.com/django/django/pull/324
>
> The code so far, can be found at:
> https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py
>
> I'm guessing that someone proficient in Python could finish it off in a
> couple of hours or less.
>
> Any volunteers?
>
>
>
>
> On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote:
>>
>> you can alternatively use jquery to validate the field, i do not have the
>> link handy as m on my phone right now but google validation engine, it is
>> one of the most powerful jquery validation library which also has builtin
>> method of validating uk phone numbers.
>> On Sep 4, 2012 5:00 AM, "g1smd.1"  wrote:
>>
>>> I see that there are routines for validating telephone numbers in forms
>>> in Django for several countries.
>>>
>>> The code for that can usually be found in the forms.py file located in
>>> the various country folders here:
>>> https://github.com/django/**django/tree/master/django/**
>>> contrib/localflavor
>>>
>>> So far, there is nothing for GB numbers, here:
>>> https://github.com/django/**django/tree/master/django/**
>>> contrib/localflavor/gb
>>>
>>> I've written a bunch of RegEx patterns to get this functionality
>>> started. The patterns are 100% fully tested. All that's needed is a few
>>> lines of python logic to string them together. The details can be found at:
>>> https://github.com/django/**django/pull/316/files
>>>
>>> My python foo is almost zero. Anyone care to have a go at getting this
>>> to work?
>>>
>>> RegEx 1 checks the user entered something that looks like a GB telephone
>>> number:
>>> 020  3000  
>>> 02075  567  234
>>> 0114  223  4567
>>> 01145  345  567
>>> +44  1213  456  789
>>> 00  44  (0)  1697  73555
>>> 011  44  11  4890  2345
>>> and several other formats, without worrying if the format is correct for
>>> this particular number (but read on). It allows for national or
>>> international format, even for two common international dial prefixes. What
>>> is most important is that the user enters the right number of digits. Don't
>>> constrain the user to use a particular format for entry.
>>> "Be lenient in what you accept, be strict in what you send." (Postel's
>>> Law)
>>>
>>> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in
>>> $2 (so you know if international or national format was used on input), and
>>> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.
>>>
>>> RegEx 3 tests the NSN part of the number is in a valid range and has the
>>> right number of digits for that range (GB numbers can be 9 or 10 digits
>>> long). This RegEx pattern is very detailed. You can say that a number is
>>> possible or is invalid with this RegEx.
>>>
>>> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how
>>> a GB number should be formatted, detailed by number length and initial
>>> digits. These rules cover all GB numbers.
>>>
>>> The last bit is to add the 0 or +44 back on, and append the original
>>> extension number (if present) and present it back to the user.
>>>
>>> 020  3000   => Valid: 020  3000  
>>> 02075  567  234 => Valid: 020  7556  7234
>>> 0114  223  4567 => Valid: 0114  223  4567
>>> 01145  345  567 => Valid: 0114  534  5567
>>> +44  1213  456  789 => Valid: +44  121  345  6789
>>> 00  44  (0)  1697  73555 => Valid: +44  16977  3555
>>> 011  44  11  4890  2345 => Valid: +44  114  890  2345
>>> 0623 111 3456 => NOT VALID
>>>
>>>
>>>  --
>>> You received this message because you are subscribed to the Google
>>> Groups "Django users" group.
>>> To view this discussion on the web visit https://groups.google.com/d/**
>>> 

Re: How to use FTP to upload files with Django?

2012-09-05 Thread Kurtis Mullins
Do you want to use FTP to serve or accept the files?

On Wed, Sep 5, 2012 at 2:14 PM, Mando  wrote:

> Would this work -> nginx-gridfs ?
>
>
> On Wednesday, September 5, 2012 1:09:25 AM UTC-5, Chaney Lee wrote:
>>
>> I just want to allow users uploading some videos to server in my
>> website.I want to use FTP.So ,how to realize it?
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/f-vzQMOMSpoJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
The code is what Anthony posted, and the traceback is simply:


Traceback:
File 
"/opt/local/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/handlers/base.py"
in get_response
  89. response = middleware_method(request)
File "/usr/local/motor/motor/../motor/middleware.py" in process_request
  29. backend = get_backends()[0]

Exception Type: NameError at /report/CDSEM/RawFile/
Exception Value: global name 'get_backends' is not defined


And I was under the impression that his middleware code would
eliminate the need to disable all login_required decorators, etc.


On Wed, Sep 5, 2012 at 1:48 PM, Amyth Arora  wrote:
> could you post the traceback and the respective code. Most probably you'll
> need to disable all login_required decorators and also disable your user
> login based template tags in all the templates for it to work properly.
>
>
> On Wed, Sep 5, 2012 at 10:36 PM, Larry Martell 
> wrote:
>>
>> Thanks - but now I'm getting
>>
>> NameError: "global name 'get_backends' is not defined"
>>
>>
>> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>>  wrote:
>> > Looks like you just need a quick:
>> >
>> > from django.contrib.auth.models import User
>> >
>> > towards the top :)
>> >
>> >
>> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
>> > wrote:
>> >>
>> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>> >>  wrote:
>> >> > We are using a middleware to enforce a user login:
>> >> >
>> >> > class AutoAuthMiddleware(object):
>> >> > """
>> >> > Middleware for testing purpose only.
>> >> > Can enforce the user login.
>> >> > """
>> >> >
>> >> > def process_request(self, request):
>> >> > enforce_user = request.GET.get("enforce_user", None)
>> >> > if hasattr(request, "user") and not enforce_user:
>> >> > return
>> >> >
>> >> > user = User.objects.filter(username = enforce_user)
>> >>
>> >>
>> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>> >> above line. This is the same issue I was running into when I was
>> >> trying to hard code the initialization of a request.user object. Where
>> >> is that defined?
>> >>
>> >>
>> >> > if user:
>> >> > backend = get_backends()[0]
>> >> > user = user[0]
>> >> > user.backend = "%s.%s" % (backend.__module__,
>> >> > backend.__class__.__name__) #fake authentication
>> >> > login(request, user)
>> >> >
>> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>> >> >
>> >> > Then you can just go to any url and add ?enforce_user=
>> >> >
>> >> >
>> >> >
>> >> > On 05/09/12 17:56, Larry Martell wrote:
>> >> >
>> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>> >> > 
>> >> > wrote:
>> >> >
>> >> > I don't see why not.
>> >> >
>> >> > I've been trying to do that, but it's still complaining.
>> >> >
>> >> > Are you running unit tests (testing scripts) or are you
>> >> > just using the browser for testing?
>> >> >
>> >> > I'm trying to do performance measuring. I have a list of all the urls
>> >> > accessed over the past few months by a client, along with metrics on
>> >> > their execution times. I want to run all those on a new server we've
>> >> > set up and collect metrics and compare them. I have a python script
>> >> > that uses urllib2 but, I can't run anything without logging in. I've
>> >> > tried to login from python, but I get a 403. I also tried using the
>> >> > requests module - that doesn't give me the 403, but doesn't log me in
>> >> > - it just returns the login page as if the login failed.
>> >> >
>> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >
>> >> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
>> >> > 
>> >> > wrote:
>> >> >
>> >> > If any of your templates/views depend upon a request.user object,
>> >> > you'll
>> >> > run
>> >> > into issues because that will not exist without "logging in". I'm not
>> >> > sure
>> >> > of a good way around this off-hand without knowing more about your
>> >> > site.
>> >> > Sorry!
>> >> >
>> >> > Yes, they do depend on a request.user object. Can I hard code the
>> >> > initialization of it?
>> >> >
>> >> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell
>> >> > 
>> >> > wrote:
>> >> >
>> >> > We have a django app that requires the users to login. For some
>> >> > testing we want to do, we want to disable this so the app can be run
>> >> > without logging in. Is there some way to easily do this? I've tried
>> >> > commenting out all the @login_required decorations, but then I was
>> >> > getting a 403. I tried commenting out the 'if not
>> >> > controller.has_access' lines, but then I was getting 'Report.owner"

Re: Problem with Django recaptcha

2012-09-05 Thread Amyth Arora
This is because the re-captcha API is not able to recognize the keys ? do
you have the re-Captcha settings set to automatic  by any chance ? if so
change it to manual and add the domains you'd want to work it on and you
should have it working...


On Wed, Sep 5, 2012 at 6:19 PM, Lakshmen  wrote:

> I have git cloned the django-recaptcha(
> https://github.com/praekelt/django-recaptcha) into my directory and have
> included the public and private keys in my settings.py and captcha =
> ReCaptchaField(). But i get this error everytime i run the forms: 
> Captcha:Input error: k: Format of site key was invalid. How do i avoid this 
> error?
> Any idea? the original question is here:
> http://stackoverflow.com/questions/12251274/cant-get-the-captcha-to-appear. 
> Need some help...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/Gcrs76paRTAJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_
http://techstricks.com/

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



Re: How to use FTP to upload files with Django?

2012-09-05 Thread Mando
Would this work -> nginx-gridfs ?

On Wednesday, September 5, 2012 1:09:25 AM UTC-5, Chaney Lee wrote:
>
> I just want to allow users uploading some videos to server in my website.I 
> want to use FTP.So ,how to realize it?

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



Re: Choosing a JS framework to go together with Django

2012-09-05 Thread Amyth Arora
I am not sure what you are exactly trying to achieve. A more issue specific
topic would have been easy to understand though i can suggest you following
frameworks (in particular order):

1. KnockoutJS
2. BackboneJS
3. Cappucino
4. Ember.Js
5. Sammy.JS
6. Spine.JS
7. JavascriptMVC

On Wed, Sep 5, 2012 at 8:04 PM, Kelly Nicholes wrote:

> It would be a travesty to not mention backbone.js.
>
>
> On Tuesday, September 4, 2012 7:39:49 AM UTC-6, dotnetCarpenter wrote:
>>
>> Hi all.
>>
>> I'm new here and just took over a Django project for the first time. I'm
>> still getting to grip with Django but as a front end dev for the past 5
>> years, I'm also looking for a client-side library/framework to go together
>> with my project.
>> My requirements for a JS framework is that it:
>>
>>1. is unobtrusive (Django rendered HTML will be shown to scraper bots
>>like google)
>>2. provides some sort of structure (MVC, MVP, MVVM ect.)
>>3. embraces standards
>>4. doesn't conflict with Django templates or does so intentionally
>>5. ideally uses the same template language as Django
>>
>> In the ideal world a request/response scenario would look like this:
>>
>>1. A client make a (HTTP) request to the (django powered) web site
>>with (HTTP) Accept header text/html
>>2. Django response in the usual way by rendering the assign View
>>(django template)
>>3. The view figure out if JS is supported (implemented in JS). If no,
>>this scenario stays in loop 1-3. If yes, then 4.
>>4. The client (usually a browser) wire up the client-side app
>>structure, hook in to URI links, add transitions between views,
>>data-bindings ect.
>>5. Subsequent request are now handle by the JS framework, either user
>>initiated (e.g. clicking a link) or app initiated (e.g. pulling extra
>>data), that will modify the request header to Accept header
>>application/json or application/django-template.
>>6. If django receive a request with an application/django-template
>>header it will serve the view as plain text. E.g. Content-type: 
>> text/plain.
>>On the other hand if django receive a request with application/json, it
>>will send the object model defined in the view as JSON.
>>7. The client-side JS framework will receive a template to render in
>>the first request and the data to render in the template in the second
>>request. A promise object could be used to synchronize the two calls.
>>
>> This way django will work as intended for non JS clients and silently
>> convert to a RIA in clients that supports JS, with minimal double work for
>> the two execution contexts.
>> A big pro in this is the fact that both django and the JS framework share
>> template and data (only has to defined once - in django) - we'll duck type
>> all the way. But does this JS framework exist? Does anyone have any
>> experience with working with django and JS frameworks? Is there any obvious
>> pitfalls in my ideal world scenario in regard to Django? And finally, is it
>> possible to serve templates as plain text with django?
>>
>>
>> Cheers, Jon and thanks in advance
>>
>> PS. I accidentally cross-posted this to the Django Developers group
>> before realizing it was the wrong forum. Sorry about that.
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/PF4D-xIEovcJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_
http://techstricks.com/

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



Re: bound field object - dynamic forms

2012-09-05 Thread Amyth Arora
check if it is being passed to template.

{% if issue %}
  {{ issue }}
{% else %}
  Issue was not passed #Debug
{% endif %}

On Wed, Sep 5, 2012 at 8:45 PM, Mando  wrote:

> are you passing it to the template?
>
>
> On Wednesday, September 5, 2012 7:09:57 AM UTC-5, mjh wrote:
>>
>> tried {{ issue.x }} x = 0,1,2,3 but nothing is displayed in the template
>>
>> any other thoughts?
>>
>> On Monday, 3 September 2012 22:53:03 UTC+1, somecallitblues wrote:
>>>
>>> Try {{ issue.0}} and {{ issue.1}}
>>> On Sep 4, 2012 5:55 AM, "mjh"  wrote:
>>>
 Hi all - not sure how to show the choicefield dropdown in my template?

 Am generating a dynamic form (note: for issue in issues in forms.py) and 
 appending the fields to self.issue_list

 in the template I am looping over these fields ({% for issue in 
 form.issue_list %}) and can write out the label {{ issue.label }} but if 
 write out {{ issue }} I simply get the bound field object written to 
 template ().

 Question is how do I get the html dropdown to display in the template??



 >>> forms.py
 def __init__(self, item, *args, **kwargs):
 super(ItemAnalysisForm, self).__init__(*args, **kwargs)
 issue_choice = (('1', 'Reduced'),
 ('2', 'Maintained'),
 ('3', 'Increased')
 )
 issues = item.issue.all()

 self.issue_list = []
 self.a_list = []
 # generate dynamic issue dropdowns...
 for issue in issues:
 self.fields['issue-' + str(issue.pk)] = 
 forms.ChoiceField(label=issue.**name , 
 choices=issue_choice, required=False)
 self.a_list.append(self.**fields['issue-' + str(issue.pk)])
 self.issue_list.append(self.**fields['issue-' + str(issue.pk)])
 self.fields['text'] = forms.CharField(label='text', required=True, 
 widget=forms.Textarea(attrs={'**rows':25,'cols':'100'}))
 self.a_list.append(self.**fields['text'])


 >>> template
 {% 
 csrf_token %}
 
 Individual Issue Outcome:
 
 {% for issue in form.issue_list %}
 
 {{ issue.label }}: {{ issue }}
 
 {% endfor %}
 
 
 
 Comment:
 
 {{ form.text }}
 

 

  --
 You received this message because you are subscribed to the Google
 Groups "Django users" group.
 To view this discussion on the web visit https://groups.google.com/d/**
 msg/django-users/-/**XSMbUGOJyvMJ
 .
 To post to this group, send email to django...@googlegroups.com.
 To unsubscribe from this group, send email to
 django-users...@googlegroups.**com.
 For more options, visit this group at http://groups.google.com/**
 group/django-users?hl=en
 .

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



-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_
http://techstricks.com/

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



Re: Django Interview Questions

2012-09-05 Thread Amyth Arora
after reading this guide it seems, the interviewer who asks such questions
himself is new to django or more importantly to programming. When it comes
to programming or codes , most of the interviewers would ask you logic
based questions instead of framework based questions as technologies like
django come and go on a daily basis. if your logic is clear, you can code
in any language based on any CMS' or frameworks.

On Wed, Sep 5, 2012 at 10:31 PM, Kurtis Mullins wrote:

> Yeah, I think this guide is a little crazy. If I'm getting interviewed
> based on questions I can't answer without looking up relevant documentation
> then I'd probably look bad even though the interviewer is the one lacking
> the required knowledge to get the job done.
>
> Maybe that's why I don't interview too often :) Just my 2 cents.
>
>
> On Wed, Sep 5, 2012 at 12:57 PM, Aaron C. de Bruyn wrote:
>
>> I disagree with the "how to install" section.
>> I use Nginx and uwsgi to host Django applications.
>> There are other ways to deploy it too.
>>
>> The section makes it seem like the only 'real' way would be Apache.
>>
>> Lastly, it doesn't seem to touch on how a lot of people actually
>> install and deploy django projects.  My workflow is pretty simple
>> compared to what the install section says:
>>
>> apt-get install python-pip python-virtualenv virtualenvwrapper
>> cd code
>> mkvirtualenv some-django-project
>> pip install django
>> django-admin startproject somedjangoproject
>> cd somedjangoproject
>> python manage.py startapp app1
>>
>> Using virtualenv should also take care of the problem listed in
>> "Remove any old versions of Django".
>>
>> I'd hate for someone to not get the job because they give a
>> "non-textbook" answer. ;)
>>
>> -A
>>
>>
>> On Tue, Sep 4, 2012 at 5:10 AM, Stephen Anto 
>> wrote:
>> > Hi Guys,
>> >
>> > I have updated Django latest interview questions and answers. It may
>> cover
>> > all technical requirements of the interview.
>> >
>> > Vist http://www.f2finterview.com/web/Django/ for latest Django
>> interview
>> > questions and answers
>> >
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>



-- 
Thanks & Regards


Amyth [Admin - Techstricks]
Email - aroras.offic...@gmail.com, ad...@techstricks.com
Twitter - @a_myth_
http://techstricks.com/

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
Actually, I've got another idea for you. You mentioned you wanted to simply
access using urllib. Maybe you could create a small script to extract a
CSRF token from the login page, login with a known (test) user, and
continue passing and extracting the CSRF token as needed?

On Wed, Sep 5, 2012 at 1:06 PM, Larry Martell wrote:

> Thanks - but now I'm getting
>
> NameError: "global name 'get_backends' is not defined"
>
>
> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>  wrote:
> > Looks like you just need a quick:
> >
> > from django.contrib.auth.models import User
> >
> > towards the top :)
> >
> >
> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
> > wrote:
> >>
> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
> >>  wrote:
> >> > We are using a middleware to enforce a user login:
> >> >
> >> > class AutoAuthMiddleware(object):
> >> > """
> >> > Middleware for testing purpose only.
> >> > Can enforce the user login.
> >> > """
> >> >
> >> > def process_request(self, request):
> >> > enforce_user = request.GET.get("enforce_user", None)
> >> > if hasattr(request, "user") and not enforce_user:
> >> > return
> >> >
> >> > user = User.objects.filter(username = enforce_user)
> >>
> >>
> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
> >> above line. This is the same issue I was running into when I was
> >> trying to hard code the initialization of a request.user object. Where
> >> is that defined?
> >>
> >>
> >> > if user:
> >> > backend = get_backends()[0]
> >> > user = user[0]
> >> > user.backend = "%s.%s" % (backend.__module__,
> >> > backend.__class__.__name__) #fake authentication
> >> > login(request, user)
> >> >
> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
> >> >
> >> > Then you can just go to any url and add ?enforce_user=
> >> >
> >> >
> >> >
> >> > On 05/09/12 17:56, Larry Martell wrote:
> >> >
> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
> >> > 
> >> > wrote:
> >> >
> >> > I don't see why not.
> >> >
> >> > I've been trying to do that, but it's still complaining.
> >> >
> >> > Are you running unit tests (testing scripts) or are you
> >> > just using the browser for testing?
> >> >
> >> > I'm trying to do performance measuring. I have a list of all the urls
> >> > accessed over the past few months by a client, along with metrics on
> >> > their execution times. I want to run all those on a new server we've
> >> > set up and collect metrics and compare them. I have a python script
> >> > that uses urllib2 but, I can't run anything without logging in. I've
> >> > tried to login from python, but I get a 403. I also tried using the
> >> > requests module - that doesn't give me the 403, but doesn't log me in
> >> > - it just returns the login page as if the login failed.
> >> >
> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell <
> larry.mart...@gmail.com>
> >> > wrote:
> >> >
> >> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
> >> > 
> >> > wrote:
> >> >
> >> > If any of your templates/views depend upon a request.user object,
> you'll
> >> > run
> >> > into issues because that will not exist without "logging in". I'm not
> >> > sure
> >> > of a good way around this off-hand without knowing more about your
> site.
> >> > Sorry!
> >> >
> >> > Yes, they do depend on a request.user object. Can I hard code the
> >> > initialization of it?
> >> >
> >> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell <
> larry.mart...@gmail.com>
> >> > wrote:
> >> >
> >> > We have a django app that requires the users to login. For some
> >> > testing we want to do, we want to disable this so the app can be run
> >> > without logging in. Is there some way to easily do this? I've tried
> >> > commenting out all the @login_required decorations, but then I was
> >> > getting a 403. I tried commenting out the 'if not
> >> > controller.has_access' lines, but then I was getting 'Report.owner"
> >> > must be a "User" instance.' Before I hack up the code any more, is
> >> > there some way to just globally disable the need to login?
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Django users" group.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/django-users?hl=en.
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Django users" group.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > To unsubscribe from this group, send 

Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Amyth Arora
could you post the traceback and the respective code. Most probably you'll
need to disable all login_required decorators and also disable your user
login based template tags in all the templates for it to work properly.

On Wed, Sep 5, 2012 at 10:36 PM, Larry Martell wrote:

> Thanks - but now I'm getting
>
> NameError: "global name 'get_backends' is not defined"
>
>
> On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
>  wrote:
> > Looks like you just need a quick:
> >
> > from django.contrib.auth.models import User
> >
> > towards the top :)
> >
> >
> > On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
> > wrote:
> >>
> >> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
> >>  wrote:
> >> > We are using a middleware to enforce a user login:
> >> >
> >> > class AutoAuthMiddleware(object):
> >> > """
> >> > Middleware for testing purpose only.
> >> > Can enforce the user login.
> >> > """
> >> >
> >> > def process_request(self, request):
> >> > enforce_user = request.GET.get("enforce_user", None)
> >> > if hasattr(request, "user") and not enforce_user:
> >> > return
> >> >
> >> > user = User.objects.filter(username = enforce_user)
> >>
> >>
> >> I'm getting: 'NameError: "global name 'User' is not defined"' on the
> >> above line. This is the same issue I was running into when I was
> >> trying to hard code the initialization of a request.user object. Where
> >> is that defined?
> >>
> >>
> >> > if user:
> >> > backend = get_backends()[0]
> >> > user = user[0]
> >> > user.backend = "%s.%s" % (backend.__module__,
> >> > backend.__class__.__name__) #fake authentication
> >> > login(request, user)
> >> >
> >> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
> >> >
> >> > Then you can just go to any url and add ?enforce_user=
> >> >
> >> >
> >> >
> >> > On 05/09/12 17:56, Larry Martell wrote:
> >> >
> >> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
> >> > 
> >> > wrote:
> >> >
> >> > I don't see why not.
> >> >
> >> > I've been trying to do that, but it's still complaining.
> >> >
> >> > Are you running unit tests (testing scripts) or are you
> >> > just using the browser for testing?
> >> >
> >> > I'm trying to do performance measuring. I have a list of all the urls
> >> > accessed over the past few months by a client, along with metrics on
> >> > their execution times. I want to run all those on a new server we've
> >> > set up and collect metrics and compare them. I have a python script
> >> > that uses urllib2 but, I can't run anything without logging in. I've
> >> > tried to login from python, but I get a 403. I also tried using the
> >> > requests module - that doesn't give me the 403, but doesn't log me in
> >> > - it just returns the login page as if the login failed.
> >> >
> >> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell <
> larry.mart...@gmail.com>
> >> > wrote:
> >> >
> >> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
> >> > 
> >> > wrote:
> >> >
> >> > If any of your templates/views depend upon a request.user object,
> you'll
> >> > run
> >> > into issues because that will not exist without "logging in". I'm not
> >> > sure
> >> > of a good way around this off-hand without knowing more about your
> site.
> >> > Sorry!
> >> >
> >> > Yes, they do depend on a request.user object. Can I hard code the
> >> > initialization of it?
> >> >
> >> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell <
> larry.mart...@gmail.com>
> >> > wrote:
> >> >
> >> > We have a django app that requires the users to login. For some
> >> > testing we want to do, we want to disable this so the app can be run
> >> > without logging in. Is there some way to easily do this? I've tried
> >> > commenting out all the @login_required decorations, but then I was
> >> > getting a 403. I tried commenting out the 'if not
> >> > controller.has_access' lines, but then I was getting 'Report.owner"
> >> > must be a "User" instance.' Before I hack up the code any more, is
> >> > there some way to just globally disable the need to login?
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Django users" group.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > django-users+unsubscr...@googlegroups.com.
> >> > For more options, visit this group at
> >> > http://groups.google.com/group/django-users?hl=en.
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> >> > Groups
> >> > "Django users" group.
> >> > To post to this group, send email to django-users@googlegroups.com.
> >> > To unsubscribe from this group, send email to
> >> > 

Re: setting up Django Compressor

2012-09-05 Thread Phil
Hi Joni,

Yes I have 'compressor.finders.CompressorFinder' added. All the 
requirements are installed too I double checked them all, tried installing 
them all individually and it said they were all installed already. When I 
first setup the site it was using django1.3, but recently upgraded it. 

My static url setting is

STATIC_URL = '/media/'

and media is(for local setup)...

MEDIA_URL = 'http://127.0.0.1:8080/media/'

Not sure what's going on, might just try another compressor at this stage 
as I am not having any joy with this one.



On Sunday, September 2, 2012 3:38:27 PM UTC+1, Joni Bekenstein wrote:
>
> Just to cover the basics, did you follow all installation steps described 
> here:
> http://django_compressor.readthedocs.org/en/latest/quickstart/#installation
>
> Mainly adding 'compressor.finders.CompressorFinder' to STATICFILES_FINDERS
>
>
> Another thing kind of odd is that your css URL starts with /media/. Whats 
> your STATIC_URL and MEDIA_URL setting? Check this out: 
> http://django_compressor.readthedocs.org/en/latest/settings/#django.conf.settings.COMPRESS_URL
>
> It looks like its defaulting to MEDIA_URL, but you said you were using 
> Django 1.4, which should have STATIC_URL available.
>
>
> On Sunday, September 2, 2012 11:13:53 AM UTC-3, Phil wrote:
>>
>> Hi Joni,
>>
>> Thanks a million for reply.
>>
>> Yes I am using django runserver, its a working site just trying to get 
>> compressor working locally before moving to production. My css works fine 
>> without the compressor app. I can't see the file if I copy it in my url I 
>> get a 500 error and the "CACHE" folder doesn't seem to exist anywhere. I 
>> didn't have anything in my "urls.py" for media, but I added the following 
>> to see if it would help but it still didn't work...
>>
>> ***
>> if settings.DEBUG:
>> urlpatterns = patterns('',
>> url(r'^media/(?P.*)$', 'django.views.static.serve',
>> {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
>> url(r'', include('django.contrib.staticfiles.urls')),
>> ) + urlpatterns
>> ***
>>
>>
>>
>> On Saturday, September 1, 2012 3:09:42 PM UTC+1, Joni Bekenstein wrote:
>>>
>>> The generated css file seems to be in your media directory. If you copy 
>>> that URL, can you see the css file? Are you using Django's dev server 
>>> (runserver)? If so, did you add to your urls.py a view to serve the media 
>>> files? (and that view should only exist when DEBUG is true since in 
>>> production you're probably going to serve static files and media files 
>>> directly with your webserver)
>>
>>

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
Thanks - but now I'm getting

NameError: "global name 'get_backends' is not defined"


On Wed, Sep 5, 2012 at 12:59 PM, Kurtis Mullins
 wrote:
> Looks like you just need a quick:
>
> from django.contrib.auth.models import User
>
> towards the top :)
>
>
> On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell 
> wrote:
>>
>> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>>  wrote:
>> > We are using a middleware to enforce a user login:
>> >
>> > class AutoAuthMiddleware(object):
>> > """
>> > Middleware for testing purpose only.
>> > Can enforce the user login.
>> > """
>> >
>> > def process_request(self, request):
>> > enforce_user = request.GET.get("enforce_user", None)
>> > if hasattr(request, "user") and not enforce_user:
>> > return
>> >
>> > user = User.objects.filter(username = enforce_user)
>>
>>
>> I'm getting: 'NameError: "global name 'User' is not defined"' on the
>> above line. This is the same issue I was running into when I was
>> trying to hard code the initialization of a request.user object. Where
>> is that defined?
>>
>>
>> > if user:
>> > backend = get_backends()[0]
>> > user = user[0]
>> > user.backend = "%s.%s" % (backend.__module__,
>> > backend.__class__.__name__) #fake authentication
>> > login(request, user)
>> >
>> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
>> >
>> > Then you can just go to any url and add ?enforce_user=
>> >
>> >
>> >
>> > On 05/09/12 17:56, Larry Martell wrote:
>> >
>> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins
>> > 
>> > wrote:
>> >
>> > I don't see why not.
>> >
>> > I've been trying to do that, but it's still complaining.
>> >
>> > Are you running unit tests (testing scripts) or are you
>> > just using the browser for testing?
>> >
>> > I'm trying to do performance measuring. I have a list of all the urls
>> > accessed over the past few months by a client, along with metrics on
>> > their execution times. I want to run all those on a new server we've
>> > set up and collect metrics and compare them. I have a python script
>> > that uses urllib2 but, I can't run anything without logging in. I've
>> > tried to login from python, but I get a 403. I also tried using the
>> > requests module - that doesn't give me the 403, but doesn't log me in
>> > - it just returns the login page as if the login failed.
>> >
>> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
>> > wrote:
>> >
>> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins
>> > 
>> > wrote:
>> >
>> > If any of your templates/views depend upon a request.user object, you'll
>> > run
>> > into issues because that will not exist without "logging in". I'm not
>> > sure
>> > of a good way around this off-hand without knowing more about your site.
>> > Sorry!
>> >
>> > Yes, they do depend on a request.user object. Can I hard code the
>> > initialization of it?
>> >
>> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
>> > wrote:
>> >
>> > We have a django app that requires the users to login. For some
>> > testing we want to do, we want to disable this so the app can be run
>> > without logging in. Is there some way to easily do this? I've tried
>> > commenting out all the @login_required decorations, but then I was
>> > getting a 403. I tried commenting out the 'if not
>> > controller.has_access' lines, but then I was getting 'Report.owner"
>> > must be a "User" instance.' Before I hack up the code any more, is
>> > there some way to just globally disable the need to login?
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> > --
>> > You received this message because 

Re: Test driven development in Django framework

2012-09-05 Thread Javier Guerra Giraldez
On Wed, Sep 5, 2012 at 7:46 AM, jyria  wrote:
> What is your experience? Is it worth it, and is it possible?
>
> I tried it and found it quite difficult to follow guideline of unit testing
> -- testing a unit of code, a class for example. Maybe Im just ignorant, but
> I didnt see, how can I create registration app only with unit tests. The
> only way I could drive implementation with tests was using more like an
> integration testing approach: calling requests with data and asserting that
> new user was registered and that form was valid/invalid etc, but this goes
> against TDD as I understand it. So should I not worry about pure "unit
> testing" approach and use django client http request to validate
> RegistrationForm. Or I should write unit tests for RegistrationForm class?

TDD is not unit-testing

https://www.google.com/webhp?q=tdd%20is%20not%20unit%20testing


in short, it's like you've found: the tests you easily get with TDD
are more (but not exactly) like integration tests, because you test
features, not units.  The "test isolated units" mantra of unit-testing
requires different work.  There's nothing wrong in adding 'real'
unit-tests, but it's not required to do effective TDD.

I guess that since unittesting became so well known so long ago,
almost all test frameworks (including Python's and Django's) call
their base test class "UnitTest", but they're not; they're just tests.
 you make them feature tests, or integration tests, or unit tests, or
whatever kind of test.

now, about the pros/cons of unit-testing vs. other kinds of tests.
that's a whole debate that i'm not going to touch.

-- 
Javier

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



Re: Django Interview Questions

2012-09-05 Thread Kurtis Mullins
Yeah, I think this guide is a little crazy. If I'm getting interviewed
based on questions I can't answer without looking up relevant documentation
then I'd probably look bad even though the interviewer is the one lacking
the required knowledge to get the job done.

Maybe that's why I don't interview too often :) Just my 2 cents.

On Wed, Sep 5, 2012 at 12:57 PM, Aaron C. de Bruyn wrote:

> I disagree with the "how to install" section.
> I use Nginx and uwsgi to host Django applications.
> There are other ways to deploy it too.
>
> The section makes it seem like the only 'real' way would be Apache.
>
> Lastly, it doesn't seem to touch on how a lot of people actually
> install and deploy django projects.  My workflow is pretty simple
> compared to what the install section says:
>
> apt-get install python-pip python-virtualenv virtualenvwrapper
> cd code
> mkvirtualenv some-django-project
> pip install django
> django-admin startproject somedjangoproject
> cd somedjangoproject
> python manage.py startapp app1
>
> Using virtualenv should also take care of the problem listed in
> "Remove any old versions of Django".
>
> I'd hate for someone to not get the job because they give a
> "non-textbook" answer. ;)
>
> -A
>
>
> On Tue, Sep 4, 2012 at 5:10 AM, Stephen Anto 
> wrote:
> > Hi Guys,
> >
> > I have updated Django latest interview questions and answers. It may
> cover
> > all technical requirements of the interview.
> >
> > Vist http://www.f2finterview.com/web/Django/ for latest Django interview
> > questions and answers
> >
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
Looks like you just need a quick:

from django.contrib.auth.models import User

towards the top :)

On Wed, Sep 5, 2012 at 12:57 PM, Larry Martell wrote:

> On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
>  wrote:
> > We are using a middleware to enforce a user login:
> >
> > class AutoAuthMiddleware(object):
> > """
> > Middleware for testing purpose only.
> > Can enforce the user login.
> > """
> >
> > def process_request(self, request):
> > enforce_user = request.GET.get("enforce_user", None)
> > if hasattr(request, "user") and not enforce_user:
> > return
> >
> > user = User.objects.filter(username = enforce_user)
>
>
> I'm getting: 'NameError: "global name 'User' is not defined"' on the
> above line. This is the same issue I was running into when I was
> trying to hard code the initialization of a request.user object. Where
> is that defined?
>
>
> > if user:
> > backend = get_backends()[0]
> > user = user[0]
> > user.backend = "%s.%s" % (backend.__module__,
> > backend.__class__.__name__) #fake authentication
> > login(request, user)
> >
> > You can add that to your testing environnement MIDDLEWARE_CLASSES.
> >
> > Then you can just go to any url and add ?enforce_user=
> >
> >
> >
> > On 05/09/12 17:56, Larry Martell wrote:
> >
> > On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins  >
> > wrote:
> >
> > I don't see why not.
> >
> > I've been trying to do that, but it's still complaining.
> >
> > Are you running unit tests (testing scripts) or are you
> > just using the browser for testing?
> >
> > I'm trying to do performance measuring. I have a list of all the urls
> > accessed over the past few months by a client, along with metrics on
> > their execution times. I want to run all those on a new server we've
> > set up and collect metrics and compare them. I have a python script
> > that uses urllib2 but, I can't run anything without logging in. I've
> > tried to login from python, but I get a 403. I also tried using the
> > requests module - that doesn't give me the 403, but doesn't log me in
> > - it just returns the login page as if the login failed.
> >
> > On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
> > wrote:
> >
> > On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins  >
> > wrote:
> >
> > If any of your templates/views depend upon a request.user object, you'll
> > run
> > into issues because that will not exist without "logging in". I'm not
> > sure
> > of a good way around this off-hand without knowing more about your site.
> > Sorry!
> >
> > Yes, they do depend on a request.user object. Can I hard code the
> > initialization of it?
> >
> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
> > wrote:
> >
> > We have a django app that requires the users to login. For some
> > testing we want to do, we want to disable this so the app can be run
> > without logging in. Is there some way to easily do this? I've tried
> > commenting out all the @login_required decorations, but then I was
> > getting a 403. I tried commenting out the 'if not
> > controller.has_access' lines, but then I was getting 'Report.owner"
> > must be a "User" instance.' Before I hack up the code any more, is
> > there some way to just globally disable the need to login?
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > 

Re: Django Interview Questions

2012-09-05 Thread Aaron C. de Bruyn
I disagree with the "how to install" section.
I use Nginx and uwsgi to host Django applications.
There are other ways to deploy it too.

The section makes it seem like the only 'real' way would be Apache.

Lastly, it doesn't seem to touch on how a lot of people actually
install and deploy django projects.  My workflow is pretty simple
compared to what the install section says:

apt-get install python-pip python-virtualenv virtualenvwrapper
cd code
mkvirtualenv some-django-project
pip install django
django-admin startproject somedjangoproject
cd somedjangoproject
python manage.py startapp app1

Using virtualenv should also take care of the problem listed in
"Remove any old versions of Django".

I'd hate for someone to not get the job because they give a
"non-textbook" answer. ;)

-A


On Tue, Sep 4, 2012 at 5:10 AM, Stephen Anto  wrote:
> Hi Guys,
>
> I have updated Django latest interview questions and answers. It may cover
> all technical requirements of the interview.
>
> Vist http://www.f2finterview.com/web/Django/ for latest Django interview
> questions and answers
>

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
On Wed, Sep 5, 2012 at 12:21 PM, anthony tresontani
 wrote:
> We are using a middleware to enforce a user login:
>
> class AutoAuthMiddleware(object):
> """
> Middleware for testing purpose only.
> Can enforce the user login.
> """
>
> def process_request(self, request):
> enforce_user = request.GET.get("enforce_user", None)
> if hasattr(request, "user") and not enforce_user:
> return
>
> user = User.objects.filter(username = enforce_user)


I'm getting: 'NameError: "global name 'User' is not defined"' on the
above line. This is the same issue I was running into when I was
trying to hard code the initialization of a request.user object. Where
is that defined?


> if user:
> backend = get_backends()[0]
> user = user[0]
> user.backend = "%s.%s" % (backend.__module__,
> backend.__class__.__name__) #fake authentication
> login(request, user)
>
> You can add that to your testing environnement MIDDLEWARE_CLASSES.
>
> Then you can just go to any url and add ?enforce_user=
>
>
>
> On 05/09/12 17:56, Larry Martell wrote:
>
> On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins 
> wrote:
>
> I don't see why not.
>
> I've been trying to do that, but it's still complaining.
>
> Are you running unit tests (testing scripts) or are you
> just using the browser for testing?
>
> I'm trying to do performance measuring. I have a list of all the urls
> accessed over the past few months by a client, along with metrics on
> their execution times. I want to run all those on a new server we've
> set up and collect metrics and compare them. I have a python script
> that uses urllib2 but, I can't run anything without logging in. I've
> tried to login from python, but I get a 403. I also tried using the
> requests module - that doesn't give me the 403, but doesn't log me in
> - it just returns the login page as if the login failed.
>
> On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
> wrote:
>
> On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins 
> wrote:
>
> If any of your templates/views depend upon a request.user object, you'll
> run
> into issues because that will not exist without "logging in". I'm not
> sure
> of a good way around this off-hand without knowing more about your site.
> Sorry!
>
> Yes, they do depend on a request.user object. Can I hard code the
> initialization of it?
>
> On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
> wrote:
>
> We have a django app that requires the users to login. For some
> testing we want to do, we want to disable this so the app can be run
> without logging in. Is there some way to easily do this? I've tried
> commenting out all the @login_required decorations, but then I was
> getting a 403. I tried commenting out the 'if not
> controller.has_access' lines, but then I was getting 'Report.owner"
> must be a "User" instance.' Before I hack up the code any more, is
> there some way to just globally disable the need to login?
>
> --
> You received this message because you are subscribed to the Google
> Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google
> Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

-- 
You received this message because you 

Does anyone know how to access the Protege Ontology Editor?

2012-09-05 Thread Alex Glaros
Anyone know how to access the Protege Ontology Editor from Django? 

http://protege.stanford.edu/

Anyone with experience using it?

Thanks,

Alex Glaros 

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



Re: Editable Tables

2012-09-05 Thread MattDale
I used this tutorial to get me going with the dhtmlx grid.   
http://www.rkblog.rk.edu.pl/w/p/using-dhtmlxgrid-django-application/ 
it's easy once you get the hang of it to make custom grids for each view, 
but not as cut and dry as it seems you are looking for. 

On Wednesday, September 5, 2012 4:27:39 AM UTC-4, Sait Maraşlıoğlu wrote:
>
> This is an example how to create and modify admin listing page: This 
> explains better
>
> class BookAdmin(admin.ModelAdmin):
> list_display = ('title', 'publisher', 'publication_date')
> list_filter = ('publication_date',)
> date_hierarchy = 'publication_date'
> ordering = ('-publication_date',)
> filter_horizontal = ('authors',)
> *raw_id_fields = ('publisher',)
>
> Lets say , I want to use this kind of command for my frond-end, django handle 
> the search fields and listing parameters.
> only with my own table model, lets say its DHTMLX . at the end, I will have 
> my view, generated with search options and
> a few buttons to search,view,edit...
> is it possible, not required to be ready to use, I just looking for a way to 
> achieve it.
>
> thx again.
> *
>
>
>
>
> On Sunday, 2 September 2012 00:58:25 UTC+3, Sait Maraşlıoğlu wrote:
>>
>> Just seen a demo page
>> http://nextgensim.info/grids
>> so beautiful grids,
>> lift framework can do that, I guess, havent dig much but as far as I 
>> seen, its an alternative framework.
>> Can anybody tell me how to create this kind of interactive tables? What 
>> django has to offer, if not What keywords, I need to search?
>> thx
>>
>

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread anthony tresontani

We are using a middleware to enforce a user login:

/class AutoAuthMiddleware(object):
"""
Middleware for testing purpose only.
Can enforce the user login.
"""

def process_request(self, request):
enforce_user = request.GET.get("enforce_user", None)
if hasattr(request, "user") and not enforce_user:
return

user = User.objects.filter(username = enforce_user)
if user:
backend = get_backends()[0]
user = user[0]
user.backend = "%s.%s" % (backend.__module__, 
backend.__class__.__name__) #fake authentication

login(request, user)/

You can add that to your testing environnement MIDDLEWARE_CLASSES.

Then you can just go to any url and add ?enforce_user=


On 05/09/12 17:56, Larry Martell wrote:

On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins  wrote:

I don't see why not.

I've been trying to do that, but it's still complaining.


Are you running unit tests (testing scripts) or are you
just using the browser for testing?

I'm trying to do performance measuring. I have a list of all the urls
accessed over the past few months by a client, along with metrics on
their execution times. I want to run all those on a new server we've
set up and collect metrics and compare them. I have a python script
that uses urllib2 but, I can't run anything without logging in. I've
tried to login from python, but I get a 403. I also tried using the
requests module - that doesn't give me the 403, but doesn't log me in
- it just returns the login page as if the login failed.


On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
wrote:

On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins 
wrote:

If any of your templates/views depend upon a request.user object, you'll
run
into issues because that will not exist without "logging in". I'm not
sure
of a good way around this off-hand without knowing more about your site.
Sorry!

Yes, they do depend on a request.user object. Can I hard code the
initialization of it?


On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
wrote:

We have a django app that requires the users to login. For some
testing we want to do, we want to disable this so the app can be run
without logging in. Is there some way to easily do this? I've tried
commenting out all the @login_required decorations, but then I was
getting a 403. I tried commenting out the 'if not
controller.has_access' lines, but then I was getting 'Report.owner"
must be a "User" instance.' Before I hack up the code any more, is
there some way to just globally disable the need to login?

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


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

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


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



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



Re: Django Interview Questions

2012-09-05 Thread Tim Chase
On 09/05/12 09:05, Dimitri Gnidash wrote:
> This seems to be a copy-paste of Django FAQ.

It seems to be a copy/paste of a LOT of sources around the web, not
just the Django FAQ :-)

-tkc


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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
On Wed, Sep 5, 2012 at 9:36 AM, Kurtis Mullins  wrote:
> I don't see why not.

I've been trying to do that, but it's still complaining.

> Are you running unit tests (testing scripts) or are you
> just using the browser for testing?

I'm trying to do performance measuring. I have a list of all the urls
accessed over the past few months by a client, along with metrics on
their execution times. I want to run all those on a new server we've
set up and collect metrics and compare them. I have a python script
that uses urllib2 but, I can't run anything without logging in. I've
tried to login from python, but I get a 403. I also tried using the
requests module - that doesn't give me the 403, but doesn't log me in
- it just returns the login page as if the login failed.

>
> On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell 
> wrote:
>>
>> On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins 
>> wrote:
>> > If any of your templates/views depend upon a request.user object, you'll
>> > run
>> > into issues because that will not exist without "logging in". I'm not
>> > sure
>> > of a good way around this off-hand without knowing more about your site.
>> > Sorry!
>>
>> Yes, they do depend on a request.user object. Can I hard code the
>> initialization of it?
>>
>> >
>> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
>> > wrote:
>> >>
>> >> We have a django app that requires the users to login. For some
>> >> testing we want to do, we want to disable this so the app can be run
>> >> without logging in. Is there some way to easily do this? I've tried
>> >> commenting out all the @login_required decorations, but then I was
>> >> getting a 403. I tried commenting out the 'if not
>> >> controller.has_access' lines, but then I was getting 'Report.owner"
>> >> must be a "User" instance.' Before I hack up the code any more, is
>> >> there some way to just globally disable the need to login?
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> >> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
This *might* be helpful depending on how you're testing:
http://stackoverflow.com/questions/2036202/how-to-mock-users-and-requests-in-django

On Wed, Sep 5, 2012 at 11:36 AM, Kurtis Mullins wrote:

> I don't see why not. Are you running unit tests (testing scripts) or are
> you just using the browser for testing?
>
>
> On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell wrote:
>
>> On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins 
>> wrote:
>> > If any of your templates/views depend upon a request.user object,
>> you'll run
>> > into issues because that will not exist without "logging in". I'm not
>> sure
>> > of a good way around this off-hand without knowing more about your site.
>> > Sorry!
>>
>> Yes, they do depend on a request.user object. Can I hard code the
>> initialization of it?
>>
>> >
>> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell > >
>> > wrote:
>> >>
>> >> We have a django app that requires the users to login. For some
>> >> testing we want to do, we want to disable this so the app can be run
>> >> without logging in. Is there some way to easily do this? I've tried
>> >> commenting out all the @login_required decorations, but then I was
>> >> getting a 403. I tried commenting out the 'if not
>> >> controller.has_access' lines, but then I was getting 'Report.owner"
>> >> must be a "User" instance.' Before I hack up the code any more, is
>> >> there some way to just globally disable the need to login?
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django-users@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users+unsubscr...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To post to this group, send email to django-users@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users+unsubscr...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
I don't see why not. Are you running unit tests (testing scripts) or are
you just using the browser for testing?

On Wed, Sep 5, 2012 at 11:24 AM, Larry Martell wrote:

> On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins 
> wrote:
> > If any of your templates/views depend upon a request.user object, you'll
> run
> > into issues because that will not exist without "logging in". I'm not
> sure
> > of a good way around this off-hand without knowing more about your site.
> > Sorry!
>
> Yes, they do depend on a request.user object. Can I hard code the
> initialization of it?
>
> >
> > On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
> > wrote:
> >>
> >> We have a django app that requires the users to login. For some
> >> testing we want to do, we want to disable this so the app can be run
> >> without logging in. Is there some way to easily do this? I've tried
> >> commenting out all the @login_required decorations, but then I was
> >> getting a 403. I tried commenting out the 'if not
> >> controller.has_access' lines, but then I was getting 'Report.owner"
> >> must be a "User" instance.' Before I hack up the code any more, is
> >> there some way to just globally disable the need to login?
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Django users" group.
> >> To post to this group, send email to django-users@googlegroups.com.
> >> To unsubscribe from this group, send email to
> >> django-users+unsubscr...@googlegroups.com.
> >> For more options, visit this group at
> >> http://groups.google.com/group/django-users?hl=en.
> >>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> > http://groups.google.com/group/django-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
On Wed, Sep 5, 2012 at 9:22 AM, Kurtis Mullins  wrote:
> If any of your templates/views depend upon a request.user object, you'll run
> into issues because that will not exist without "logging in". I'm not sure
> of a good way around this off-hand without knowing more about your site.
> Sorry!

Yes, they do depend on a request.user object. Can I hard code the
initialization of it?

>
> On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell 
> wrote:
>>
>> We have a django app that requires the users to login. For some
>> testing we want to do, we want to disable this so the app can be run
>> without logging in. Is there some way to easily do this? I've tried
>> commenting out all the @login_required decorations, but then I was
>> getting a 403. I tried commenting out the 'if not
>> controller.has_access' lines, but then I was getting 'Report.owner"
>> must be a "User" instance.' Before I hack up the code any more, is
>> there some way to just globally disable the need to login?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



Re: Easy way to temporarily disable the need to login

2012-09-05 Thread Kurtis Mullins
If any of your templates/views depend upon a request.user object, you'll
run into issues because that will not exist without "logging in". I'm not
sure of a good way around this off-hand without knowing more about your
site. Sorry!

On Wed, Sep 5, 2012 at 11:18 AM, Larry Martell wrote:

> We have a django app that requires the users to login. For some
> testing we want to do, we want to disable this so the app can be run
> without logging in. Is there some way to easily do this? I've tried
> commenting out all the @login_required decorations, but then I was
> getting a 403. I tried commenting out the 'if not
> controller.has_access' lines, but then I was getting 'Report.owner"
> must be a "User" instance.' Before I hack up the code any more, is
> there some way to just globally disable the need to login?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Easy way to temporarily disable the need to login

2012-09-05 Thread Larry Martell
We have a django app that requires the users to login. For some
testing we want to do, we want to disable this so the app can be run
without logging in. Is there some way to easily do this? I've tried
commenting out all the @login_required decorations, but then I was
getting a 403. I tried commenting out the 'if not
controller.has_access' lines, but then I was getting 'Report.owner"
must be a "User" instance.' Before I hack up the code any more, is
there some way to just globally disable the need to login?

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



Re: bound field object - dynamic forms

2012-09-05 Thread Mando
are you passing it to the template?

On Wednesday, September 5, 2012 7:09:57 AM UTC-5, mjh wrote:
>
> tried {{ issue.x }} x = 0,1,2,3 but nothing is displayed in the template
>
> any other thoughts?
>
> On Monday, 3 September 2012 22:53:03 UTC+1, somecallitblues wrote:
>>
>> Try {{ issue.0}} and {{ issue.1}}
>> On Sep 4, 2012 5:55 AM, "mjh"  wrote:
>>
>>> Hi all - not sure how to show the choicefield dropdown in my template?
>>>
>>> Am generating a dynamic form (note: for issue in issues in forms.py) and 
>>> appending the fields to self.issue_list
>>>
>>> in the template I am looping over these fields ({% for issue in 
>>> form.issue_list %}) and can write out the label {{ issue.label }} but if 
>>> write out {{ issue }} I simply get the bound field object written to 
>>> template ().
>>>
>>> Question is how do I get the html dropdown to display in the template??
>>>
>>>
>>>
>>> >>> forms.py
>>> def __init__(self, item, *args, **kwargs):
>>> super(ItemAnalysisForm, self).__init__(*args, **kwargs)
>>> issue_choice = (('1', 'Reduced'),
>>> ('2', 'Maintained'),
>>> ('3', 'Increased')
>>> )
>>> issues = item.issue.all()
>>>
>>> self.issue_list = []
>>> self.a_list = []
>>> # generate dynamic issue dropdowns...
>>> for issue in issues:
>>> self.fields['issue-' + str(issue.pk)] = 
>>> forms.ChoiceField(label=issue.name, choices=issue_choice, required=False)
>>> self.a_list.append(self.fields['issue-' + str(issue.pk)])
>>> self.issue_list.append(self.fields['issue-' + str(issue.pk)])
>>> self.fields['text'] = forms.CharField(label='text', required=True, 
>>> widget=forms.Textarea(attrs={'rows':25,'cols':'100'}))
>>> self.a_list.append(self.fields['text'])
>>>
>>>
>>> >>> template
>>> {% 
>>> csrf_token %}
>>> 
>>> Individual Issue Outcome:
>>> 
>>> {% for issue in form.issue_list %}
>>> 
>>> {{ issue.label }}: {{ issue }}
>>> 
>>> {% endfor %}
>>> 
>>> 
>>> 
>>> Comment:
>>> 
>>> {{ form.text }}
>>> 
>>>
>>> 
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/XSMbUGOJyvMJ.
>>> To post to this group, send email to django...@googlegroups.com.
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com.
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>

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



Re: Django admin runs out of memory with ForeignKeys to large tables

2012-09-05 Thread Thomas Lockhart

On 9/5/12 6:00 AM, Mattias Linnap wrote:

I've found two solutions: setting "editable=False" in the model's
field definition (which removes the field completely from admin), or
adding it to readonly_fields list in the ModelAdmin (which keeps the
data visible).

Perhaps it will be possible to subclass ModelAdmin, and make all
editable=False fields show up as readonly: after all, their data is
still interesting to look at, just should not be editable.

Looking at millions of read-only entries should lead to hours of 
enjoyment ;)


What good is that volume of data displayed to a user or admin? How about 
showing a rollup of the number of values and then allowing a 
click-through to a detailed display if necessary?


 - Tom

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



Re: How to use URL namespaces in tests?

2012-09-05 Thread Natim
Ok it is quite easy, you are missing {% load url from future %} in your 
template.

Le jeudi 23 août 2012 09:25:54 UTC+2, e.generalov a écrit :
>
> Url patterns which provided by a django application should be 
> addressedexternally in 
> the form of "namespace:name". I guess it will be connected to the project as 
> follows:
>
> project/urls.py
>
> urlpatterns = patterns('',
> url('^something/', include('django_something.urls', 
> namespace='something')))
>
> URL patterns module in the application looks like:
>
> django_something/urls.py
>
> urlpatterns = patterns('',
> url('^$', show, name='show'))
>
> and I write a test:
>
> django_something/tests.py
>
> class ShowViewTest(TestCase):
> urls = 'django_something.urls'
>
> def test_should_render_something_template(self):
> url = reverse('something:show') # !!!
> response = self.client.get(url)
> self.assertIn('something.html', set([t.name for t in 
> response.templates]))
>
> This test failes with exception "django NoReverseMatch 'something' is not 
> a registered namespace" . How can I specify namespace 'something' in this 
> case?

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



Re: Choosing a JS framework to go together with Django

2012-09-05 Thread Kelly Nicholes
It would be a travesty to not mention backbone.js.

On Tuesday, September 4, 2012 7:39:49 AM UTC-6, dotnetCarpenter wrote:
>
> Hi all.
>
> I'm new here and just took over a Django project for the first time. I'm 
> still getting to grip with Django but as a front end dev for the past 5 
> years, I'm also looking for a client-side library/framework to go together 
> with my project.
> My requirements for a JS framework is that it:
>
>1. is unobtrusive (Django rendered HTML will be shown to scraper bots 
>like google)
>2. provides some sort of structure (MVC, MVP, MVVM ect.)
>3. embraces standards
>4. doesn't conflict with Django templates or does so intentionally
>5. ideally uses the same template language as Django
>
> In the ideal world a request/response scenario would look like this:
>
>1. A client make a (HTTP) request to the (django powered) web site 
>with (HTTP) Accept header text/html
>2. Django response in the usual way by rendering the assign View 
>(django template)
>3. The view figure out if JS is supported (implemented in JS). If no, 
>this scenario stays in loop 1-3. If yes, then 4.
>4. The client (usually a browser) wire up the client-side app 
>structure, hook in to URI links, add transitions between views, 
>data-bindings ect.
>5. Subsequent request are now handle by the JS framework, either user 
>initiated (e.g. clicking a link) or app initiated (e.g. pulling extra 
>data), that will modify the request header to Accept header 
>application/json or application/django-template.
>6. If django receive a request with an application/django-template 
>header it will serve the view as plain text. E.g. Content-type: 
> text/plain. 
>On the other hand if django receive a request with application/json, it 
>will send the object model defined in the view as JSON.
>7. The client-side JS framework will receive a template to render in 
>the first request and the data to render in the template in the second 
>request. A promise object could be used to synchronize the two calls.
>
> This way django will work as intended for non JS clients and silently 
> convert to a RIA in clients that supports JS, with minimal double work for 
> the two execution contexts.
> A big pro in this is the fact that both django and the JS framework share 
> template and data (only has to defined once - in django) - we'll duck type 
> all the way. But does this JS framework exist? Does anyone have any 
> experience with working with django and JS frameworks? Is there any obvious 
> pitfalls in my ideal world scenario in regard to Django? And finally, is it 
> possible to serve templates as plain text with django?
>  
>
> Cheers, Jon and thanks in advance
>
> PS. I accidentally cross-posted this to the Django Developers group before 
> realizing it was the wrong forum. Sorry about that. 
>
>

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



Re: How to use URL namespaces in tests?

2012-09-05 Thread Natim
I've got the same problem any ideas ?

Le jeudi 23 août 2012 09:25:54 UTC+2, e.generalov a écrit :
>
> Url patterns which provided by a django application should be 
> addressedexternally in 
> the form of "namespace:name". I guess it will be connected to the project as 
> follows:
>
> project/urls.py
>
> urlpatterns = patterns('',
> url('^something/', include('django_something.urls', 
> namespace='something')))
>
> URL patterns module in the application looks like:
>
> django_something/urls.py
>
> urlpatterns = patterns('',
> url('^$', show, name='show'))
>
> and I write a test:
>
> django_something/tests.py
>
> class ShowViewTest(TestCase):
> urls = 'django_something.urls'
>
> def test_should_render_something_template(self):
> url = reverse('something:show') # !!!
> response = self.client.get(url)
> self.assertIn('something.html', set([t.name for t in 
> response.templates]))
>
> This test failes with exception "django NoReverseMatch 'something' is not 
> a registered namespace" . How can I specify namespace 'something' in this 
> case?

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



Re: Output of form in Extjs

2012-09-05 Thread JJ
Hi Russell,
I would like to create was plugin, as you presentation. I would like to 
contribute with this code. How can it help you?

Thank's

On Wednesday, September 5, 2012 8:46:06 AM UTC-3, Russell Keith-Magee wrote:
>
> Hi João, 
>
> Thanks for the suggestion, but this isn't something we're likely to 
> add to Django's core itself. 
>
> This is for two reasons. The first is that we have been specifically 
> avoiding any dependency on any particular database library. Django is 
> a server-side framework, so we don't want to impose any client-side 
> decisions on users. 
>
> The second is that we want to move away from the .as_* model, towards 
> a more flexible approach. There was a Summer of Code project last year 
> aimed at moving the forms library to a templates approach; that hasn't 
> come to completion yet, but the broader aim still stands -- rather 
> than try an encode every possible output format, we'd like to move to 
> a place where an end user can plug in any output format. To that end, 
> your ext2js renderer would be an end-user plugin, rather than 
> something built into Django itself. 
>
> Yours, 
> Russ Magee %-) 
>
> On Wed, Sep 5, 2012 at 3:05 AM, JJ  
> wrote: 
> > Hi all, 
> > I created parse django to extjs in modelforms and forms. Basically works 
> as 
> > form.as_p but is form.extjs_output. I mapped all widgets fields to 
> extjs. I 
> > would like to submit this code to django-project. What do you think? 
> > Thank you. 
> > 
> > João Júnior 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To view this discussion on the web visit 
> > https://groups.google.com/d/msg/django-users/-/h6rzplc6r3kJ. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

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



Re: Django Interview Questions

2012-09-05 Thread Dimitri Gnidash
This seems to be a copy-paste of Django FAQ.

On Tue, Sep 4, 2012 at 8:10 AM, Stephen Anto  wrote:
> Hi Guys,
>
> I have updated Django latest interview questions and answers. It may cover
> all technical requirements of the interview.
>
> Vist http://www.f2finterview.com/web/Django/ for latest Django interview
> questions and answers
>
> On Monday, November 2, 2009 9:06:41 PM UTC+5:30, Dimitri Gnidash wrote:
>>
>> Hey guys,
>>
>> For all those of you interviewing or being interviewed, I created a
>> quick list of sample interview questions.
>> While not comprehensive, it is a good start to review these before the
>> interview, if anything, to gain a perspective on how other people
>> might be using Django.
>>
>>
>> http://blog.lightsonsoftware.com/django-interview-questions-0
>>
>>
>> Dimitri Gnidash
>> www.lightsonsoftware.com



-- 
Dimitri
647.773.7223

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



Problem with Django recaptcha

2012-09-05 Thread Lakshmen
I have git cloned the 
django-recaptcha( https://github.com/praekelt/django-recaptcha) into my 
directory and have included the public and private keys in my settings.py 
and captcha = ReCaptchaField(). But i get this error everytime i run the 
forms: Captcha: Input error: k: Format of site key was invalid. How do i 
avoid this error? Any idea? the original question is here: 
http://stackoverflow.com/questions/12251274/cant-get-the-captcha-to-appear 
. Need some help...  

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



Re: Django admin runs out of memory with ForeignKeys to large tables

2012-09-05 Thread m1chael
what about raw_id_fields ?

On Wed, Sep 5, 2012 at 9:00 AM, Mattias Linnap  wrote:

> I've found two solutions: setting "editable=False" in the model's
> field definition (which removes the field completely from admin), or
> adding it to readonly_fields list in the ModelAdmin (which keeps the
> data visible).
>
> Perhaps it will be possible to subclass ModelAdmin, and make all
> editable=False fields show up as readonly: after all, their data is
> still interesting to look at, just should not be editable.
>
> Mattias
>
> On Wed, Sep 5, 2012 at 1:37 PM, Mattias Linnap  wrote:
> > Hi all,
> >
> > I have a model X that references another model Y with a ForeignKey.
> > There are very few Xs, but close to a million Ys in the database (and
> > it will grow considerably in the future).
> > This causes MemoryErrors in the Django built-in admin pages: the
> > ForeignKey is rendered as a select box field, and the admin attempts
> > to populate it with all million possible Ys.
> >
> > What would be the recommended solution? The ForeignKey relationship
> > does not need to be actually editable in the admin, it's a simple
> > uniqueness constraint that should never change after an X is created.
> > I'm using the admin as more of a data browsing UI rather than a
> > management UI.
> >
> > Thanks,
> >
> > Mattias
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

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



Re: Does ``QuerySet.select_for_update`` lock related (joined) rows as well?

2012-09-05 Thread Yo-Yo Ma
Thanks, Tom. That does help.

On Wednesday, September 5, 2012 6:02:27 AM UTC-4, Tom Evans wrote:
>
> On Wed, Sep 5, 2012 at 1:45 AM, Yo-Yo Ma  
> wrote: 
> > restaurant = 
> > 
> Restaurant.objects.select_for_update().select_related('owner').get(name=u'Koala
>  
>
> > Kafe') 
> > 
> > Assuming the ``owner`` field points to a ``Person`` table, will the 
> > aforementioned query prevent the ``Person`` row returned for the Koala 
> > Kafe's owner from being saved in a separate transaction? 
> > 
> > (I will be using Postgres and using ``transaction.commit_on_success``) 
> > 
>
> select_for_update() … 
>
> "Returns a queryset that will lock rows until the end of the 
> transaction, generating a SELECT ... FOR UPDATE SQL statement on 
> supported databases." 
>
> Postgresql handles this … 
>
> "If specific tables are named in FOR UPDATE or FOR SHARE, then only 
> rows coming from those tables are locked; any other tables used in the 
> SELECT are simply read as usual. A FOR UPDATE or FOR SHARE clause 
> without a table list affects all tables used in the statement. If FOR 
> UPDATE or FOR SHARE is applied to a view or sub-query, it affects all 
> tables used in the view or sub-query." 
>
>
> http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FOR-UPDATE-SHARE
>  
>
> Django doesn't specify any tables when it generates a SELECT … FOR UPDATE 
> query: 
>
>
> https://github.com/django/django/blob/master/django/db/backends/__init__.py#L585
>  
>
> Hope that helps 
>
> Tom 
>

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



Re: Django admin runs out of memory with ForeignKeys to large tables

2012-09-05 Thread Mattias Linnap
I've found two solutions: setting "editable=False" in the model's
field definition (which removes the field completely from admin), or
adding it to readonly_fields list in the ModelAdmin (which keeps the
data visible).

Perhaps it will be possible to subclass ModelAdmin, and make all
editable=False fields show up as readonly: after all, their data is
still interesting to look at, just should not be editable.

Mattias

On Wed, Sep 5, 2012 at 1:37 PM, Mattias Linnap  wrote:
> Hi all,
>
> I have a model X that references another model Y with a ForeignKey.
> There are very few Xs, but close to a million Ys in the database (and
> it will grow considerably in the future).
> This causes MemoryErrors in the Django built-in admin pages: the
> ForeignKey is rendered as a select box field, and the admin attempts
> to populate it with all million possible Ys.
>
> What would be the recommended solution? The ForeignKey relationship
> does not need to be actually editable in the admin, it's a simple
> uniqueness constraint that should never change after an X is created.
> I'm using the admin as more of a data browsing UI rather than a
> management UI.
>
> Thanks,
>
> Mattias

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



Test driven development in Django framework

2012-09-05 Thread jyria
What is your experience? Is it worth it, and is it possible? 

I tried it and found it quite difficult to follow guideline of unit testing 
-- testing a unit of code, a class for example. Maybe Im just ignorant, but 
I didnt see, how can I create registration app only with unit tests. The 
only way I could drive implementation with tests was using more like an 
integration testing approach: calling requests with data and asserting that 
new user was registered and that form was valid/invalid etc, but this goes 
against TDD as I understand it. So should I not worry about pure "unit 
testing" approach and use django client http request to validate 
RegistrationForm. Or I should write unit tests for RegistrationForm class?

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



Django admin runs out of memory with ForeignKeys to large tables

2012-09-05 Thread Mattias Linnap
Hi all,

I have a model X that references another model Y with a ForeignKey.
There are very few Xs, but close to a million Ys in the database (and
it will grow considerably in the future).
This causes MemoryErrors in the Django built-in admin pages: the
ForeignKey is rendered as a select box field, and the admin attempts
to populate it with all million possible Ys.

What would be the recommended solution? The ForeignKey relationship
does not need to be actually editable in the admin, it's a simple
uniqueness constraint that should never change after an X is created.
I'm using the admin as more of a data browsing UI rather than a
management UI.

Thanks,

Mattias

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



Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread g1smd.1

Thanks for the reply and information.


The jQuery validation routines for GB telephone numbers contain significant 
errors and shortcomings. I already posted some patches correcting many of 
those problems at least a month ago, but they haven't been reviewed yet.


The new Python/django telephone number validation code I am proposing here 
is far more comprehensive and has much more detailed range and length 
checking. Similar code already works fine in PHP and Java elsewhere, but I 
am having trouble converting it all to Python. 

I have added some Python logic and code to the initial RegEx patterns that 
I posted yesterday, but I now need help to finish it off and get it 
working. I am not at all familiar with the Python syntax and the manual is 
somewhat terse and obtuse.

I had a problem with GitHub this morning, so the pull request is now at 
https://github.com/django/django/pull/324

The code so far, can be found at: 
https://github.com/g1smd/django/blob/master/django/contrib/localflavor/gb/forms.py

I'm guessing that someone proficient in Python could finish it off in a 
couple of hours or less.

Any volunteers?




On Wednesday, September 5, 2012 7:02:09 AM UTC, Amyth wrote:
>
> you can alternatively use jquery to validate the field, i do not have the 
> link handy as m on my phone right now but google validation engine, it is 
> one of the most powerful jquery validation library which also has builtin 
> method of validating uk phone numbers.
> On Sep 4, 2012 5:00 AM, "g1smd.1"  
> wrote:
>
>> I see that there are routines for validating telephone numbers in forms 
>> in Django for several countries.
>>
>> The code for that can usually be found in the forms.py file located in 
>> the various country folders here:
>> https://github.com/django/django/tree/master/django/contrib/localflavor 
>>
>> So far, there is nothing for GB numbers, here:
>> https://github.com/django/django/tree/master/django/contrib/localflavor/gb
>>
>> I've written a bunch of RegEx patterns to get this functionality started. 
>> The patterns are 100% fully tested. All that's needed is a few lines of 
>> python logic to string them together. The details can be found at:
>> https://github.com/django/django/pull/316/files
>>
>> My python foo is almost zero. Anyone care to have a go at getting this to 
>> work?
>>
>> RegEx 1 checks the user entered something that looks like a GB telephone 
>> number:
>> 020  3000  
>> 02075  567  234
>> 0114  223  4567
>> 01145  345  567
>> +44  1213  456  789
>> 00  44  (0)  1697  73555
>> 011  44  11  4890  2345
>> and several other formats, without worrying if the format is correct for 
>> this particular number (but read on). It allows for national or 
>> international format, even for two common international dial prefixes. What 
>> is most important is that the user enters the right number of digits. Don't 
>> constrain the user to use a particular format for entry.
>> "Be lenient in what you accept, be strict in what you send." (Postel's 
>> Law)
>>
>> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in 
>> $2 (so you know if international or national format was used on input), and 
>> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.
>>
>> RegEx 3 tests the NSN part of the number is in a valid range and has the 
>> right number of digits for that range (GB numbers can be 9 or 10 digits 
>> long). This RegEx pattern is very detailed. You can say that a number is 
>> possible or is invalid with this RegEx.
>>
>> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how a 
>> GB number should be formatted, detailed by number length and initial 
>> digits. These rules cover all GB numbers.
>>
>> The last bit is to add the 0 or +44 back on, and append the original 
>> extension number (if present) and present it back to the user.
>>
>> 020  3000   => Valid: 020  3000  
>> 02075  567  234 => Valid: 020  7556  7234
>> 0114  223  4567 => Valid: 0114  223  4567
>> 01145  345  567 => Valid: 0114  534  5567
>> +44  1213  456  789 => Valid: +44  121  345  6789
>> 00  44  (0)  1697  73555 => Valid: +44  16977  3555
>> 011  44  11  4890  2345 => Valid: +44  114  890  2345
>> 0623 111 3456 => NOT VALID
>>
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/h0iG7nJrXikJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/Zohb6P8AsaIJ.
To post to this group, send 

Re: bound field object - dynamic forms

2012-09-05 Thread mjh
tried {{ issue.x }} x = 0,1,2,3 but nothing is displayed in the template

any other thoughts?

On Monday, 3 September 2012 22:53:03 UTC+1, somecallitblues wrote:
>
> Try {{ issue.0}} and {{ issue.1}}
> On Sep 4, 2012 5:55 AM, "mjh"  
> wrote:
>
>> Hi all - not sure how to show the choicefield dropdown in my template?
>>
>> Am generating a dynamic form (note: for issue in issues in forms.py) and 
>> appending the fields to self.issue_list
>>
>> in the template I am looping over these fields ({% for issue in 
>> form.issue_list %}) and can write out the label {{ issue.label }} but if 
>> write out {{ issue }} I simply get the bound field object written to 
>> template ().
>>
>> Question is how do I get the html dropdown to display in the template??
>>
>>
>>
>> >>> forms.py
>> def __init__(self, item, *args, **kwargs):
>> super(ItemAnalysisForm, self).__init__(*args, **kwargs)
>> issue_choice = (('1', 'Reduced'),
>> ('2', 'Maintained'),
>> ('3', 'Increased')
>> )
>> issues = item.issue.all()
>>
>> self.issue_list = []
>> self.a_list = []
>> # generate dynamic issue dropdowns...
>> for issue in issues:
>> self.fields['issue-' + str(issue.pk)] = 
>> forms.ChoiceField(label=issue.name, choices=issue_choice, required=False)
>> self.a_list.append(self.fields['issue-' + str(issue.pk)])
>> self.issue_list.append(self.fields['issue-' + str(issue.pk)])
>> self.fields['text'] = forms.CharField(label='text', required=True, 
>> widget=forms.Textarea(attrs={'rows':25,'cols':'100'}))
>> self.a_list.append(self.fields['text'])
>>
>>
>> >>> template
>> {% 
>> csrf_token %}
>> 
>> Individual Issue Outcome:
>> 
>> {% for issue in form.issue_list %}
>> 
>> {{ issue.label }}: {{ issue }}
>> 
>> {% endfor %}
>> 
>> 
>> 
>> Comment:
>> 
>> {{ form.text }}
>> 
>>
>> 
>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/XSMbUGOJyvMJ.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

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



Re: Output of form in Extjs

2012-09-05 Thread Russell Keith-Magee
Hi João,

Thanks for the suggestion, but this isn't something we're likely to
add to Django's core itself.

This is for two reasons. The first is that we have been specifically
avoiding any dependency on any particular database library. Django is
a server-side framework, so we don't want to impose any client-side
decisions on users.

The second is that we want to move away from the .as_* model, towards
a more flexible approach. There was a Summer of Code project last year
aimed at moving the forms library to a templates approach; that hasn't
come to completion yet, but the broader aim still stands -- rather
than try an encode every possible output format, we'd like to move to
a place where an end user can plug in any output format. To that end,
your ext2js renderer would be an end-user plugin, rather than
something built into Django itself.

Yours,
Russ Magee %-)

On Wed, Sep 5, 2012 at 3:05 AM, JJ  wrote:
> Hi all,
> I created parse django to extjs in modelforms and forms. Basically works as
> form.as_p but is form.extjs_output. I mapped all widgets fields to extjs. I
> would like to submit this code to django-project. What do you think?
> Thank you.
>
> João Júnior
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/h6rzplc6r3kJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



creating an object on saving another model to the database

2012-09-05 Thread Martin Illgen
Hello,

I've the following problem:

- I have a model (ModelA) with a primary key consisting of a foreignkey 
(ModelB - ID)

- *Databasestructure*
  TableA
  TableA_TableB - PK, BIGINT(20), FK TableB:ID
  NAME - VARCHAR(255)

  TableB
  ID - PK, AI, BIGINT(20)
  NAME - VARCHAR(255)

- *Django Models*

class ModelA(models.Model):
ModelA_ModelB = models.ForeignKey("ModelB", primary_key=True)
name = models.CharField(max_length=255)

class ModelB(models.Model):
id = models.BigIntegerField(primary_key=True)
name = models.CharField(max_length=255)

- *Django save_model of ModelA*

  def save_model(self, request, obj, form, change):
oObj = ModelB()
oObj.name = "TestIt"
oObj.save()

obj.ModelA_ModelB = oObj
obj.save()

- *Creating a new ModelA using the admin GUI I got the following error*

Django Version:1.4Exception Type:IntegrityErrorException Value:

(1048, "Column 'ModelA_ModelB_id' cannot be null")



 - *Model instance reference : 
Save
*

>>> b2 = Blog(name='Cheddar Talk', tagline='Thoughts on cheese.')>>> b2.id 
>>> # Returns None, because b doesn't have an ID yet.>>> b2.save()>>> b2.id 
>>> # Returns the ID of your new object.

Running the suggested Code above on my model (ModelB) I do not get the ID of 
the model after saving it. I got None for ID after saving my model. The 
Database contains the saved model.


What am I doing wrong? Why does my model not have a id after saving it to the 
Database?

kind regards






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



How to use FTP to upload files with Django?

2012-09-05 Thread Chaney Lee
I just want to allow users uploading some videos to server in my website.I 
want to use FTP.So ,how to realize it?

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



Re: Does ``QuerySet.select_for_update`` lock related (joined) rows as well?

2012-09-05 Thread Tom Evans
On Wed, Sep 5, 2012 at 1:45 AM, Yo-Yo Ma  wrote:
> restaurant =
> Restaurant.objects.select_for_update().select_related('owner').get(name=u'Koala
> Kafe')
>
> Assuming the ``owner`` field points to a ``Person`` table, will the
> aforementioned query prevent the ``Person`` row returned for the Koala
> Kafe's owner from being saved in a separate transaction?
>
> (I will be using Postgres and using ``transaction.commit_on_success``)
>

select_for_update() …

"Returns a queryset that will lock rows until the end of the
transaction, generating a SELECT ... FOR UPDATE SQL statement on
supported databases."

Postgresql handles this …

"If specific tables are named in FOR UPDATE or FOR SHARE, then only
rows coming from those tables are locked; any other tables used in the
SELECT are simply read as usual. A FOR UPDATE or FOR SHARE clause
without a table list affects all tables used in the statement. If FOR
UPDATE or FOR SHARE is applied to a view or sub-query, it affects all
tables used in the view or sub-query."

http://www.postgresql.org/docs/9.0/static/sql-select.html#SQL-FOR-UPDATE-SHARE

Django doesn't specify any tables when it generates a SELECT … FOR UPDATE query:

https://github.com/django/django/blob/master/django/db/backends/__init__.py#L585

Hope that helps

Tom

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



Re: with/include template pattern? seeking best practices

2012-09-05 Thread Mike S
The code `e.generalov` gave has been valid since Django 2.3: 


For more complicated context, you can also write an inclusion tag <
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#inclusion-tags>
 
and use that to render the inner template.

On Tuesday, September 4, 2012 6:21:47 PM UTC-4, Ivan Kirigin wrote:
>
> I find myself writing things like this a lot in django templates
>
> {% for e in some_list %}
> {% with e as element %}
> {% include "single_element.html" %}
> {% endwith %} 
> {% enfor %}
>
> This would be in a template which shows a lists of elements, with another 
> template that renders a single one. The template single_element.html uses 
> element locally. I find this encapsulates my templates well, especially 
> in making single_element.html far more reusable.
>
> I've been doing this for a while and wanted to know if there is a better 
> way I just don't know about. Also, I don't know the performance 
> implications of so many with/include calls. This list could be very long 
> (100s or 1000s).
>
> Thanks!
> Ivan Kirigin
> http://kirigin.com
>
>

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



Re: Editable Tables

2012-09-05 Thread Sait Maraşlıoğlu
This is an example how to create and modify admin listing page: This 
explains better

class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'publisher', 'publication_date')
list_filter = ('publication_date',)
date_hierarchy = 'publication_date'
ordering = ('-publication_date',)
filter_horizontal = ('authors',)
*raw_id_fields = ('publisher',)

Lets say , I want to use this kind of command for my frond-end, django handle 
the search fields and listing parameters.
only with my own table model, lets say its DHTMLX . at the end, I will have my 
view, generated with search options and
a few buttons to search,view,edit...
is it possible, not required to be ready to use, I just looking for a way to 
achieve it.

thx again.
*




On Sunday, 2 September 2012 00:58:25 UTC+3, Sait Maraşlıoğlu wrote:
>
> Just seen a demo page
> http://nextgensim.info/grids
> so beautiful grids,
> lift framework can do that, I guess, havent dig much but as far as I seen, 
> its an alternative framework.
> Can anybody tell me how to create this kind of interactive tables? What 
> django has to offer, if not What keywords, I need to search?
> thx
>

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



Re: Editable Tables

2012-09-05 Thread Sait Maraşlıoğlu
DHTMLX  is looking great, I hope I can integrate it to my website.
Actually I was looking for a way to make it modular, let me explain.

Say, we have a modal named books, and it has fields, named 
'name,pages,author' . 
using a generic view or something, it will display a table vith its field 
types derived from my model and using a search box , and generated form. u 
can search your books. 
it should be modular so u shouldnt have same hassle to list and search ur 
other models.

it maybe possible, Django do that in its admin page, u can declare the 
search fields and the fields u can show in the listing page. its similar.

is it a dream? was this second version of I have a dream speech?
thx


On Sunday, 2 September 2012 00:58:25 UTC+3, Sait Maraşlıoğlu wrote:
>
> Just seen a demo page
> http://nextgensim.info/grids
> so beautiful grids,
> lift framework can do that, I guess, havent dig much but as far as I seen, 
> its an alternative framework.
> Can anybody tell me how to create this kind of interactive tables? What 
> django has to offer, if not What keywords, I need to search?
> thx
>

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



Re: Installation script?

2012-09-05 Thread Carsten Agger

Den 04-09-2012 20:41, creecode skrev:

Have you checked out pip  which has 
a requirements feature and fabric .  Those 
two would probably take you a fair ways or at least give you some 
ideas how you might approach the problem.




Thanks for the suggestions! In fact, I think buildout (zc.buildout) may 
be what I'm looking for.


Best regards,

Carsten

--
Carsten Agger
Magenta ApS
Åbogade 15
8200 Århus N

Tlf +45 5060 1269
Mob +45 2086 5010
http://www.magenta-aps.dk
carst...@magenta-aps.dk

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



Re: with/include template pattern? seeking best practices

2012-09-05 Thread e.generalov
{% for e in some_list %}
{% include "single_element.html" with element=e %}
{% enfor %}


I find myself writing things like this a lot in django templates
>
> {% for e in some_list %}
> {% with e as element %}
> {% include "single_element.html" %}
> {% endwith %} 
> {% enfor %}
>
> This would be in a template which shows a lists of elements, with another 
> template that renders a single one. The template single_element.html uses 
> element locally. I find this encapsulates my templates well, especially 
> in making single_element.html far more reusable.
>
> I've been doing this for a while and wanted to know if there is a better 
> way I just don't know about. Also, I don't know the performance 
> implications of so many with/include calls. This list could be very long 
> (100s or 1000s).
>
> Thanks!
> Ivan Kirigin
> http://kirigin.com
>
>

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



Re: Validating GB telephone numbers in Django forms.

2012-09-05 Thread Amyth Arora
you can alternatively use jquery to validate the field, i do not have the
link handy as m on my phone right now but google validation engine, it is
one of the most powerful jquery validation library which also has builtin
method of validating uk phone numbers.
On Sep 4, 2012 5:00 AM, "g1smd.1"  wrote:

> I see that there are routines for validating telephone numbers in forms in
> Django for several countries.
>
> The code for that can usually be found in the forms.py file located in the
> various country folders here:
> https://github.com/django/django/tree/master/django/contrib/localflavor
>
> So far, there is nothing for GB numbers, here:
> https://github.com/django/django/tree/master/django/contrib/localflavor/gb
>
> I've written a bunch of RegEx patterns to get this functionality started.
> The patterns are 100% fully tested. All that's needed is a few lines of
> python logic to string them together. The details can be found at:
> https://github.com/django/django/pull/316/files
>
> My python foo is almost zero. Anyone care to have a go at getting this to
> work?
>
> RegEx 1 checks the user entered something that looks like a GB telephone
> number:
> 020  3000  
> 02075  567  234
> 0114  223  4567
> 01145  345  567
> +44  1213  456  789
> 00  44  (0)  1697  73555
> 011  44  11  4890  2345
> and several other formats, without worrying if the format is correct for
> this particular number (but read on). It allows for national or
> international format, even for two common international dial prefixes. What
> is most important is that the user enters the right number of digits. Don't
> constrain the user to use a particular format for entry.
> "Be lenient in what you accept, be strict in what you send." (Postel's Law)
>
> RegEx 2 extracts the NSN part of the number in $3, with "44" or NULL in $2
> (so you know if international or national format was used on input), and
> any extension in $4. Store $2 and $4 for later. Send $3 on to RegEx 3.
>
> RegEx 3 tests the NSN part of the number is in a valid range and has the
> right number of digits for that range (GB numbers can be 9 or 10 digits
> long). This RegEx pattern is very detailed. You can say that a number is
> possible or is invalid with this RegEx.
>
> RegEx Group 4. Here, there's a bunch of RegEx patterns that specify how a
> GB number should be formatted, detailed by number length and initial
> digits. These rules cover all GB numbers.
>
> The last bit is to add the 0 or +44 back on, and append the original
> extension number (if present) and present it back to the user.
>
> 020  3000   => Valid: 020  3000  
> 02075  567  234 => Valid: 020  7556  7234
> 0114  223  4567 => Valid: 0114  223  4567
> 01145  345  567 => Valid: 0114  534  5567
> +44  1213  456  789 => Valid: +44  121  345  6789
> 00  44  (0)  1697  73555 => Valid: +44  16977  3555
> 011  44  11  4890  2345 => Valid: +44  114  890  2345
> 0623 111 3456 => NOT VALID
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/h0iG7nJrXikJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Using array for making form

2012-09-05 Thread Satinderpal Singh
Hi,
I want to make a form in such a way that the contents of the form
should be declared in the array, and also the user details field
corresponding to that contents of the form, which a user fills, should
also be in array in the the models of the project.
I currently use to do this like:

class soil_oshr(models.Model):
date_of_testing = models.CharField(max_length=255)
type_of_str = models.CharField(max_length=255)
latitude_N = models.CharField(max_length=255,blank=True)
longitude_E = models.CharField(max_length=255,blank=True)
presence_1 = models.CharField(max_length=255)
presence_2 = models.CharField(max_length=255,blank=True)
submitted_1 = models.CharField(max_length=255)
submitted_2 = models.CharField(max_length=255,blank=True)
submitted_3 = models.CharField(max_length=255,blank=True)
site_name = models.CharField(max_length=255)
water_table = models.CharField(max_length=255)
depth_D = models.CharField(max_length=255)
water_table = models.CharField(max_length=255)
def __str__(self):
return self.date_of_testing

class soil_oshrForm(ModelForm):
class Meta :
model = soil_oshr
The thing i need that in case of above class "soil_ohsr" the choices
like "date_of_testing", "type_of_str", "latitude_N", and their values
which are in charfields, should be declared as array to avoid the
lengthy code.
If anybody tell me how i'll do it. Thanks in advance.

-- 
Satinderpal Singh
http://satindergoraya.blogspot.in/
http://satindergoraya91.blogspot.in/

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



Authentication across projects

2012-09-05 Thread yillkid
Hi all .
I have two projects (A and B), different django installation, database, but 
same host.

I want the B projects share A project User database table.  
So A user account can login into B project site, but we don't create any 
user account in B project.
and I have already search many information about that.

1. REMOTE_USER
2. django multi database table
3. remote authentication

but I don't know what is the typical solution ?

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



Re: No ROLLBACK within TestCase on second database

2012-09-05 Thread Mike Dewhirst

On 5/09/2012 3:09pm, Kit Randel wrote:

On 05/09/12 16:28, Mike Dewhirst wrote:

I asked about this a couple of weeks ago and the correct solution is
to use a TransactionTestCase


Hi Mike,

I don't want to be explicitly test transactional behaviour, which I
think is the intention behind TransactionTestCase. I just want each test
running a transaction which rolls back on teardown. The django
documentation for TestCase seems to suggest that TestCase should provide
the behaviour I'm wanting:

/class/TestCase
Wraps each test in a transaction.

https://docs.djangoproject.com/en/dev/topics/testing/#testcase


In your earlier post you mention Django 1.2 but the reference you quote 
above is the dev documentation. There are differences in the docs but 
I'm not sure what the underlying code differences might be.


You are right though. If you want to test commits and rollbacks 
TransactionTestCase is your thing. By my reading of both 1.2 and dev 
docs, vanilla TestCase imported from Django on the other hand should 
handle commits and rollbacks itself.


As to your second database, I can't help because I have zero experience 
with multiple databases. However, I think I have recently seen a caveat 
in the docs somewhere about testing with multiple database. I haven't 
looked in the 1.2 docs for some time.


Mike


Explicitly calling connection._rollback() in a TransactionTestCase
unfortunately has the same behaviour and only calls ROLLBACK on the
'default' database.



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