Re: Advice on python version for new project

2016-08-15 Thread Nick Santos
I'd recommend Python 3 at this point unless you encounter a good, specific
reason to use Python 2. If you use the six 
module, it's really easy to write code that can be used for both versions
without writing conditionals everywhere. If you then encounter something
that forces you to use Python 2, you can downgrade without trouble. But if
this application has anything close to the lifespan of the previous one,
you'll want to be using Python 3 if at all possible. That's without
mentioning the other benefits of Python 3 too!

-Nick 

On Mon, Aug 15, 2016 at 12:37 PM, Rich Shepard 
wrote:

>   The django web site suggests that new projects use python3 unless
> required
> dependencies are not yet available for that version. I've no idea what
> python dependencies I'll need for this job.
>
>   What I want to do is convert an abandoned php application (last upgraded
> a
> decade ago) to django. The application is XRMS, an open source CRM (client
> relationship manangement tool in my case) that is perhaps the only one that
> supposedly supported postgresql via adodb. What I learned over the weekend
> is that I cannot even install it and cannot find the reason why it's not
> connecting to the db back end.
>
>   A posting on a forum thread from 2007 reported that postgres was not
> supported unless all extensions (none of which I need) are installed, and
> all those extensions are hard coded for mysql. I have source code, schema,
> and a very full set of docs; suprizingly complete.
>
>   I suppose there's no reason to not use python-2.7.5 installed here for
> this project, unless you advise me otherwise. I also need some advice and
> guidance on how to proceed on creating a django application from the php
> source files.
>
> TIA,
>
> Rich
>
>

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


Re: Fwd: Moving from 1.2 to 1.6

2014-04-09 Thread Nick Santos
Thanks for that. If you inspect a generated page with the form using 
something like Firebug or Chrome Inspector, can you confirm that there is a 
hidden form element named csrfmiddlewaretoken? If you're trying to 
serialize the values in the page to send via AJAX, you can try using that 
value instead of the cookie value (I've AJAXed many forms and have never 
dealt with a CSRF cookie).

Also, does the form work if you don't send it via AJAX and just do a normal 
POST/GET from the browser?
-Nick

On Wednesday, April 9, 2014 5:59:37 PM UTC-7, John Fabiani wrote:
>
>  I have created a csrf.js added the code.
> I added it to the html base
> 
>  
> I've added the {% csrf_token %} in the form.
>  
>
>  Where oh where do I use the code or is it magic!  Does it really work?
>  
> I don't mean to be an ass but using google search I find over 20,000 hits 
> on the django and csrf on several of the sites.  Stackoverflow has 12,000 + 
> on one page about this
>
>
> http://stackoverflow.com/questions/6506897/csrf-token-missing-or-incorrect-while-post-parameter-via-ajax-in-django/6533544#6533544
>  
> This might be the greatest thing since slice bread but I can't figure out 
> how to use it!
>  
> At this point I'm willing to pay some guru!
>
> And below is what I get from debug.
>  
> Reason given for failure:
>
> CSRF cookie not set.
> 
>
> In general, this can occur when there is a genuine Cross Site Request 
> Forgery, or when Django's CSRF 
> mechanism<http://docs.djangoproject.com/en/dev/ref/contrib/csrf/#ref-contrib-csrf>
>  has not been used correctly. For POST forms, you need to ensure:
>
>- Your browser is accepting cookies. 
>- The view function uses 
> RequestContext<http://docs.djangoproject.com/en/dev/ref/templates/api/#subclassing-context-requestcontext>
> for the template, instead of Context. 
>- In the template, there is a {% csrf_token %} template tag inside 
>each POST form that targets an internal URL. 
>- If you are not using CsrfViewMiddleware, then you must use 
>csrf_protect on any views that use the csrf_token template tag, as 
>well as those that accept the POST data. 
>
> You're seeing the help section of this page because you have DEBUG = True in 
> your Django settings file. Change that to False, and only the initial 
> error message will be displayed.
>
> You can customize this page using the CSRF_FAILURE_VIEW setting.
>  
> Johnf
>  
> On 04/09/2014 04:25 PM, Nick Santos wrote:
>  
> Hey John,
>  
>  Is this a server you could turn set DEBUG=True for and send this list the 
> results of the error page that's produced? That could be super valuable in 
> tracking down the error.
>  
>  -Nick
>
> On Wed, Apr 9, 2014 at 4:00 PM, John Fabiani 
> <jo...@jfcomputer.com
> > wrote:
>
>>  Do you guys think is possible the jQuery Form plugin is some how 
>> interfering with the token?
>>
>> Johnf 
>>
>> On 04/09/2014 02:18 PM, John Fabiani wrote:
>>
>> The code looks great.  I just do not know where the code goes and how it 
>> is to be called.
>> For example:  Should the code you provided be in .alaxSubmit -> 
>> beforeSubmit: showRequest or is there some other way I should call the 
>> functions.  Does the code add to my data - if so where and how does that 
>> work?
>>
>> I tired adding the code to the beforeSubmit but still get the 403 error.  
>> I'm missing something very fundamental.
>>
>> Johnf
>> On 04/09/2014 12:22 PM, C. Kirby wrote:
>>  
>> Okay. I may get a few of the details wrong here, but the general idea 
>> should be correct.
>> Basically CSRF makes sure that the request is coming from a page served 
>> by the same domain. In order to do this it checks the REFERRER header to 
>> make sure it is in the same domain. The cookie that you grab using the code 
>> you showed is used in generating the ajax headers.
>>
>> So, how to use it. I do it slightly differently than the example - I use 
>> jquery .ajaxSend() <https://api.jquery.com/ajaxSend/> instead of the 
>> $.ajaxSetup() they provide. What I like about the way I use it is you put 
>> all of the ajax related csrf code in one $(document) block in an always 
>> included .js file and it Just Works(TM)
>>
>> Here is the code that I use:
>>
>>  $(document).ajaxSend(function(event, xhr, settings) {
>> function getCookie(name) {
>> var cookieValue = null;
>> if (document.cookie && document.cookie != '') {
>> var cookies = document.cookie.split(';');
>> for (var i = 0; i <

Fwd: Moving from 1.2 to 1.6

2014-04-09 Thread Nick Santos
Hey
John,

Is this a server you could turn set DEBUG=True for and send this list the
results of the error page that's produced? That could be super valuable in
tracking down the error.

-Nick

On Wed, Apr 9, 2014 at 4:00 PM, John Fabiani  wrote:

>  Do you guys think is possible the jQuery Form plugin is some how
> interfering with the token?
>
> Johnf
>
> On 04/09/2014 02:18 PM, John Fabiani wrote:
>
> The code looks great.  I just do not know where the code goes and how it
> is to be called.
> For example:  Should the code you provided be in .alaxSubmit ->
> beforeSubmit: showRequest or is there some other way I should call the
> functions.  Does the code add to my data - if so where and how does that
> work?
>
> I tired adding the code to the beforeSubmit but still get the 403 error.
> I'm missing something very fundamental.
>
> Johnf
> On 04/09/2014 12:22 PM, C. Kirby wrote:
>
> Okay. I may get a few of the details wrong here, but the general idea
> should be correct.
> Basically CSRF makes sure that the request is coming from a page served by
> the same domain. In order to do this it checks the REFERRER header to make
> sure it is in the same domain. The cookie that you grab using the code you
> showed is used in generating the ajax headers.
>
> So, how to use it. I do it slightly differently than the example - I use
> jquery .ajaxSend()  instead of the
> $.ajaxSetup() they provide. What I like about the way I use it is you put
> all of the ajax related csrf code in one $(document) block in an always
> included .js file and it Just Works(TM)
>
> Here is the code that I use:
>
>  $(document).ajaxSend(function(event, xhr, settings) {
> function getCookie(name) {
> var cookieValue = null;
> if (document.cookie && document.cookie != '') {
> var cookies = document.cookie.split(';');
> for (var i = 0; i < cookies.length; i++) {
> var cookie = jQuery.trim(cookies[i]);
> // Does this cookie string begin with the name we want?
> if (cookie.substring(0, name.length + 1) == (name + '=')) {
> cookieValue = 
> decodeURIComponent(cookie.substring(name.length + 1));
> break;
> }
> }
> }
> return cookieValue;
> }
> function sameOrigin(url) {
> // url could be relative or scheme relative or absolute
> var host = document.location.host; // host + port
> var protocol = document.location.protocol;
> var sr_origin = '//' + host;
> var origin = protocol + sr_origin;
> // Allow absolute or scheme relative URLs to same origin
> return (url == origin || url.slice(0, origin.length + 1) == origin + 
> '/') ||
> (url == sr_origin || url.slice(0, sr_origin.length + 1) == 
> sr_origin + '/') ||
> // or any other URL that isn't scheme relative or absolute i.e 
> relative.
> !(/^(\/\/|http:|https:).*/.test(url));
> }
> function safeMethod(method) {
> return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
> }
>
> if (!safeMethod(settings.type) && sameOrigin(settings.url)) {
> xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
> }
> });
>
>
> jquery is up to 1.11 (on the 1.x branch) you will probably gain a lot from
> upgrading, but I would be a bit worried about deprecated features. Try it
> out, if it works with no issues - great, if not then you can decide if you
> want to fix the errors or revert.
>
> Kirby
>
> On Wednesday, April 9, 2014 1:57:24 PM UTC-5, John Fabiani wrote:
>>
>>  Also I was using jquery 1.4 with Django 1.2.  Should I upgrade the
>> jquery?
>>
>> Johnf
>> On 04/09/2014 11:54 AM, John Fabiani wrote:
>>
>> I've read that paragraph 15 different ways (maybe even standing on my
>> head).  I still don't understand what I'm missing.
>> Believe me I realize I might be the only person that doesn't get it -
>> such is life.
>>
>> Could you highlight what exactly I'm missing.  What do you mean by
>> "missing necessary headers"?
>>
>> The code that includes the 'headers' in the doc's is exactly the part I
>> don't understand.  Where does that code go and how does it relate to my
>> code.
>>
>> Johnf
>>
>> On 04/09/2014 10:51 AM, C. Kirby wrote:
>>
>> Hi John,
>> You are mostly there, but you are missing necessary headers on the ajax
>> request.
>> It isn't that much code. Just follow the couple of paragraphs of doc and
>> examples here:
>> https://docs.djangoproject.com/en/1.6/ref/contrib/csrf/#ajax
>>
>> Kirby
>>
>> On Wednesday, April 9, 2014 12:47:12 PM UTC-5, John Fabiani wrote:
>>>
>>>  Hi,
>>>
>>> I be honest this {% csrf_token %} has me completely baffled.  I have
>>> read the doc's and I guess I have to admit I don't 

Re: A subprocess call fails, but only under Django

2014-03-11 Thread Nick Santos
Hey Shawn,

What does your web stack and environment look like? If it's failing during
a fork with an out of memory, that makes me wonder if the host process for
django is consuming a chunk of memory for some reason, and when it gets
forked, it'll get replicated over (which supposedly would fail, even with
copy on write, with certain OS settings - I'm far from an expert in this
area). Have you tested this code on another machine to see if it exhibits
the same behavior?
-Nick

On Tue, Mar 11, 2014 at 5:07 PM, Shawn Milochik wrote:

> Hi Russ, thanks for the reply.
>
> What I mean by "under Django" is if I call it from within a view or with
> "manage.py shell" I get the problem. On the system in question, "manage.py
> shell" does in fact invoke iPython. However, invoking iPython manually
> (without manage.py) works. Executing the script stand-alone works.
>
> I tried to circumvent the entire problem by adding an "if __name__ ==
> '__main__'" block to the script and having it take a command-line argument
> via argparse and print the desired output. Then I did a
> subprocess.check_output call on *that* instead of importing the module.
> This worked from "manage.py shell," but not within a view in Django -- the
> same OS error 12.
>
> The error happens in a call to os.fork within the subprocess.call or
> subprocess.check_output methods (I tried both). The traceback is here:
> http://bpaste.net/show/NRYtgvzoqyOBawl6XoxY/
>
> I'm going to have to keep poking at it, but I was really hoping someone
> had encountered this before. I did see some cases via Google on forums and
> StackOverflow where people reported the problem, but there were no answers
> other than directly addressing the amount of memory required, but I'm
> pretty sure this script isn't consuming much memory. Even when it's not
> running ls, it's just doing a subprocess call to gpg to sign and encrypt a
> file. It takes well under one second.
>
> Thanks for looking at it.
> Shawn
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAOzwKwFtAFocN0riTpViRhwRxTuvGR4dX6T53ToQdwJHZAr7bQ%40mail.gmail.com
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Gunicor + Postgres + Python 3

2014-03-09 Thread Nick Santos
Hey Henrique,

Can you send the code for the view that generates the page?

-Nick 


On Sun, Mar 9, 2014 at 9:14 PM, Henrique Oliveira <
henriqueollive...@gmail.com> wrote:

> Hi there,
>
> I have set Django + gunicorn + python 3 in a production env, but I am
> gettin critical timeout on simple request(home).
> Any Ideas?
>
> 14-03-09 23:11:21 [14029] [INFO] Listening at: http://127.0.0.1:8001(14029)
> 2014-03-09 23:11:21 [14029] [INFO] Using worker: sync
> 2014-03-09 23:11:21 [14039] [INFO] Booting worker with pid: 14039
> 2014-03-09 23:11:21 [14040] [INFO] Booting worker with pid: 14040
> 2014-03-09 23:11:21 [14041] [INFO] Booting worker with pid: 14041
> 2014-03-09 23:11:31 [14040] [DEBUG] GET /done
> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
> 2014-03-09 23:12:02 [14029] [CRITICAL] WORKER TIMEOUT (pid:14040)
>
> Cheers
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/641f550d-4e8b-4a36-b76f-93d8100f3500%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: DDT not showing

2014-03-09 Thread Nick Santos
Since you didn't say that you have - did you add it to your INSTALLED_APPS?

-Nick 


On Sun, Mar 9, 2014 at 12:03 PM, Aiden  wrote:

> Hi all,
>
> Banging my head against a wall trying everything to get DDT to appear
> using Gunicorn+nginx
> I have the following:
>
> DEBUG = True
> TEMPLATE_DEBUG = True
> SHOW_TOOLBAR_CALLBACK = lambda x: True
> DEBUG_TOOLBAR_PATCH_SETTINGS = False
>
> along with the URL settings for __debug__ in my urls.conf. The routes are
> attaching, but I can't work out
> how to get DDT to appear. It isn't in the HTML output, it just isn't
> there. It was working but now it isn't even
> working with manage's runserver.
>
> Any help would be great! . Versions:
>
> django-debug-toolbar==1.0.1
> gunicorn==18.0
> Django==1.6.2
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8bcdde5c-d965-4be5-9e07-a696d38eb236%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

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


Re: Django Windows Install Issues

2014-02-25 Thread Nick Santos
Hi Joe,

You shouldn't need to set any paths to install Django. If you open a
command prompt up and navigate to the folder (or hold down shift and right
click in the folder and select "Open Command Window Here" then run the
command "python setup.py install" it will install Django.

Also, I'd highly recommend you install a package manager like "pip", which
will make future installs much easier.

-Nick 


On Tue, Feb 25, 2014 at 1:23 PM, Joe Buty  wrote:

> Hello, I am having trouble getting Django to work. I have installed python
> and downloaded and unzipped the .tar file for django. I am using windows 8
> ugh and can not open the instal file. I read through the setup.py and I
> think I need help setting the correct path. Either moving the Django unzip
> folder or declare where it is.
>
> If any one can offer me advice or even just describe how they got Django
> to work, whether its on Win8 or something more useful.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/54607b0b-7de9-4bc9-b6fd-8e404425f68b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: virtualenv on Windows

2014-02-03 Thread Nick Santos
FYI, virtualenvwrapper was ported to windows:
https://pypi.python.org/pypi/virtualenvwrapper-win

It works seamlessly like the linux/OSX versions
-Nick 



On Mon, Feb 3, 2014 at 3:10 PM, Mike Dewhirst  wrote:

> Michel
>
> I learned quite a lot and appreciate it greatly!
>
> Thankyou
>
> Mike
>
>
> On 4/02/2014 7:37am, werefrog wrote:
>
>> Hello,
>>
>> For Windows, I tried many ways that worked but I finally installed
>> Visual Studio 2008 C++ for the compilation problems and only pillow and
>> psycopg2 resist in my case (I simply extract the content of the binaries
>> from http://www.lfd.uci.edu/~gohlke/pythonlibs/, copy content from
>> 'SCRIPTS' to project's virtualenv 'Scripts' and 'PLATLIB' to project's
>> virtualven 'Lib/site-packages'; I'll give a try to the easy_install with
>> them, thank you).
>>
>> While speaking of psycopg2, I spent a ridiculous amount of time
>> struggling with postgresql installation on Windows to finally discover
>> that you should stick to ASCII for the password chosen on this platform.
>> (Yes, I missed some warning).
>>
>> You can use virtualenvwrapper-win on Windows. The documentation is short
>> and efficient but here is some basic steps, begining from install:
>>
>>  pip install -U virtualenv
>>  pip install -U virtualenvwrapper-win
>>
>> You have to set WORKON_HOME environment variable to to directory where
>> will be grouped your virtualenvs to make it convenient.
>>
>> Update pip and setuptools:
>>
>>  easy_install -U pip
>>  pip install -U setuptools
>>
>> Then, create your virtualenv:
>>
>>  mkvirtualenv myproject
>>
>> Activate the virtualenv (you will then be on %WORKON_HOME%/myproject/):
>>
>>  workon myproject
>>
>> I keep projects in their own directory independant from virtualenv. To
>> add your project directory to its virualenv's pythonpath, use the
>> following command where  can be full or relative:
>>
>>  setprojectdir 
>>
>> Now, install your requirements:
>>
>>  pip install -r requirements.txt
>>
>> You can use cdproject and cdvirtualenv commands to go to project and
>> virtualenv directories.
>>
>> To go back to the 'general' environment, just type:
>>
>>  deactivate
>>
>> Additional details you probably already know: remember to not rely on
>> the registry to execute your python scripts :) for example:
>>
>>  python manage.py runserver
>>
>> and not:
>>
>>  manage.py runserver
>>
>> Edit you virtualenv's Script\activate.bat to add any other specific
>> environment variables and don't forget .pth files for specific python
>> path.
>>
>> That's all for today!
>>
>> Regards,
>> Michel
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/52F021F0.1050004%40dewhirst.com.au.
>
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: How do I test my Django App on my Phone

2013-12-09 Thread Nick Santos
I'm not familiar with the method you mentioned - and don't think it should
work unless you establish a network connection through your USB connection,
amongst other things. In a basic sense, 0.0.0.0 is nonroutable if you try
to access it externally. That runserver command, if I remember correctly,
uses 0.0.0.0 to bind to all of your computer's IP addresses (so you can
access it externally). A simpler way than trying to network over USB would
be to connect your phone to the the same network (via wifi, unless that's
not an option), and open port 8000 to your development machine in its
firewall. Then determine that machine's public IP address (eg 1.2.3.4) and
enter that into your browser as 1.2.3.4:8000. Then it should come up on
your phone.
-Nick 



On Mon, Dec 9, 2013 at 10:44 AM, Muhammad Ali  wrote:

> Hello,
>
> I'm developing a Django-powered blog, with two versions: a desktop version
> and a mobile I optimized version for when it is accessed through a mobile
> device.
>
> Now, I'm trying to test it on my Samsung phone to see how it would look
> and act like when someone uses it through a mobile phone's browser [iPhone,
> Android, etc.]
>
> Instructions I found online (such as this one: ) say that I should plug
> the phone to the computer through a USB and run: manage.py runser
> 0.0.0.0:8000 and visit this IP address via my phone's browser. But it
> doesn't work and instead returns an error:
>
> "Oops! Google Chrome could not connect to 0.0.0.0:8000"
>
> What am I missing in the setup? What are other, if any, alternative ways
> of testing my Django app on my phone during development?
>
> Thank you for your time and help.
>
> Sincerely,
> Muhammad
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/47bac303-2b53-4f9d-bd93-acbc1d4f1b09%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: To Django or not to Django

2013-11-24 Thread Nick Santos
I'd say the answer depends on your personal capabilities and objectives.
"Best" tends to always be relative to what you know and your personal
requirements as much as to you specific design requirements. Nothing you've
said here sounds like it couldn't be done with a CMS and some plugins, and
if you're not a proficient programmer, or you want this set up very
quickly, I'd suggest you look there first. If you have a goal of learning
new technologies, or you need specific extension points that a CMS can't
provide, or if you want the experience to be more tightly integrated than a
CMS, then django could be a good option for you.

-Nick 


On Sun, Nov 24, 2013 at 10:37 AM,  wrote:

> Hi,
> I'm looking to build a contest website where there would be a challenge
> every so often where people need to post a video or a picture.  Then all
> users can vote on them, and I can announce a winner.   I would prefer maybe
> if people not actually upload to my site, but provide a link to youtube,
> instragram, etc.
>
> My website building experience is limited, but I am a techie, so I could
> spend some time learning stuff, but my question is, what is the best
> solution for such site?  Do I need a CMS site, maybe use django CMS, or
> just django and use many of the available plugins.   Or is there a host
> that can provide a configurable solution like some have with e-commerce
> sites?
>
>
>
> Help is appreciated.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e64f41f1-3c3a-4237-b9d5-ec61345b74dc%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

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


Re: Django: Temporary "wait page" while heavy compute processing is handled

2013-08-12 Thread Nick Santos
Hi Howard,

You will want to look into Celery , which lets
you do heavy processing outside of your web requests. You can then use some
checking via Javascript to see if the work is done yet and load a new page,
or ask the user to come back later. There's a celery "app" for django that
makes certain tasks a little easier. Sorry I can't provide more details
than pointing you there right now, but I hope that helps. Someone on this
list may have some better options for you that involve less setup, but
Celery is the first thing that came to mind for me.

Also, just as an FYI, your links won't work because they point to your
local development server and can't be accessed by anyone else.
-Nick



On Mon, Aug 12, 2013 at 8:49 AM, Julio Molina Soler wrote:

> Hi Howard,
>
> I'm not very experience with django yet, but if you are not very familiar
> with Ajax I recommend to have a look on jQuery, I also have no experience
> with Ajax, that's why I work with it, I find it more friendly, and get the
> things nicely done (mostly popup menus and so on). That link may help you
> http://jqueryui.com/progressbar/
>
> I hope someone can give you a better django approach, but I think the
> clean one would be via Ajax.
>
> Julio
>
>
> On Monday, August 12, 2013 6:28:35 AM UTC+2, Howard S wrote:
>>
>> Hi everyone,
>>
>> I have a page whose content cannot be loaded until a lot of computations
>> are done, which may take a minute or two. How can I set up a temporary
>> "wait page" that will direct users to a new link once the computing is done?
>>
>> For example:
>> User submits an input: 
>> http://127.0.0.1:8000/tools/**submit/
>>
>> User waits for output: 
>> http://127.0.0.1:8000/tools/**WaitPlease/
>> User receives the output: 
>> http://127.0.0.1:8000/tools/**result/
>>
>> If such redirect is a bad practice, can should i do this via AJAX (which
>> I am not very familiar with)?
>>
>> Please and thank you.
>>
>> Best,
>> Howard
>>
>>
>>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: Using Django and R in a production environment?

2013-04-30 Thread Nick Santos
Is Django a hard and fast requirement? If so, is it just about integrating
the routines? I think otherwise something like RStudio Server would work
for you. I've deployed it previously and it was a pretty nice setup. It's
based on Unix user accounts, so R processes run as if users were running
them on a desktop, except not. You may be able to share code in this
environment too, but I haven't played with it a ton.

http://www.rstudio.com/ide/docs/server/getting_started

-Nick

On Tue, Apr 30, 2013 at 12:06 AM, Derek  wrote:

> " if you write your own R  analysis routines, why have them run in a web
> system"
>
> Two issues here:
>
> 1. We are writing R routines for someone else; who needs 'analysis on
> demand'
> 2. A web system means that multiple users in multiple locations can all
> readily access the same analysis routines (but with different data sets)
>
> I agree that if you work on a desktop, with no need to access shared data
> or use the same analysis routines as anyone else, then a web interface
> makes no sense.
>
> Basically we are trying to harness two disparate systems; each of which is
> very powerful in their own sphere, to create an application that is really
> useful for better and more efficient science.
>
>
> On 29 April 2013 16:59, Javier Guerra Giraldez  wrote:
>
>> On Mon, Apr 29, 2013 at 2:13 AM, Derek  wrote:
>> > hat no one is actually using R in a production environment themselves
>> (which
>> > is a little surprising to me).
>>
>>
>> well R itself is widely used in production... but the intersection
>> with Django is very small.  (after all, if you write your own R
>> analysis routines, why have them run in a web system)
>>
>> --
>> Javier
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

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




Re: performance of delete

2013-04-24 Thread Nick Santos
Related to the use of IN, but not an answer, I've found this series of
article from ExplainExtended to be super helpful in optimizing some of my
DB queries. These two are for MySQL, but the author has versions for
Postgres and SQL Server as well. I know this help is limited with an ORM,
but maybe with some clever django-ing you can utilize the core principles
of this.

IN vs JOIN vs EXISTS:
http://explainextended.com/2009/06/16/in-vs-join-vs-exists/
NOT IN vs NOT EXISTS vs LEFT JOIN / IS NULL:
http://explainextended.com/2009/09/18/not-in-vs-not-exists-vs-left-join-is-null-mysql/

Nick Santos
Executive Director, The Environmental Consumer

You sent this email to ultraa...@gmail.com - please note that my current
address is n...@enviroconsumer.org


On Wed, Apr 24, 2013 at 7:22 PM, Matt Long <m...@crocodoc.com> wrote:

> I'm curious how long manually running a single delete query with the
> appropriate where clause would take. Surely there's a way to do that
> through the Django ORM without having to drop into raw SQL?
>
> That being said, there are limits to how long a given query can be, so the
> ORM would have to do some intelligent batching of your IN clause, so maybe
> it does make sense to leave that hairy logic out of the ORM :-)
>
> --
> Matt Long
> Sent with Sparrow <http://www.sparrowmailapp.com/?sig>
>
> On Wednesday, April 24, 2013 at 18:31, Larry Martell wrote:
>
> I changed it to delete one row at a time and it's taking 3 minutes.
>
> On Wed, Apr 24, 2013 at 6:38 PM, Setiaman Lee <setiaman@gmail.com>
> wrote:
>
> Larry,
>
>
> Avoid to use IN clause. I'd say to insert the events you want to delete
> into
> the temp table. You can put the session id or user id in temp table to
> differentiate set of data from other users. Then do the delete by joining
> the temp table to the Event_Message_ldx table. your sql might look like
> this:
>
> delete event_message_ldx
> from temp
> where event_message_ldx.event_id = temp.event_id
> and temp.userid = %s
>
> above SQL can be executed in Django using RAW SQL. See the link below.
> https://docs.djangoproject.com/en/dev/topics/db/sql/
>
> Test the SQL in the MySQL workspace when it works then move the code to the
> Django.
>
> Rgrds,
> Setiaman Lee
>
>
>
>
>
> On Thu, Apr 25, 2013 at 8:12 AM, Larry Martell <larry.mart...@gmail.com>
> wrote:
>
>
> I have a table that has 2.5 million rows and 9 columns that are all
> int except for 2 varchar(255) - i.e. not that big of a table. I am
> executing this statement:
>
> Event_Message_Idx.objects.filter(event_id__in=event_ids).delete()
>
> Where event_ids has around 1,500 items in it. There is an index on
> event_id. This statement is taking 1 hour and 5 minutes to run. There
> is nothing else hitting the database at that time, and the machine
> it's running on is 97% idle and has plenty of free memory. This seems
> extremely excessive to me. I would guess it's because of the in
> clause. Perhaps this is more of a MySQL question when a django one,
> but is there some better way to do a delete like this in django?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@goo

Re: Django in Eclipse+PyDev, lot's of functions and imports are undefined/unresolved

2012-10-26 Thread Nick Santos
I don't have a solution, but I can indicate that the same thing has
happened to me on a standard install of Python 2.7.2 (no virtualenv) on
Windows 7, so I don't know that it's anything about your setup in
particular, if that helps.
-Nick


On Fri, Oct 26, 2012 at 9:48 AM, Chris Pagnutti wrote:

> Hi.  I created a django project using the eric4 IDE.  I'm just trying to
> transfer everything over to Eclipse+PyDev.  I basically just rebuilt the
> whole project from scratch by copying and pasting all the source code.  I'm
> pretty sure I set up my python interpreter fine.  I'm using django-trunk in
> a virtual env.
>
> When I open the console in Eclipse, and can import django and it prints
> the correct version number.  But my project, which worked fine in eric4,
> makes Eclipse complain about unresolved imports and undefined variables.
>  Here a list of a few that might give some clue as to what's wrong:
> from django.conf.urls import patterns, url
> from django.conf import settings
> from django.contrib import admin
>
> urlquote
> send_mail
> _user_has_perm
>
> among a whole bunch of others.
>
> I thought it might have something to do with the auto-reload, but I
> followed this http://pydev.org/manual_adv_django.html (scroll to bottom),
> but it still doesn't work.
>
> Any thoughts would be great.
>
>  --
> 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/-/kDtwvXBFp4cJ.
> 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: Should we have a database independent SQL like query language in Django?

2012-10-06 Thread Nick Santos
I agree with Babatunde. I think it would be too much of a barrier to entry
and tries to solve some of the problems that the ORM/SQL in general solve
or are intended to solve (generalizability). I'd personally rather enhance
the ORM where necessary, or suggest that if you plan on switching between
databases in an application with raw sql, you consider some method for
setting a flag that indicates which version of raw sql to send. But maybe
I'm underestimating the need for this sort of feature.
-Nick

On Sat, Oct 6, 2012 at 9:59 AM, Babatunde Akinyanmi wrote:

> IMO, 'fake sql' would be another layer of abstraction *like the the
> ORM* over different databases that don't work the same way. The result
> would be the same. Since the ORM works fine, the ORM could be improved
> to cater for some of these more complex cases. It leaves using django
> a matter of learning python and not python and another sql language.
> My 50 kobo
>
> On 10/6/12, Yugal Jindle  wrote:
> > *Note :*
> >
> >  - I know we have `Django ORM` already that keeps things database
> > independent and converts to the database specific `SQL` queries.
> >  - Once things starts getting complicated it is preferred to write `raw
> > SQL` queries for better efficiency.
> >  - When you write `raw sql` queries your code gets trapped with the
> > database you are using.
> >  - I also understand its important to use the full power of your database
> > that can-not be achieved with the `django orm` alone.
> >
> > *My Question :*
> >
> >  - Until I use any database specific feature, why should one be trapped
> > with the database.
> >  - For instance :
> >
> > We have a query with multiple joins and we decided to write a raw sql
> >> query. Now, that makes my website `postgres` specific. Even when I
> >> have not used any postgres specific feature.
> >
> >
> > I feel there should be some `fake sql` language which can translate to
> any
> > database's sql query. Even Django's ORM can be built over it. So, that if
> > you go out of ORM but not database specific - you can still remain
> database
> >
> > independent.
> >
> > I asked the same question to `Jacob Kaplan Moss` (In person) :
> >
> >  - He advised me to stay with the database that I like and endure its
> whole
> >
> > power, to which I agree. But my point was not that we should be `database
> > independent`.
> >  - My point is we should be database independent until we use a database
> > specific feature.
> >
> > *
> > *
> > *Please explain, why should be there a `fake sql` layer over the actual
> sql
> >
> > ?*
> >
> > --
> > 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/-/cQW4Vpc9ueYJ.
> > 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.
> >
> >
>
> --
> Sent from my mobile device
>
> --
> 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: My "Contributors" page Conundrum

2012-08-27 Thread Nick Santos
Hi JJ,

You're absolutely right that there is a better way to do this that doesn't
involve repetition. To start with, check out the docs under example on the
page for the URL dispatcher:
https://docs.djangoproject.com/en/dev/topics/http/urls/ - I'll walk you
through part of it though.

First, let's take a look at how capture groups work. Capture groups allow
you to pass a variable portion of the url to a view, which is what you'll
need to do in order to have one definition that lets you have a generic
view that looks up the contributor. So, you can assign a view to a URL
where only part of it is known at the time of the definition, and pass the
unknown parts into the view. In your case, your url definition would look
like:

urlpatterns = patterns('',
 your other patterns...
(r'^about/contributor/(?P[a-zA-Z]+)/$', 'your.view.name'),
possibly more patterns 
)

So, what that (?P[a-zA-Z]+) says, in parts is that we want to
capture a value - designated by the parenthesis - to be passed to
your.view.name as a named parameter called contribname - this is defined by
the ?P. That value looks like text with at least one
character. The text definition is [a-zA-Z] (careful, this doesn't include
spaces right now)and the at least one is +, and comes between two slashes.
If you want to learn more about writing things like that, look into regular
expressions.

Then, in your view, you can take that parameter and look up the relevant
contributor and make the view generic to something like:

def contributor_page(request, contribname):
contrib_object = Contributor.objects.filter(name=contribname)
return render_to_response('contributor.html', {'Contributor':
contrib_object}, context_instance = RequestContext(request))

Then, in outputting your links, you can put the relevant name in the url,
etc.

I hope that helps. Let me know if anything is unclear. Good luck


On Mon, Aug 27, 2012 at 9:58 PM, JJ Zolper  wrote:

> Hello,
>
> I'm trying to develop a simple hyperlink between two pages. It sounds
> simple but it's a little bit more complex then that.
>
> Here is the template code that proceeds through the database of
> contributors:
>
> Contributors
>
> 
>  {% for Contributor in Contributors_List %}
> http://www.madtrak.com/about/contributors/;>{{
> Contributor.name }}
>  
> Title: {{ Contributor.title }}
> 
>  {% endfor %}
> 
>
> and spits out the contributors name in a link form and the title of that
> person.
>
> My problem is that I want each contributor to have their own separate
> page. So if the first guys name for some example is Mike Smith then if you
> were to click his name for example you would be sent to
> /about/contributor/mikesmith and so on. I supposed I could define a url for
> each contributor so I could set this up:
>
> Contributors
>
> 
> {% for Contributor in Contributors_List %}
>  {{ Contributor.name }}
> 
>  Title: {{ Contributor.title }}
> 
> {% endfor %}
>  
>
> but that doesn't seem like the correct way to do this. that
> Contributor.link is then hardcoded into the system. It's not generated by
> the system obviously.
>
> I also have:
>
> def mikesmith(request):
> mikesmith = Contributor.objects.filter(name='Mike Smith')
> return render_to_response('mikesmith.html',
> {'Contributor': mikesmith}, context_instance = RequestContext(request))
>
> I have that repeated for each and every contributor. This goes againist
> Django's DRY mentality so I have a feeling there is a much better way.
>
> Thanks,
>
>  JJ
>
> --
> 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/-/xWx39cCFzvYJ.
> 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: After form validation, need to post and call a perl program to display to a log file

2012-08-24 Thread Nick Santos
Obligatory followup (though the docs I believe cover this pretty well) - be 
*very* careful calling subprocess with anything related to a form 
submission. Read the documents that Melvyn linked to carefully because you 
can be opening a massive security hole. If this is just temporary to check 
some output, that's fine, but if you plan on going into production, make 
sure to know the risks and consider alternatives.
-Nick

On Friday, August 24, 2012 6:11:45 AM UTC-7, Melvyn Sopacua wrote:
>
> On 24-8-2012 8:41, Pervez Mulla wrote: 
>
> > Once validation happened (its working good), I wanna call perl script to 
> > disply it content to lof file ... 
> > 
> > 
> > How can I do this ..?? 
>
>  
> FYI, it don't matter that it's perl, you can do this for anything that 
> can be invoked as a "program". 
>
> -- 
> Melvyn Sopacua 
>

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