django 1.6.1 raw_id_fields open a 'change' popup instead of 'select' popup

2014-03-04 Thread Vittorio

django==1.6.1
python==2.7.6
Mac OS X 10.7.5 (development)  & UBUNTU Linux 13.04 (production -- Apache 
2.2.server)
Browsers==(Mac OS X) Safari, Firefox,Chrome; (Linux) Firefox

To put in a nutshell in my app (I'm translating from Italian into English) 
'warehouse' I have a model 'invoice' and a model 'items'. I use the admin 
interface only. 
In an admin form I input all data for a specific invoice (client, date of 
issue, number of invoice) and, by means of inlines, the ordered items. In these 
inlines I defined a raw_id_fields referring to the 'items' model which is 
showing correctly in the form, BUT ... when I click on it  a "change"   page is 
 often (not always) popping up instead of the expected "select" one.
Tis happens both in development and in production.

Surfing the net I saw a message with the same subject as mine 
http://stackoverflow.com/questions/21009319/django-1-6-1-raw-id-fields-open-a-change-popup-instead-of-select-popup
 with a somewhat cryptic only answer...

In my case the pop up window instead of being called by :
http://localhost:8000/warehouse/warehouse/items/?_popup=1 (which - I tested - 
works great showing a 'select' page)

is called by:
http://localhost:8000/warehouse/warehouse/items/?e=1 (which shows a change page)

Why is that and what should I do?

Thanks a lot 
Vittorio


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


Re: [ELI5] how to deploy django

2014-03-04 Thread Daniel Roseman
On Tuesday, 4 March 2014 07:28:04 UTC, Sam Lai wrote:
>
> On 4 March 2014 14:36, Walter Wang > 
> wrote: 
> >  I tried my best to follow the various guides out there, but the 
> official 
> > documentation here 
> > https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/has 
> > different instructions than the instructions here, 
> > 
> https://www.digitalocean.com/community/articles/using-mod_wsgi-to-serve-applications-on-ubuntu-12-04
>  
>
> Follow the digitalocean instructions.


I don't necessarily agree. The digitalocean instructions seem to be for 
Django version 1.4 (annoyingly, they don't specify which version it applies 
to, and don't even put a year on the datestamp of the article). Various 
changes have been made to the default configuration of Django since then. 
The OP needs to specify which version of Django they are using.

In any case, the digitalocean instructions are simply wrong in at least one 
important detail: you should not put your Django code under /public_html.
--
DR.

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


File uploads - a warning

2014-03-04 Thread André Cruz
Hello.

If your application receives file uploads, and thus you have your frontend 
server configured to allow request bodies >= 10MB for example, you should 
pay attention to ticket #21231 
(https://code.djangoproject.com/ticket/21231). Django enforces size limits 
on FILE parts, but does not do the same with FIELD parts, be it in 
multipart requests or form-data.

This means that an attacker can DoS your server by sending requests with 
large FIELD parts for Django to parse. This is easy to do. According to the 
ticket a simple 10MB field can take up 350MB of RAM and make the Django 
worker spin for 30s.

If your application server supports memory usage monitoring for its 
workers, it can help defusing this issue, but does not solve it.

Best regards,
André Cruz

-- 
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/3f759b4c-cf2d-4b04-8499-9c32597e6b1e%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Showing which users are viewing a given page

2014-03-04 Thread Some Developer

Hopefully someone here will be able to point me in the right direction.

Basically I want to be able to view which users are viewing a page at 
any given time and I want to be able to update it in real time using 
JavaScript but I'm at a loss as to how to track which users are viewing 
any given page in Django.


So for instance if I had mydomain.com/page/ I'd like a little box on the 
top of the page saying "Page being viewed by users: xxx and yyy" and 
then when one of those users navigates away from the page the box 
updates to remove that user from the list.


I'm not sure if I have described what I want clearly enough so if you 
need any more information let me know. Any 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/5315C6F8.10701%40googlemail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Showing which users are viewing a given page

2014-03-04 Thread Nevio Vesic
Well proper way of doing that in your case would be to use something like a
socket.io and have each page as a separate channel. Than you can on user
join/leave emit/push appropriate count.

Other way would be to hook on middleware http request and than update or
redis or database entry for that particular "page". Once you have that you
can long poll from javascript to update count.

-- 
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/CAD1DFf0cN0xffQ4SOikn13vxj%2BrCdWVi%2B395-9f1vEt-er%2Br2Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Showing which users are viewing a given page

2014-03-04 Thread Dig
my opinion,

frontend:
setup a ping api, and refresh every 30 seconds, pass in a current page url
from javascript, and return current page viewers.

backup:
a table has 3 main column (user id, page id, last_ping). update the page_id
and last_ping when receiving a ping request. and return users list who are
on the same page and last_ping within 60 seconds.

30 or 60 seconds are sample data.

Regards,
Dig
2014-3-4 下午8:30于 "Some Developer" 写道:

> Hopefully someone here will be able to point me in the right direction.
>
> Basically I want to be able to view which users are viewing a page at any
> given time and I want to be able to update it in real time using JavaScript
> but I'm at a loss as to how to track which users are viewing any given page
> in Django.
>
> So for instance if I had mydomain.com/page/ I'd like a little box on the
> top of the page saying "Page being viewed by users: xxx and yyy" and then
> when one of those users navigates away from the page the box updates to
> remove that user from the list.
>
> I'm not sure if I have described what I want clearly enough so if you need
> any more information let me know. Any 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/5315C6F8.10701%40googlemail.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/CAObE2pED60iprTzivr--LQv_yVPcverJurnJ8EPE9MEpXOq1MQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


about csv import

2014-03-04 Thread Choro Hasu
hello:

I could not  import csv to SnetOS from local pc,  please tell me 

this is my views.py file :
def import_csv(request):
upload_filename = 'csvfile'
if request.method == 'POST' and 
request.FILES.has_key('upload_filename'):
csv_file = request.FILES['csv_file']

response = HttpResponse(mimetype='application/vnd.ms-excel; 
charset=UTF-8')
response['Content-Disposition'] = 'attachment; filename=file.csv'
reader = csv.reader(response)
   
reader = csv.reader(csv_file)
for row in reader:  
tmp = User.objects.create()
tmp.UserID = row[0]
tmp.user_name = row[1]
tmp.first_kana = row[2]
tmp.last_kana = row[3]

tmp.save()
csv_file.close()
return  HttpResponseRedirect('/memo/all')
else:

tmp = User.objects.all()
args = {}
args.update(csrf(request))
args['tmp'] = tmp
return render_to_response('importcsv.html', args)   

this is my html:
{% extends "base.html" %}

{% block content %}


{% csrf_token %}
{{ form.as_table }}
   




{% endblock %}


-- 
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/235e6f94-846f-46f7-a987-f3c7bb8e545a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: modification time in Python - Django

2014-03-04 Thread Paul J Stevens
On 02-03-14 20:49, Jaap van Wingerde wrote:
> views.py:
> ...
> pwd = os.path.dirname(os.path.realpath(__file__ ))
> home_lastmod =  
> strftime('%Y-%m-%dT%H:%m:%SZ',gmtime(os.path.getmtime(pwd+'/templates/art_index.html')))
> ...
> 
> The template says: "2014-03-02T19:03:55Z".

The strtime argument contains a typo. Use %M for minutes!


-- 

Paul J Stevens   pjstevns @ gmail, twitter, github, linkedin
   www.nfg.nl/i...@nfg.nl/+31.85.877.99.97

-- 
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/531594E9.3090903%40nfg.nl.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ELI5] how to deploy django

2014-03-04 Thread Alan Hicks

On 04/03/2014 03:36, Walter Wang wrote:

  I tried my best to follow the various guides out there, but the
official documentation here
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/ has
different instructions than the instructions here,
https://www.digitalocean.com/community/articles/using-mod_wsgi-to-serve-applications-on-ubuntu-12-04

+1 for official documents, assuming you are using Django 1.6

Good clear guidance on mod_wsgi with Apache
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/modwsgi/

Good guidance on wsgi if a little verbose
https://docs.djangoproject.com/en/1.6/howto/deployment/wsgi/




I have been at this for over a week now, and I can't figure out how to
deploy django with mod_wsgi and apache on a linux web server.

Can someone give or point to me a step to step instruction on how to
deploy django?

Specifically,
1. what do I do with the httpd.conf file?
2. wsgi file? what's the difference between "making a wsgi file" and a
wsgi.py file? For example

As per the docs for version 1.6 it is wsgi.py



"wsgi file"

import os
import sys  
sys.path.append('~/public_html/domain1.com/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'MyTestProject.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


Your project is named MyTestProject.settings here



"wsgi.py"

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

Your project is named mywebsite.settings here



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

Thank you for any help.


Perhaps you renamed part of your project?
If your project is named mywebsite located at /usr/local/www/domain1.com 
then the wsgi.py file should contain something like the following six lines:


import os
import sys
sys.path.append('/usr/local/www/domain1.com')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mywebsite.settings")
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

Alan

--
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/5315C3F1.5040600%40p-o.co.uk.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Showing which users are viewing a given page

2014-03-04 Thread Paul J Stevens
On 04-03-14 13:28, Some Developer wrote:
> Hopefully someone here will be able to point me in the right direction.
> 
> Basically I want to be able to view which users are viewing a page at
> any given time and I want to be able to update it in real time using
> JavaScript but I'm at a loss as to how to track which users are viewing
> any given page in Django.

So enter some long-polling javascript that notifies the server every X
seconds that some user is still at the page you're tracking.

> So for instance if I had mydomain.com/page/ I'd like a little box on the
> top of the page saying "Page being viewed by users: xxx and yyy" and
> then when one of those users navigates away from the page the box
> updates to remove that user from the list.

This means that apart from the "I'm still here", you also need a "Who's
here at" as well.

> I'm not sure if I have described what I want clearly enough so if you
> need any more information let me know. Any help is appreciated :).

So for each page you want to track:

use a settimeout loop in javascript to:
- do a POST to some mini-view where you register who's at some page. You
can use the REMOTEUSER (auth-user) to find out who's who, and the
Referer header to see where they are in your site.
- this POST returns some data (json?) that will tell you who else is
there. You can now update your DOM to reflect this information.

If you don't want or care about authenticating users, you can't know who
is actually at the page, just the number of people, and their IP
addresses, browser version, etc.

Of course some people have done this before. Maybe check out TogetherJS
for more real-time collaboration goodies.


-- 

Paul J Stevens   pjstevns @ gmail, twitter, github, linkedin
   www.nfg.nl/i...@nfg.nl/+31.85.877.99.97

-- 
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/5315CFCB.2040907%40nfg.nl.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Showing which users are viewing a given page

2014-03-04 Thread Manu
Hey Some Developer,

If you have the option, try http://www.google.com/analytics/.
There are other similar services to get the analytics about real time usage 
statistics about your website.
If you want to identify each individual user, http://kissmetrics.com/ or 
https://mixpanel.com/ are also good bets.
Actually you can do this even in google analytics with a bit of 
customization. Hope it helps.

Regards,
Some other developer

-- 
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/01646285-d61e-4d84-8a47-d6177f5f8aae%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ELI5] how to deploy django

2014-03-04 Thread Walter Wang
Thanks alot for all your answers, I really appreciate it.

I am using ubuntu 12.04 lts hosted on digitalocean. Apache version is 2.2.2 
and django is 1.6, I created a virtualenv in the home directory, named 
myproject, I am using python3.2 as the interpreter in the virtualenv. 

All your answers has given renewed energy. 

So from reading all your answers, based on having django 1.6. I should edit 
the wsgi.py file and I don't have to make a "wsgi file" according to the 
digital ocean instructions.

What about the httpd.conf file? According to sam I should not touch it, but 
the official documentation for 1.6 says otherwise.

-- 
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/2728636a-1b69-4836-b5f4-bb95c89f39ea%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ELI5] how to deploy django

2014-03-04 Thread Daniel Roseman
On Tuesday, 4 March 2014 16:53:32 UTC, Walter Wang wrote:
>
> Thanks alot for all your answers, I really appreciate it.
>
> I am using ubuntu 12.04 lts hosted on digitalocean. Apache version is 
> 2.2.2 and django is 1.6, I created a virtualenv in the home directory, 
> named myproject, I am using python3.2 as the interpreter in the virtualenv. 
>
> All your answers has given renewed energy. 
>
> So from reading all your answers, based on having django 1.6. I should 
> edit the wsgi.py file and I don't have to make a "wsgi file" according to 
> the digital ocean instructions.
>
> What about the httpd.conf file? According to sam I should not touch it, 
> but the official documentation for 1.6 says otherwise.
>

No, in Debian-based distributions like Ubuntu, the specific configuration 
for each virtual host is in the sites-available directory. Follow the 
DigitalOcean instructions for that part, except that the WSGIScriptAlias 
should point to your existing wsgi.py file, which you should not need to 
edit.
--
DR.

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


Re: Trouble with Django in production server.

2014-03-04 Thread Daniel Roseman
On Tuesday, 4 March 2014 00:54:48 UTC, Omar Acevedo wrote:
>
> Also there's a file called .bashrc which activates the virtualenv.
> This is the line that does that:
> source /home/userName/.env/env/bin/activate
> So it runs (the virtualenv) always.
>

But the web server is not running as you! So whatever is in your .bashrc is 
completely irrelevant. That's why, as everyone keeps telling you, you need 
to activate the virtualenv in your server, which is normally done in the 
wsgi file. 
--
DR.

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


Re: Trouble with Django in production server.

2014-03-04 Thread Tom Evans
On Tue, Mar 4, 2014 at 7:11 PM, Daniel Roseman  wrote:
> That's why, as everyone keeps telling you, you need
> to activate the virtualenv in your server, which is normally done in the
> wsgi file.

Is it? I keep my wsgi.py exactly as startproject created it, I set
python-path when setting WSGIDaemonProcess in httpd.conf, eg (1.6
layout):

WSGIScriptAlias / /usr/local/mediabox/source/mediabox/wsgi.py
WSGIDaemonProcess mediabox.foo.com
python-path=/usr/local/mediabox/source:/usr/local/mediabox/env_mediabox/lib/python2.7/site-packages
WSGIProcessGroup mediabox.nubtek.com

Cheers

Tom

-- 
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/CAFHbX1LVeCrNqeY3m8KJoZo8%3D6hDDCDd2R%2BsjFg3vbq7SCkv4Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django and amazon web services

2014-03-04 Thread Robin Lery
Thank you Clifford for the heads up and your advice!


On Sun, Mar 2, 2014 at 1:32 AM, CLIFFORD ILKAY
wrote:

> On 03/01/2014 11:21 AM, Robin Lery wrote:
> > Very nicely explained! I was actually hoping to use Amazon RDS  with
> > postgresql. Your help was very useful. Thank you!
>
> There is another issue if your application has to deal with user
> uploaded files, such as photos, PDFs, etc. You must consider the
> instances in an autoscaling cluster to be volatile because they can come
> and go automatically. Consequently, you must have a way of ensuring that
> either the filesystems of those instances are synchronized or store user
> contributed files on Amazon S3. Fortunately, we have pluggable storage
> in Django so it's easy to do the latter.
>
> If you ever have to deploy an application that doesn't have that, as we
> did, we ended up creating an NFS cluster in a VPC (Virtual Private
> Cloud) and the instances in the autoscaling group mounted the exported
> NFS filesystem. The autoscale instances had two network interfaces, one
> for the public Internet and another for the internal network in the VPC,
> so the NFS cluster was not exposed to the Internet.
>
> --
> Regards,
>
> Clifford Ilkay
>
> 647-778-8696
>
> Dinamis
>
> 
>
> --
> 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/53123CF0.9030005%40dinamis.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/CA%2B4-nGpSS5oj5SrL-%3DV21ODWvOi3v%3DTJoHQJTgOdPn-n29M%3D-w%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [ELI5] how to deploy django

2014-03-04 Thread voger
Hi, I am using Debian Wheezy and this is my configuration. This is the 
content of /etc/apache2/sites-available/mysitedomain.com. I made this 
file following the official django docs.


Keep in mind that this is a deployed for testing purposes site so both 
static files and django files are served from the same server, against 
django guidelines. I am posting it here just to give you an example.


I am using the wsgi.py file created by startproject and I don't know if 
I can keep it when I go live. For that maybe we can get some experienced 
advice.


Also I had to rename the /etc/apache2/sites-available/default. 
to default.bak so apache wouldn't default to that.


No need for httpd.conf file. I couldn't find any in my server anyway.

The project is named ssite and the projects folder is simply it's parent 
folder.


Hope this helps

Alias /robots.txt /home/voger/projects/ssite/static/robots.txt
Alias /favicon.ico /home/voger/projects/ssite/static/favicon.ico

AliasMatch ^/([^/]*\.css) /home/voger/projects/ssite/static/styles/$1

Alias /media/ /home/voger/projects/ssite/media/
Alias /static/ /home/voger/projects/ssite/static/


Order deny,allow
Allow from All



Order deny,allow
Allow from All


WSGIDaemonProcess mysitedomain.com 
python-path=/home/voger/projects/ssite:/home/voger/ssite_venv/lib/python2.7/site-packages

WSGIProcessGroup mysitedomain.com

WSGIScriptAlias / /home/voger/projects/ssite/ssite/wsgi.py



Order allow,deny
Allow from All




--
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/53163185.3090602%40yahoo.gr.
For more options, visit https://groups.google.com/groups/opt_out.


confused about sql in django

2014-03-04 Thread Robin Lery
Hello,

I am really being confused. How to use sql in django? I found two:
1. Performing raw queries.
2.Executing custom SQL directly.

Does it have better performance than the django's orm? And how is the
performance the same between those two?

And lastly, what is sqlalchemy? Are sqlalchemy and django's orm the same?
In the website of sqlalchemy it says "*SQLAlchemy is the Python SQL toolkit
and Object Relational Mapper that gives application developers the full
power and flexibility of SQL*".

So I am confused. I will really appreciate very much, if you could help me
understand the above.

Thank you!

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


Why doesn't a forms.fields.DateField always return a datetime.date instance?

2014-03-04 Thread Peter Bengtsson
I've been googling for an explanation but nothing's come up. 

See
https://github.com/django/django/blob/master/django/forms/fields.py#L447

If you use a `DateField` in your form, don't you expect it to produce a 
`datetime.date` instance?
E.g.

class MyForm:
start = forms.DateField()

def clean_start(self):
 if self.cleaned_data['start'] > datetime.date.today():
raise ValidationError('too futuristic')
 return self.cleaned_data['start']

This won't work! You'll get a TypeError if you run that code. 
Why is that?

It'd be easy to fix but because it's so blatant I just suspect I missed 
something obvious. 


Peter

-- 
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/a5ddd8ee-b72e-46c8-9d3c-c211aa76fa25%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: confused about sql in django

2014-03-04 Thread Alex Mandel
On 03/04/2014 12:08 PM, Robin Lery wrote:
> Hello,
> 
> I am really being confused. How to use sql in django? I found two:
> 1. Performing raw queries.
> 2.Executing custom SQL directly.
> 
Do you have links for those? I know there is a the raw query mode of
Django, and I'm guessing the other method you refer to is creating your
own db connection directly with the python driver for a particular
database? The raw queries will at least be more similar to the results
you get from the ORM in terms of object types returned, where direct SQL
would require you to take the results, and iterate them into a useful
object.

> Does it have better performance than the django's orm? And how is the
> performance the same between those two?
> 

Probably not better performing than the ORM, I expect the ORM to behave
better. The key is the ORM returns results in an easy to use object that
can be then passed to the templates. It also has options to pre-cache
some results, only query when you actually need it, etc.
However there are some types of queries the ORM can't do, that's
typically when you need the direct SQL methods.

> And lastly, what is sqlalchemy? Are sqlalchemy and django's orm the same?
> In the website of sqlalchemy it says "*SQLAlchemy is the Python SQL toolkit
> and Object Relational Mapper that gives application developers the full
> power and flexibility of SQL*".
> 

No, Django ORM is a competitor of SQL Alchemy. Though you can use either
or both it's just more work for you.


> So I am confused. I will really appreciate very much, if you could help me
> understand the above.
> 
> Thank you!
> 

Enjoy,
Alex

-- 
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/5316376D.6040808%40wildintellect.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Why doesn't a forms.fields.DateField always return a datetime.date instance?

2014-03-04 Thread Tom Evans
On Tue, Mar 4, 2014 at 8:27 PM, Peter Bengtsson  wrote:
> I've been googling for an explanation but nothing's come up.
>
> See
> https://github.com/django/django/blob/master/django/forms/fields.py#L447
>
> If you use a `DateField` in your form, don't you expect it to produce a
> `datetime.date` instance?
> E.g.
>
> class MyForm:
> start = forms.DateField()
>
> def clean_start(self):
>  if self.cleaned_data['start'] > datetime.date.today():
> raise ValidationError('too futuristic')
>  return self.cleaned_data['start']
>
> This won't work! You'll get a TypeError if you run that code.
> Why is that?
>
> It'd be easy to fix but because it's so blatant I just suspect I missed
> something obvious.

What version of django are you using?

The code linked indicates quite clea

-- 
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/CAFHbX1JQLyrSk872PJJBNvBe0oVzi%3DPc3GN-YN_4_x%3DnHywzhg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Why doesn't a forms.fields.DateField always return a datetime.date instance?

2014-03-04 Thread Tom Evans
On Tue, Mar 4, 2014 at 8:27 PM, Peter Bengtsson  wrote:
> I've been googling for an explanation but nothing's come up.
>
> See
> https://github.com/django/django/blob/master/django/forms/fields.py#L447
>
> If you use a `DateField` in your form, don't you expect it to produce a
> `datetime.date` instance?
> E.g.
>
> class MyForm:
> start = forms.DateField()
>
> def clean_start(self):
>  if self.cleaned_data['start'] > datetime.date.today():
> raise ValidationError('too futuristic')
>  return self.cleaned_data['start']
>
> This won't work! You'll get a TypeError if you run that code.
> Why is that?
>
> It'd be easy to fix but because it's so blatant I just suspect I missed
> something obvious.
>

What version of django are you using?

The code linked indicates quite clearly that it should generate a
datetime.date() instance, or raise a ValidationError.

(apologies for double send, tab+space=bad).

Cheers

Tom

-- 
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/CAFHbX1J17HmqHV60_jHCeyuaKiCxJ5%3DiNUQcGsu1XSHK6r%2BAVA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: confused about sql in django

2014-03-04 Thread Tom Evans
On Tue, Mar 4, 2014 at 8:08 PM, Robin Lery  wrote:
> Hello,
>
> I am really being confused. How to use sql in django? I found two:
> 1. Performing raw queries.
> 2.Executing custom SQL directly.
>
> Does it have better performance than the django's orm? And how is the
> performance the same between those two?

1 and 2 are the same thing. Running the same query using the ORM and
running the same query directly will take the same time - the clue is
in the name, it is the *same* query.

Running queries that return model instances is slower using the ORM
than simply fetching the data row at a time, simply because django
will construct model instances from each row of data, which costs
time.

There are queries that django's ORM cannot express, for those
obviously you must use SQL directly.

The ORM will not write "bad" or slow queries, there is always a
possibility that a query could be written better by hand. The ORM is
powerful, but this power does allow you to write queries that look
simple in code, but actually do complex and unexpected things when
run. Of course, the same is true of writing SQL by hand.

I think it is important to understand that the two do different
things. ORM stands for Object Relational Mapper, which means it is
perfect for extracting objects that are related to each other. SQL
stands for Structured Query Language, which means it can be used to
extract almost any data in whatever format you require. If you want
objects, use the ORM, if you want arbitrary data, use SQL.

Using an ORM does not mean that you no longer have to design and
optimise your database and the queries you run on it. You still need
to check your queries to ensure that your DB engine is optimising them
correctly, that you have the correct indices on the columns you are
querying on - probably also that you aren't repeating the same read
queries over and over again within one request.

>
> And lastly, what is sqlalchemy? Are sqlalchemy and django's orm the same? In
> the website of sqlalchemy it says "SQLAlchemy is the Python SQL toolkit and
> Object Relational Mapper that gives application developers the full power
> and flexibility of SQL".

sqlalchemy is a different ORM to django. All ORMs do basically the
same thing under the hood, so there are obvious similarities between
the two. sqlalchemy has a few more features than django's ORM, at the
cost of being more complex.

You can use sqlalchemy in django instead of django's ORM/models, but
you lose the ability to use anything based on django models - the
admin site, authentication, basically anything that touches the
database. You can still use templates, i18n, some session backends,
forms (but not model forms), views and url handling.

Cheers

Tom

-- 
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/CAFHbX1%2B7nkk-4Mh1MD03aHZyJnoNwAFOi%3DHiie7ahpg6iCBHUQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Admin interface is calling a custom method on my model?

2014-03-04 Thread Greg Barker
I have a model with a custom method like so:

class MyModel(models.Model):
some_counter_field = models.IntegerField(blank=True, default=0)

def my_custom_method(self):
if (self.some_counter_field < 5):
self.some_counter_field += 1
self.save()
return True
else:
return False

The only place this method is called is in one of my templates.

I was using the Django Admin interface to facilitate testing this, so I 
could easily reset some_counter_field back to 0. However, I noticed that 
just by viewing an instance of this model in the admin interface was 
causing some_counter_field to be incremented until it hit 5. What is also 
strange is that this only happens in production, I was not able to 
reproduce this with my local runserver, even when I had DEBUG=False like 
production has.

Any ideas as to what might be going on here?

Thanks!
Greg

-- 
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/1050ca2f-c945-4490-b9ae-e3e6b6cc83b6%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Why doesn't a forms.fields.DateField always return a datetime.date instance?

2014-03-04 Thread Peter Bengtsson


On Tuesday, March 4, 2014 12:47:03 PM UTC-8, Tom Evans wrote:
>
> On Tue, Mar 4, 2014 at 8:27 PM, Peter Bengtsson 
> > 
> wrote: 
> > I've been googling for an explanation but nothing's come up. 
> > 
> > See 
> > https://github.com/django/django/blob/master/django/forms/fields.py#L447 
> > 
> > If you use a `DateField` in your form, don't you expect it to produce a 
> > `datetime.date` instance? 
> > E.g. 
> > 
> > class MyForm: 
> > start = forms.DateField() 
> > 
> > def clean_start(self): 
> >  if self.cleaned_data['start'] > datetime.date.today(): 
> > raise ValidationError('too futuristic') 
> >  return self.cleaned_data['start'] 
> > 
> > This won't work! You'll get a TypeError if you run that code. 
> > Why is that? 
> > 
> > It'd be easy to fix but because it's so blatant I just suspect I missed 
> > something obvious. 
>
> What version of django are you using? 
>
> The link was to django master. So it's in all versions. 

 

> The code linked indicates quite clea 
>

-- 
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/81ccd7ce-d138-47e1-97ee-87742ac5cb42%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


What to do after python manage.py runserver

2014-03-04 Thread Matthew Epps
Hey all,

I apologize for the extremely basic question. I am new to django and 
python. But after I enter the "python manage.py runserver" command, my 
terminal prints out the message that the tutorial says I should expect. 
However, I have a difficult time entering the other commands on the 
tutorial. Should I quit the server? Or do I have to type something in to 
access a point where I could enter more commands?

Thank you,

Matt

-- 
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/7e58b992-825a-4a32-8830-655853c7f2ca%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What to do after python manage.py runserver

2014-03-04 Thread Thomas Murphy
Hi Matthew,

You'll want to leave the window you typed runserver in open so your app can
print information about it's activities to that window. Open another
terminal window and proceed from there.

Happy Hacking!

Thomas


On Tue, Mar 4, 2014 at 4:50 PM, Matthew Epps  wrote:

> Hey all,
>
> I apologize for the extremely basic question. I am new to django and
> python. But after I enter the "python manage.py runserver" command, my
> terminal prints out the message that the tutorial says I should expect.
> However, I have a difficult time entering the other commands on the
> tutorial. Should I quit the server? Or do I have to type something in to
> access a point where I could enter more commands?
>
> Thank you,
>
> Matt
>
> --
> 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/7e58b992-825a-4a32-8830-655853c7f2ca%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/CALgvumV_uJy1nCc%2BdHBPR_Jr0Y%2BNAdZXzz%2BYbWNOEcjL_pL8ag%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: What to do after python manage.py runserver

2014-03-04 Thread Bill Freeman
Or you can share the one terminal by stopping the server to run other
commands, then do runserver again to test them.

The startup message should have told you how to stop (exit, kill) the
server.  On linux it's control-C.  That may work elsewhere too.  (Just for
completeness, in an emacx shell window, it's two control-Cs in a row.)


On Tue, Mar 4, 2014 at 6:22 PM, Thomas Murphy
wrote:

> Hi Matthew,
>
> You'll want to leave the window you typed runserver in open so your app
> can print information about it's activities to that window. Open another
> terminal window and proceed from there.
>
> Happy Hacking!
>
> Thomas
>
>
> On Tue, Mar 4, 2014 at 4:50 PM, Matthew Epps  wrote:
>
>> Hey all,
>>
>> I apologize for the extremely basic question. I am new to django and
>> python. But after I enter the "python manage.py runserver" command, my
>> terminal prints out the message that the tutorial says I should expect.
>> However, I have a difficult time entering the other commands on the
>> tutorial. Should I quit the server? Or do I have to type something in to
>> access a point where I could enter more commands?
>>
>> Thank you,
>>
>> Matt
>>
>> --
>> 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/7e58b992-825a-4a32-8830-655853c7f2ca%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/CALgvumV_uJy1nCc%2BdHBPR_Jr0Y%2BNAdZXzz%2BYbWNOEcjL_pL8ag%40mail.gmail.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/CAB%2BAj0t1oV%3D1j%2BsEfh90BBP1k%3DRt1Q5ah6B5Bn1vZz3w5Ou%3DYA%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


URLValidator raising sre_constants.error

2014-03-04 Thread rectangletangle
When entering two backslashes into the URL validator it raises an 
`sre_constants.error`. As per the 
docs, 
it 
seems like the validator should catch this and then chain a 
`ValidationError`
 
to the exception. This appears to be an issue with Django's integration 
with Python's regex implementation. This may just be my misunderstanding of 
the way Django handles validation, but it seems like *any *form 
of invalid input should raise a 
`ValidationError
`.

I found this while running Django 1.6.2 on Python 3.3.0 on Windows 7.

This session reproduces the bug on my system.

>>> from django.core.validators import URLValidator
>>> URLValidator('\\')
Traceback (most recent call last):
  File "C:\Python33\lib\sre_parse.py", line 195, in __next
c = self.string[self.index + 1]
IndexError: string index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 301, in runcode
  File "", line 1, in 
  File "C:\Python33\lib\site-packages\django\core\validators.py", line 32, 
in __init__
self.regex = re.compile(self.regex)
  File "C:\Python33\lib\re.py", line 214, in compile
return _compile(pattern, flags)
  File "C:\Python33\lib\functools.py", line 258, in wrapper
result = user_function(*args, **kwds)
  File "C:\Python33\lib\re.py", line 274, in _compile
return sre_compile.compile(pattern, flags)
  File "C:\Python33\lib\sre_compile.py", line 493, in compile
p = sre_parse.parse(p, flags)
  File "C:\Python33\lib\sre_parse.py", line 717, in parse
source = Tokenizer(str)
  File "C:\Python33\lib\sre_parse.py", line 183, in __init__
self.__next()
  File "C:\Python33\lib\sre_parse.py", line 197, in __next
raise error("bogus escape (end of line)")
sre_constants.error: bogus escape (end of line)

-- 
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/3b324829-5daf-4975-bc60-244dba0ded53%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: URLValidator raising sre_constants.error

2014-03-04 Thread rectangletangle
I believe I may have found the issue. I was using the validator 
incorrectly. I was passing the string to `__init__` like so `
URLValidator('\\')`, instead of passing it to the `__call__` method like 
this `URLValidator()('\\')`.

On Tuesday, March 4, 2014 4:13:12 PM UTC-8, rectang...@gmail.com wrote:
>
> When entering two backslashes into the URL validator it raises an 
> `sre_constants.error`. As per the 
> docs,
>  it 
> seems like the validator should catch this and then chain a `
> ValidationError`
>  
> to the exception. This appears to be an issue with Django's integration 
> with Python's regex implementation. This may just be my misunderstanding of 
> the way Django handles validation, but it seems like *any *form 
> of invalid input should raise a 
> `ValidationError
> `.
>
> I found this while running Django 1.6.2 on Python 3.3.0 on Windows 7.
>
> This session reproduces the bug on my system.
>
> >>> from django.core.validators import URLValidator
> >>> URLValidator('\\')
> Traceback (most recent call last):
>   File "C:\Python33\lib\sre_parse.py", line 195, in __next
> c = self.string[self.index + 1]
> IndexError: string index out of range
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File "", line 301, in runcode
>   File "", line 1, in 
>   File "C:\Python33\lib\site-packages\django\core\validators.py", line 32, 
> in __init__
> self.regex = re.compile(self.regex)
>   File "C:\Python33\lib\re.py", line 214, in compile
> return _compile(pattern, flags)
>   File "C:\Python33\lib\functools.py", line 258, in wrapper
> result = user_function(*args, **kwds)
>   File "C:\Python33\lib\re.py", line 274, in _compile
> return sre_compile.compile(pattern, flags)
>   File "C:\Python33\lib\sre_compile.py", line 493, in compile
> p = sre_parse.parse(p, flags)
>   File "C:\Python33\lib\sre_parse.py", line 717, in parse
> source = Tokenizer(str)
>   File "C:\Python33\lib\sre_parse.py", line 183, in __init__
> self.__next()
>   File "C:\Python33\lib\sre_parse.py", line 197, in __next
> raise error("bogus escape (end of line)")
> sre_constants.error: bogus escape (end of line)
>

-- 
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/a3b9d7b8-29d0-45fe-ab46-58d01f73cc17%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Why doesn't a forms.fields.DateField always return a datetime.date instance?

2014-03-04 Thread Tom Evans
On Tue, Mar 4, 2014 at 10:45 PM, Peter Bengtsson  wrote:
> The link was to django master. So it's in all versions.
>

Well, that doesn't necessarily follow does it? It could have been
changed recently in trunk, say for 1.6 release. If you were using 1.5
it could be different. I haven't looked back, since you didn't
actually say what version you are using.

Trivially, in 1.6 at least, it works precisely as you expect:

>>> class A(forms.Form):
... s = forms.DateField()
... def clean_s(self):
... print repr(self.cleaned_data['s'])
... return self.cleaned_data['s']
...
>>> A(data={'s':'2012-12-25'}).is_valid()
datetime.date(2012, 12, 25)
True


Does this form also have a custom clean() method, is that doing
something silly with cleaned_data['start'] after the form field has
pythonized it and before your clean_start() method is called?

Cheers

Tom

-- 
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/CAFHbX1%2B4d8tpizusgRcKEdmNZBd71tvfE6k3xfKEzhHiQwH_TQ%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: django 1.6.1 raw_id_fields open a 'change' popup instead of 'select' popup

2014-03-04 Thread Camilo Torres
On Tuesday, March 4, 2014 4:47:58 AM UTC-4:30, Vittorio wrote:
>
> In an admin form I input all data for a specific invoice (client, date of 
> issue, number of invoice) and, by means of inlines, the ordered items. In 
> these inlines I defined a raw_id_fields referring to the 'items' model 
> which is showing correctly in the form, BUT ... when I click on it  a 
> "change"   page is  often (not always) popping up instead of the expected 
> "select" one. 
> Tis happens both in development and in production. 
>
> Surfing the net I saw a message with the same subject as mine 
> http://stackoverflow.com/questions/21009319/django-1-6-1-raw-id-fields-open-a-change-popup-instead-of-select-popupwith
>  a somewhat cryptic only answer... 
>
Hello,

Try to delete your browser cache.

Regards,
Camilo 

-- 
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/8df6ef61-02cb-4b6f-a503-2f91c38d1d87%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Why doesn't a forms.fields.DateField always return a datetime.date instance?

2014-03-04 Thread Peter Bengtsson


On Tuesday, March 4, 2014 5:19:17 PM UTC-8, Tom Evans wrote:
>
> On Tue, Mar 4, 2014 at 10:45 PM, Peter Bengtsson 
> > 
> wrote: 
> > The link was to django master. So it's in all versions. 
> > 
>
> Well, that doesn't necessarily follow does it? It could have been 
> changed recently in trunk, say for 1.6 release. If you were using 1.5 
> it could be different. I haven't looked back, since you didn't 
> actually say what version you are using. 
>
> Trivially, in 1.6 at least, it works precisely as you expect: 
>
> >>> class A(forms.Form): 
> ... s = forms.DateField() 
> ... def clean_s(self): 
> ... print repr(self.cleaned_data['s']) 
> ... return self.cleaned_data['s'] 
> ... 
> >>> A(data={'s':'2012-12-25'}).is_valid() 
> datetime.date(2012, 12, 25) 
> True 
>
> Right you are!
It's independent of version.
My actual code, where this question arose from, isn't using forms.Form as 
the base class. Instead a custom base class which clearly is causing some 
problem. 

I'm using BaseForm from this http://www.peterbe.com/plog/django-baseform
Clearly it's affecting it in some bad way. 
 

>
> Does this form also have a custom clean() method, is that doing 
> something silly with cleaned_data['start'] after the form field has 
> pythonized it and before your clean_start() method is called? 
>
> Cheers 
>
> Tom 
>

-- 
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/f3831069-5e8b-45bf-8faf-c522310e7d46%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.