to_field can not use primary key of related object.

2012-08-22 Thread yillkid



HI all.
I write a model:
class UserGroup(models.Model):
groups = models.ForeignKey(Group, to_field='id')

and when I into admin backend:













According to the Django  document the combobox item should be a "id" field 
in Group model,
but it is not, why ?

-- 
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/-/TUnn-1naTZIJ.
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: database error and connection._rollback

2012-08-22 Thread akaariai
On 23 elo, 08:30, Mike Dewhirst  wrote:
> This ... [1]
>
> from django.db import connection
> connection._rollback()
>
> ... solved a problem for me in unit testing when I catch a deliberate
> DatabaseError.
>
> Django 1.4
> Python 2.7
> PostgreSQL 9.1
>
> My question: Is it safe enough to use a method with a leading underscore?

Generally no. In this specific case you might be safe. However, if you
use _commit() in Django's standard TestCase you might make your
testing DB dirty and some other test could break because of that. This
kind of bug is horrible to debug.

> Is there a better method?

Use TransactionTestCase which is meant for this kind of testing. In
TransactionTestCase you can safely use .commit() and .rollback(). The
cost is slower test execution. See: [https://docs.djangoproject.com/en/
dev/topics/testing/#django.test.TransactionTestCase].

 - Anssi

-- 
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: From Django 1.1 to Django 1.3.1 - Goes Very Slow

2012-08-22 Thread akaariai
On 21 elo, 19:04, ydjango  wrote:
> Thank you Paul. I will use those tools.
>
> I also plan to replace to some ORM queries by raw sql to avoid performance
> impact of cloning and multi db enhancements.

If you can, please try to pinpoint the reason for regressions, and if
it seems to be in Django's ORM, then post to django-developers or
create a ticket in Django's trac. If there is some major regressions
in the ORM it would be very valuable to know about them.

Some possible explanations:
  - The DB configuration isn't exactly as it was before.
  - The ORM generates different query strings leading to slow query
plans.
  - Using F() expressions and long filter chains can lead to slow
queryset .clone() speed (see https://code.djangoproject.com/ticket/16759)

You can try to pinpoint these by:
  - Checking if the generated SQL is the same between 1.1 and 1.3 by
using qs.query.as_str() in 1.1 and str(qs.query) in 1.3.
  - Check if the generation of the queryset takes too much time.
Easiest way is to generate a dummy script which does something like
this:
from datetime import datetime
start = datetime.now()
for i in range(0, 100):
# Do not execute the query, just construct the queryset!
qs = SomeModel.objects.filter(cond1).filter(cond2)... # Replace
with problematic queryset from production.
print datetime.now() - start

And see if there are any meaningful differences.

If the answer to the above is "no meaningful differences, the same SQL
generated" then it is reasonable to suspect the DB configuration.

 - Anssi

-- 
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: CACHE_MIDDLEWARE_ANONYMOUS_ONLY does not work if user is not printed by view or template

2012-08-22 Thread Bill Freeman
I guess this is probably because the request.user object is created on demand
(is a python "property").  The intent, I presume, is to not bother
fetching the session,
etc., unless it is used, as an optimization.

You should find that simply referring to request.user in the view
helps.  If so, then
you may want to add such to the views you want to leave uncached.  An
alternative
is to add a middleware that does this, which will incur the lookup
costs for all views.

Bill

On Tue, Aug 21, 2012 at 1:27 PM, Alexis Bellido  wrote:
> Hello,
>
> I am working on a Django 1.4 project and writing one simple application
> using per-site cache as described here:
>
> https://docs.djangoproject.com/en/dev/topics/cache/#the-per-site-cache
>
> I have correctly setup a local Memcached server and confirmed the pages are
> being cached.
>
> Then I set CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True because I don't want to
> cache pages for authenticated users.
>
> I'm testing with a simple view that returns a template with
> render_to_response and RequestContext to be able to access user information
> from the template and the caching works well so far, meaning it caches pages
> just for anonymous users.
>
> And here's my problem. I created another view using a different template
> that doesn't access user information and noticed that the page was being
> cached even if the user was authenticated. After testing many things I found
> that authenticated users were getting a cached page if the template didn't
> print something from the user context variable. It's very simple to test:
> print the user on the template and the page won't be cached for an
> authenticated user, remove the user on the template, refresh the page while
> authenticated and check the HTTP headers and you will notice you're getting
> a cached page. You should clear the cache between changes to see the problem
> more clearly.
>
> I tested a little more and found that I could get rid of the user in the
> template and print request.user right on the view (which prints to the
> development server console) and that also fixed the problem of showing a
> cached page to an authenticated user but that's an ugly hack.
>
> A similar problem was reported here but never got an answer:
>
> https://groups.google.com/d/topic/django-users/FyWmz9csy5g/discussion
>
> I can probably write a conditional decorator to check if
> user.is_authenticated() and based on that use @never_cache on my view but it
> seems like that defeats the purpose of using per-site cache, doesn't it?
>
> Any suggestions will be appreciated.
>
> Thanks!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/dZx3IJsXp9EJ.
> 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.



database error and connection._rollback

2012-08-22 Thread Mike Dewhirst

This ... [1]

from django.db import connection
connection._rollback()

... solved a problem for me in unit testing when I catch a deliberate 
DatabaseError.


Django 1.4
Python 2.7
PostgreSQL 9.1

My question: Is it safe enough to use a method with a leading underscore?

Is there a better method?

Thanks

Mike

[1] 
http://stackoverflow.com/questions/7753016/djangopostgres-current-transaction-is-aborted-commands-ignored-until-end-of


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



Re: Django + FAPWS doesnt show the templates/view correct

2012-08-22 Thread keeran
I did following changes now., I still see the same observation - I suspect 
the img folder contents are not taken by webserver for some reason related 
to template tags not properly linked. any suggestion welcome (otherwise 
I think i need to go with apache + wsgi)
Am referring this link: *
https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#module-django.contrib.staticfiles
*
 
===
Added below settings under default (under /etc/nginx/conf.d & also under 
sites-enabled dir of nginx

listen 
servername localhost
location /static {
alias /home/keeran/Desktop/IT_mgmt/static/;
index index.html index.htm;
autoindex off;
=
Also, updated the 
[uwsgi]
# set the http port
http = :8080
python_path = /home/keeran/Desktop/IT_mgmt/IT_mgmt/settings.py
# change to django project directory
chdir = /home/keeran/Desktop/IT_mgmt
# load django
module = IT_mgmt.wsgi
uwsgi --ini test.ini --enable-threads
On Friday, August 17, 2012 3:13:00 PM UTC+5:30, keeran wrote:

> On the Django development server, django app works fine. But once I setup 
> the production test run, I get only the text contents, where template views 
> are not shown as intended. What am I going wrong? 
>
> I have django 1.5 latest.
>
>  Nginx - 0.8.54 
>
> uWSGI - 1.2.5
> Also tried FAPWS3.0 similar result;
>  
> cmd for uWSGI:
> =
> sudo uwsgi --ini test.ini
>  
>  
>
> test.ini content:
> ===
> [uwsgi]
> # set the http port
> http = :8080
> python_path = /home/test/Desktop/IT_mgmt/IT_mgmt/settings.py/
> # change to django project directory
> chdir = /home/test/Desktop/IT_mgmt
> # load django
> module = IT_mgmt.wsgi
>
>
> 
>  
>

-- 
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/-/csaqJPUCltoJ.
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: runserver error: "No module named app3"

2012-08-22 Thread Bill Beal
Sorry, MELVYN.

On Wednesday, August 22, 2012 11:53:44 PM UTC-4, Bill Beal wrote:
>
> Thanks, Melvin!  That did it.  On to the next error!
>
>
> On Wednesday, August 22, 2012 5:16:15 PM UTC-4, Bill Beal wrote:
>>
>> Hi all,
>>
>> I have a Django project with apps that works OK on a Mac with Django 1.3 
>> and Python 2.6, and I'm trying to move it to a Linux box with Django 1.4 
>> and Python 2.7.  I created an empty project 'proj' with apps 'app1', 
>> 'app2', 'app3' on the Linux system and carefully merged settings.py, 
>> urls.py etc. with the initial files that were created.  When I run 'python 
>> manage.py runserver' it says "Error: no module named app3" if app3 is the 
>> last in the list of installed apps (see below), but if I swap app2 and app3 
>> it claims app2 (now the last one in the list) is missing.  The error 
>> message seems to be lying to me, and I don't know where to look for the 
>> error.  In the settings.py file I have
>>
>> INSTALLED_APPS = (
>> 'django.contrib.auth',
>> 'django.contrib.contenttypes',
>> 'django.contrib.sessions',
>> 'django.contrib.sites',
>> 'django.contrib.messages',
>> 'django.contrib.staticfiles',
>> # Uncomment the next line to enable the admin:
>> 'django.contrib.admin',
>> # Uncomment the next line to enable admin documentation:
>> 'django.contrib.admindocs',
>> 'django.django-adminfiles',
>> 'proj.app1',
>> 'proj.app2',
>> 'proj.app3',
>> )
>>
>> I've looked around for anything on "Error: No module named xxx", but 
>> haven't found any that seem to relate to this behavior.  Has anyone seen 
>> this kind of error dependent on the order of the apps?  Is there any way I 
>> can force a more informative error?  I tried adding an empty module name at 
>> the end, and it gave me an error trace, but I couldn't figure out anything 
>> from  it.  My directory tree looks like this:
>>
>> proj/
>> manage.py
>> proj/proj/
>> __init__.py
>> settings.py
>> urls.py
>> wsgi.py
>> proj/app1/
>> __init__.py
>> forms.py
>> models.py
>> tests.py
>> views.py
>> proj/app2/
>> __init__.py
>> forms.py
>> models.py
>> tests.py
>> views.py
>> proj/app3/
>> __init__.py
>> forms.py
>> models.py
>> tests.py
>> views.py
>> proj/templates/
>> . . .
>>
>> Django 1.4 seems to have a second proj directory under the first level 
>> proj directory.  I didn't see this in 1.3.
>>
>>

-- 
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/-/pgyDVWZFwdoJ.
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: runserver error: "No module named app3"

2012-08-22 Thread Bill Beal
Thanks, Melvin!  That did it.  On to the next error!


On Wednesday, August 22, 2012 5:16:15 PM UTC-4, Bill Beal wrote:
>
> Hi all,
>
> I have a Django project with apps that works OK on a Mac with Django 1.3 
> and Python 2.6, and I'm trying to move it to a Linux box with Django 1.4 
> and Python 2.7.  I created an empty project 'proj' with apps 'app1', 
> 'app2', 'app3' on the Linux system and carefully merged settings.py, 
> urls.py etc. with the initial files that were created.  When I run 'python 
> manage.py runserver' it says "Error: no module named app3" if app3 is the 
> last in the list of installed apps (see below), but if I swap app2 and app3 
> it claims app2 (now the last one in the list) is missing.  The error 
> message seems to be lying to me, and I don't know where to look for the 
> error.  In the settings.py file I have
>
> INSTALLED_APPS = (
> 'django.contrib.auth',
> 'django.contrib.contenttypes',
> 'django.contrib.sessions',
> 'django.contrib.sites',
> 'django.contrib.messages',
> 'django.contrib.staticfiles',
> # Uncomment the next line to enable the admin:
> 'django.contrib.admin',
> # Uncomment the next line to enable admin documentation:
> 'django.contrib.admindocs',
> 'django.django-adminfiles',
> 'proj.app1',
> 'proj.app2',
> 'proj.app3',
> )
>
> I've looked around for anything on "Error: No module named xxx", but 
> haven't found any that seem to relate to this behavior.  Has anyone seen 
> this kind of error dependent on the order of the apps?  Is there any way I 
> can force a more informative error?  I tried adding an empty module name at 
> the end, and it gave me an error trace, but I couldn't figure out anything 
> from  it.  My directory tree looks like this:
>
> proj/
> manage.py
> proj/proj/
> __init__.py
> settings.py
> urls.py
> wsgi.py
> proj/app1/
> __init__.py
> forms.py
> models.py
> tests.py
> views.py
> proj/app2/
> __init__.py
> forms.py
> models.py
> tests.py
> views.py
> proj/app3/
> __init__.py
> forms.py
> models.py
> tests.py
> views.py
> proj/templates/
> . . .
>
> Django 1.4 seems to have a second proj directory under the first level 
> proj directory.  I didn't see this in 1.3.
>
>

-- 
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/-/w_BcEvMcbCwJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: django.db.utils.DatabaseError when resyncing django app models

2012-08-22 Thread Mhlanga Bothin

On 23/08/2012, at 10:59 AM, Melvyn Sopacua wrote:

> On 23-8-2012 2:37, Mhlanga Bothin wrote:
> 
>> Thanks a lot for your help. I am not adding any classes to the app on
>> the second sync, correct me if I am wrong but django only resyncs new
>> classes?
> 
> Yes and no. The permissions are a special case, they are also updated if
> you add permissions to a model's Meta class. Is there any difference at
> all between the first and second sync? Or can you reproduce this with an
> entirely empty database and just run syncdb twice in a row?
> 
> -- 
> Melvyn Sopacua


Thanks. There is no difference between the first sync and the second sync.

Procedure:

Drop data base
Create new data base
syncdb
syncdb: Error

:(

Is there any other debug output that I can look through?

Cheers

-- 
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: Layout and global.css files

2012-08-22 Thread Gregory Strydom


Thanks very much for the replies, this really helps alot!

-- 
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/-/W33sPdspM00J.
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: Layout and global.css files

2012-08-22 Thread Mike Dewhirst

On 23/08/2012 11:41am, Gregory Strydom wrote:

Could anyone perhaps tell me where i could find the layout.css and
global.css for the base admin site?

Ive tried looking through C:/Python26/site-packages/django but cant seem
to find anything. What i am trying to do is just change colour where it
say Users, Groups, Sites etc in the django admin. I managed to change
the header colors so far but was told i need to edit layout and
global.css to change the other colors.


I have solved this in a cack-handed way and would like to learn how to 
do it correctly.


I had trouble getting my own css files to work in the admin overriding 
the contrib.admin styles because the admin base.css kept being used 
instead of mine when I used the extrastyle block. Here is my 
base_site.html template ...


{% extends "admin/base.html" %}
{% load i18n %}
{% block title %}{{ title }} | {% trans 'X' %}{% endblock %}
{% block extrastyle %}{% endblock %}
{% block userstyle %}href="/static/css/darker.css" />{% endblock %}

{% block branding %}
{% trans 'X Administration' %}
{% endblock %}
{% block nav-global %}{% endblock %}
{% block extrahead %}{% endblock %}

You can see the "foreign" userstyle block there. That is where I had to 
put my css to get it used in the right cascade sequence over the top of 
the real thing. I think the extrastyle block is for extra styles rather 
than replacement styles.


I wrote a script to patch the admin base.html to insert that userstyle 
block and that works. But adjusting the admin base.html is not nice. 
Hence I would like to discover how it should be done.


Here is my patch_admin_base.py script ...

"""
patch django-admin base.html to include a userstyle block
"""

project = "x"
srvroot = "/srv/www"
vws_root = "%s/%s" % (srvroot, project)
app_root = "%s/%s" % (vws_root, project)

import os
import sys

if app_root not in sys.path:
sys.path.insert(0, app_root)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "%s.settings" % project)

from django.contrib import admin

flag = '{% block extrastyle %}{% endblock %}'
patch1 = '{# userstyle inserted by md #}\n'
patch2 = '{% block userstyle %}{% endblock %}\n'
base_template = 'templates/admin/base.html'
done = False
pth = 
os.path.split(str(admin).split()[-1].split("'")[-2].replace("\\","/"))[0]

template = '%s/%s' % (pth, base_template)
if os.path.isfile(template):
lines = list()
with open(template, "r") as base:
lines = base.readlines()
done = patch2 in lines
if not done:
with open(template, "w") as base:
for line in lines:
base.write(line)
if flag in line:
base.write(patch1)
base.write(patch2)
done = True
if done:
print('\n%s patched' % template)
else:
print('\n%s not patched' % template)
else:
print('\n%s already patched' % template)
else:
print('\nbase.html not found')




Thanks very much for any help with this!

--
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/-/N9aDIJzmHngJ.
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: Layout and global.css files

2012-08-22 Thread Melvyn Sopacua
On 23-8-2012 3:41, Gregory Strydom wrote:
> Could anyone perhaps tell me where i could find the layout.css and 
> global.css for the base admin site?
> 
> Ive tried looking through C:/Python26/site-packages/django but cant seem to 
> find anything.

You shouldn't edit anything there - it will be lost when you upgrade.
The base procedure is described here:


For the css and js bits, read these top to bottom:



The short version is to copy the files to the appropriate location
whether it be the TEMPLATE_DIRS or STATIC_ROOT and edit those files. The
long version is that you should thoroughly understand how static files
work - it's a recurring issue on the list and it's one of those things
that has to sink in and then you get it. If you don't get it, then lots
of time and energy is wasted on "trying if this works".

-- 
Melvyn Sopacua

-- 
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: Layout and global.css files

2012-08-22 Thread Jeff Tchang
I see some stuff under:

/python/lib/python2.6/site-packages/django/contrib/admin/static/admin/css


On Wed, Aug 22, 2012 at 6:41 PM, Gregory Strydom <
gregory.strydom...@gmail.com> wrote:

> Could anyone perhaps tell me where i could find the layout.css and
> global.css for the base admin site?
>
> Ive tried looking through C:/Python26/site-packages/django but cant seem
> to find anything. What i am trying to do is just change colour where it say
> Users, Groups, Sites etc in the django admin. I managed to change the
> header colors so far but was told i need to edit layout and global.css to
> change the other colors.
>
> Thanks very much for any help with this!
>
> --
> 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/-/N9aDIJzmHngJ.
> 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.



Layout and global.css files

2012-08-22 Thread Gregory Strydom
Could anyone perhaps tell me where i could find the layout.css and 
global.css for the base admin site?

Ive tried looking through C:/Python26/site-packages/django but cant seem to 
find anything. What i am trying to do is just change colour where it say 
Users, Groups, Sites etc in the django admin. I managed to change the 
header colors so far but was told i need to edit layout and global.css to 
change the other colors.

Thanks very much for any help with this!

-- 
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/-/N9aDIJzmHngJ.
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: custom field for callable python object like class or function

2012-08-22 Thread Melvyn Sopacua
On 23-8-2012 0:37, Michael Palumbo wrote:
> ok thanks, so you'd rather do it with a Model than a custom field.
> I actually started to make a custom field but I had a few issues while 
> displaying it in the admin so that's why I asked the question then.

You can pickle an object and store the result in a blob-type field or
encode it and put it in a TextArea field:

It's basically what the session module is doing. Perhaps look there for
inspiration:


-- 
Melvyn Sopacua

-- 
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: runserver error: "No module named app3"

2012-08-22 Thread Melvyn Sopacua
Hi Bill,

On 22-8-2012 23:16, Bill Beal wrote:

Look at it like this to spot your error:


> 'proj.app3',

> proj/
 cwd of the WSGI app

> proj/proj/
>settings.py
 DJANGO_SETTINGS_MODULE = 'proj.settings'

> proj/app3/

So this module is not proj.app3 but app3.
I'm reasonably sure that the error is only reported on the last entry
because the verification is done in reverse order, but you'll have to
look that up in the source. In either case, "the last of the installed
apps" is a red herring.
-- 
Melvyn Sopacua

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



Re: django.db.utils.DatabaseError when resyncing django app models

2012-08-22 Thread Melvyn Sopacua
On 23-8-2012 2:37, Mhlanga Bothin wrote:

> Thanks a lot for your help. I am not adding any classes to the app on
> the second sync, correct me if I am wrong but django only resyncs new
> classes?

Yes and no. The permissions are a special case, they are also updated if
you add permissions to a model's Meta class. Is there any difference at
all between the first and second sync? Or can you reproduce this with an
entirely empty database and just run syncdb twice in a row?

-- 
Melvyn Sopacua

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



Re: django.db.utils.DatabaseError when resyncing django app models

2012-08-22 Thread Mhlanga Bothin
On 22/08/2012, at 1:51 PM, Karen Tracey wrote:

> The key part of the traceback is this:
> 
>   File 
> "/usr/local/lib/python2.7/site-packages/django/core/management/sql.py", line 
> 189, in emit_post_sync_signal
> interactive=interactive, db=db)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/dispatch/dispatcher.py", line 
> 172, in send
> response = receiver(signal=self, sender=sender, **named)
>   File 
> "/usr/local/lib/python2.7/site-packages/django/contrib/auth/management/__init__.py",
>  line 54, in create_permissions
> auth_app.Permission.objects.bulk_create(objs)
> 
> which indicates the problem is related to the creation of permissions for 
> your models (I can't explain why you are seeing this on a 2nd syncdb unless 
> you are actually adding models, though I don't see any tables created in your 
> output so that is a bit confusing). You are hitting this ticket:
> 
> https://code.djangoproject.com/ticket/17763
> 
> Solution at this point in time is either to shorten names in your models or 
> manually increase the length of the too-small field(s) in the auth_permission 
> table.
> 
> Karen
> 


Hi Karen,

Thanks a lot for your help. I am not adding any classes to the app on the 
second sync, correct me if I am wrong but django only resyncs new classes? I 
find it very odd that the error occurs only with the second resync... I will 
try your suggestions and let you know how I go, Thanks a lot!

Cheers


-- 
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: Caching Options

2012-08-22 Thread Phang Mulianto
Hi i also use johhny cache, why it not hit your cache? Johny cache will
cache your queryset and update it when the database table for the queryset
updated.

I only cache the queryset without add code in the views,  johny cache
handle the rest
Pada 23 Agu 2012 06.46, "James"  menulis:

> Right now, I'm loading up some data VIA the orm. The nature of the data is
> fairly complex, somewhere around 10-12 tables are touched per insert and
> about twice that number referencing static helper tables.
>
> For production and day to day use, I've been using django-cache-machine,
> but I've also been considering Johnny-caching.
>
> For this problem though, johnny won't work because the cache would
> effectively never get hit.
>
> As far as Django-Cache-Machine, I don't think it's caching .get type
> queries. I believe it only caches querysets, and then only when you
> actually iterate over them.
>
> Considering most of my references are .get type queries for this
> operation, I would think that caching those type of queries would be useful
> for me during this process.
>
> Now, I won't have to go through this that often, maybe once ever four
> months, but still I think caching some of the queries up front could speed
> this up.
>
> What are peoples thoughts on this?
>
> --
> 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/-/pvdY4dz4LdgJ.
> 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: SyntaxError Creating New Project

2012-08-22 Thread Karen Tracey
On Wed, Aug 22, 2012 at 5:00 PM, Bestrafung  wrote:

> I'm new to Django and though I've dabbled with Linux off and on for a
> decade I'm still learning so please go easy on me. I'm following this
> guideto
>  setup a Django 1.4.1 test project. So far I've setup Python 2.5 with
> MySQL-python-1.2.3 and setuptools, setup mod_wsgi, and edited
> .bash_profile. I've downloaded Django 1.4.1 (not trunk) and so far
> everything looks good. As soon as I run "django-admin.py startproject
> testproject" I receive an error and am having trouble resolving it. I
> apologize if this has come up before bet a quick search wasn't helpful.
> Thanks in advance for any assistance, the error is below:
>
> [-bash-3.2 root@server1: /home/username/sites/domain.com] #
> /home/username/sites/domain.com/django/bin/django-admin.py startproject
> testproject
> Traceback (most recent call last):
>   File "/home/username/sites/domain.com/django/bin/django-admin.py", line
> 2, in ?
> from django.core import management
>   File "/home/username/sites/domain.com/django/__init__.py", line 15
> parts = 2 if version[2] == 0 else 3
>^
> SyntaxError: invalid syntax
> [-bash-3.2 root@server1: /home/username/sites/domain.com] #
>
> That error indicates the python executable processing django-admin.py is
Python 2.4 level, not 2.5. With Python 2.5 I can import django at level
1.4.1:

kmt@lbox 20:04:15: ~/software/web
--> python
Python 2.5.2 (r252:60911, Jan 20 2010, 23:16:55)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> quit()

If I try with Python 2.4 level, I get the error you are seeing:

kmt@lbox 20:04:45: ~/software/web
--> python2.4
Python 2.4.5 (#2, Jan 21 2010, 19:44:35)
[GCC 4.3.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
Traceback (most recent call last):
  File "", line 1, in ?
  File "/home/kmt/django/Django-1.4.1/django/__init__.py", line 15
parts = 2 if version[2] == 0 else 3
   ^
SyntaxError: invalid syntax
>>>

You may have python 2.5 installed, but you seem to have 2.4 also, and 2.4
is what's getting used for the command you are running.

Karen
-- 
http://tracey.org/kmt/

-- 
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: SyntaxError Creating New Project

2012-08-22 Thread Alexis Roda

Al 22/08/12 23:00, En/na Bestrafung ha escrit:

I'm new to Django and though I've dabbled with Linux off and on for a
decade I'm still learning so please go easy on me. I'm following this
guide

to setup a Django 1.4.1 test project. So far I've setup Python 2.5 with
MySQL-python-1.2.3 and setuptools, setup mod_wsgi, and edited
.bash_profile. I've downloaded Django 1.4.1 (not trunk) and so far
everything looks good. As soon as I run "django-admin.py startproject
testproject" I receive an error and am having trouble resolving it. I
apologize if this has come up before bet a quick search wasn't helpful.
Thanks in advance for any assistance, the error is below:

[-bash-3.2 root@server1: /home/username/sites/domain.com] #
/home/username/sites/domain.com/django/bin/django-admin.py
startproject testproject
Traceback (most recent call last):
File "/home/username/sites/domain.com/django/bin/django-admin.py",
line 2, in ?
from django.core import management
File "/home/username/sites/domain.com/django/__init__.py", line 15
parts = 2 if version[2] == 0 else 3
^
SyntaxError: invalid syntax
[-bash-3.2 root@server1: /home/username/sites/domain.com] #


The "var = value if predicate else value" syntax was introduce in python 
2.5, so it seems like the python interpreter that's being used to run 
django-admin.py is older.


Try executing python and look at the version number. Check the shebang 
in the 'django-admin.py' too.


As a workaround execute:

/path/to/python2.5 /path/to/django-admin.py startproject testproject



HTH

--
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: Can somebody help me on how to handle this scenario?

2012-08-22 Thread Melvyn Sopacua
Hi Nirmal,

I'll try to answer your question instead of assuming you're working with
django's auth system.

On 22-8-2012 7:13, Nirmal Sharma wrote:

> class People (models.Model):
> person_name  = models.CharField(max_length=150)
> 
> 
> class comments (models.Model):
> comment  = models.CharField(max_length=1000)   
> root_comment =  models.ForeignKey('self', null=True, blank=True, 
> related_name="children")
> People_id = models.ForeignKey(People)
^^^
That's bad practice, because you're not designing a database, you're
designing a model that is built from things, not id's. So name this
field person or commentator or written_by:
written_by = models.ForeignKey(People)

Same applies on numerous fields below. The reason it's bad practice is
because when you request an attribute the name of the attribute should
describe what you get. When you request comments.people_id the
expectation is that you get an id, while in actuality you get a model
instance.

> class comment_feedback (models.Model):
> feedback_People_id = models.ForeignKey(People)
> comment_id =   models.ForeignKey(comments)
> feedback_type_id =  models.CharField(max_length=20, 
> choices=FEEDBACK_CHOICES)
> class Meta:
> unique_together = [("feedback_People_id", "info_id")]
>
> We are trying build a html page that will do the following.
> Once a user logs in, he can write a new comment (that would result in an 
> insert into comments table)
> Alternatively he can do one of the following:
> select a comment of some other peoples and give his feedback (that 
> would result in an insert into comment_feedback table)
> select a comment and write his own comment with a feedback on the 
> original comment (that would result in an insert into comments table with 
> root_comment as the original comment and an insert into comment_feedback 
> table for the original comment)

Here's how to dissect your problem description:
- The person can do three things ("actions") that he cannot do at the
same time: the obvious solution is to use three different forms in the
same HTML page or use popup windows for action 2 and 3.
- The second and third option are mostly a UI problem, because how does
the user select the comment she's providing feedback for. Unless you put
a form below each comment (which will make the page possibly incredibly
long), you need to do some JavaScript programming that shows the form
below the right comment and stores the comment being commented on in
some hidden variables in that form. This is where I would hire a UI
programmer.

> We tried doing this inlineformset_factory and nested formsets. However we 
> are quite confused on how to proceed with this. Also the comment_feedback 
> table has 2 foreign keys.
That isn't a problem as long as the foreign keys are to different
tables. inlineformset_factory will find the foreign key that goes from
parent_model to model in it's function signature. It uses
_get_foreign_key() in forms/models.py for that.

> How do we handle this at the form and template level? 

Like I said, the selection process is mostly a UI nightmare. If you
solve that, creating the forms for it will be much easier to grasp.
-- 
Melvyn Sopacua

-- 
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: GeometryField in OSMGeoAdmin

2012-08-22 Thread Melvyn Sopacua
On 22-8-2012 10:31, geonition wrote:

> I have a problem with GeometryField not showing the saved geometry in the 
> admin interface. The problem is that the GeometryField has a type of 
> 'GEOMETRY' when the value saved might have the type of e.g. 'POINT'.

The GeometryField is like the normal Field class: the base class for
actual fields you should be using in your model, like PointField. The
docs are not very clear on this issue.
-- 
Melvyn Sopacua

-- 
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: What is the easy way to install DJango?

2012-08-22 Thread Demian Brecht
> Or installing the M$ VC++ Express edition compatible with the
> version used for the Python build 
> --
> Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
>
>
Sure (or MinGW if I'm not mistaken) but the question was asking about an
"easy" way. I'm not sure that setting up a full build environment on a
Windows machine would qualify it to be such. Of course, that's entirely
subjective and not really related to the question at hand ;)

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



Caching Options

2012-08-22 Thread James
Right now, I'm loading up some data VIA the orm. The nature of the data is 
fairly complex, somewhere around 10-12 tables are touched per insert and 
about twice that number referencing static helper tables.

For production and day to day use, I've been using django-cache-machine, 
but I've also been considering Johnny-caching.

For this problem though, johnny won't work because the cache would 
effectively never get hit.

As far as Django-Cache-Machine, I don't think it's caching .get type 
queries. I believe it only caches querysets, and then only when you 
actually iterate over them.

Considering most of my references are .get type queries for this operation, 
I would think that caching those type of queries would be useful for me 
during this process.

Now, I won't have to go through this that often, maybe once ever four 
months, but still I think caching some of the queries up front could speed 
this up.

What are peoples thoughts on this?

-- 
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/-/pvdY4dz4LdgJ.
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: custom field for callable python object like class or function

2012-08-22 Thread Michael Palumbo
ok thanks, so you'd rather do it with a Model than a custom field.
I actually started to make a custom field but I had a few issues while 
displaying it in the admin so that's why I asked the question then.


Le jeudi 23 août 2012 00:16:48 UTC+2, Kurtis a écrit :
>
> Whoops,
>
> foo = property(get_reference, set_reference)
>
> should be
>
> reference = property(get_reference, set_reference)
>
> Sorry, was reading another page to make sure I have the property code 
> right:
>
> http://stackoverflow.com/questions/1454727/do-properties-work-on-django-model-fields
>
> On Wed, Aug 22, 2012 at 6:15 PM, Kurtis Mullins 
> 
> > wrote:
>
>> It looks like you want to, basically, store a reference to a Python 
>> object in your Model. It shouldn't be too extremely difficult. I'd create a 
>> Model for this purpose though and just use extra methods to provide any 
>> functionality you need. Just as a quick prototypical example:
>>
>> class ReferenceModel(Model):
>> _reference = models.CharField(max_length=150)
>>
>> def get_reference(self):
>> """
>> Load the string from self._reference and use some sort of a 
>> process
>> to dynamically load the object.
>> e.g. 
>> http://stackoverflow.com/questions/547829/how-to-dynamically-load-a-python-class
>> """
>>
>> def set_reference(self, input):
>> self._reference = input
>>
>> foo = property(get_reference, set_reference)
>>
>> Anyways, just a guess at one of many ways to possibly accomplish this 
>> task.
>> 
>>
>> On Wed, Aug 22, 2012 at 5:58 PM, Michael Palumbo 
>> 
>> > wrote:
>>
>>> Hi,
>>>
>>> Do you know a custom field for a callable python object like a Class or 
>>> a function ?
>>>
>>> It could store it as a string in the DB: "module1.module2.class"  or   
>>> "module1.module2.function"
>>> With that string, it could load it as a real python object when you get 
>>> it from the DB.
>>>
>>> For example, you could do something like that:
>>>
>>> from module1.module2 import testme
>>> mymodel.process = testme
>>> mymodel.save() => stores the string "module1.module2.testme"
>>>
>>> # Later...
>>> ins = mymodel.objects.get(..)
>>> ins.process('OK') # ins.process can be called because it has been 
>>> resolved to the testme function
>>>
>>> Thanks.
>>>
>>>  -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/sHDfKCKGBmEJ.
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/OK6b72Lrr9gJ.
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: HttpResponseNotModified returning 200 code

2012-08-22 Thread Kevin Anthony
wow, that's embarrassing.  thanks.

On Wed, Aug 22, 2012 at 4:16 PM, Alexis Roda <
alexis.roda.villalo...@gmail.com> wrote:

> Al 22/08/12 21:36, En/na Kevin Anthony ha escrit:
>
>> Here is my code:
>>
>> id = get_id(request)
>>   if id is not None:
>>   host = request.GET['host']
>>   if host!=None:
>>   command =
>> command_queue.objects.all().**filter(destination_hostname=**
>> host,user__id=id)
>>   if not command.count():
>>   HttpResponseNotModified()
>>   retval =
>> JSONResponse(command.values('**command','command_text'),**
>> Extra={"success":True})
>>   command.delete()
>>   return retval
>>  return HttpResponseForbidden()
>>
>> I know it's getting to the HttpResponseNotModified, but I'm still
>> getting a HTTP status code of 200.
>>
>> Can someone point me in the correct direction?
>>
>
> return HttpResponseNotModified()
>
>
>
> HTH
>
> --
> 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+unsubscribe@**
> googlegroups.com .
> For more options, visit this group at http://groups.google.com/**
> group/django-users?hl=en
> .
>
>


-- 
Thanks
Kevin Anthony
www.NoSideRacing.com

Do you use Banshee?
Download the Community Extensions:
http://banshee.fm/download/extensions/

-- 
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: SyntaxError Creating New Project

2012-08-22 Thread Kurtis Mullins
Very weird. I ran the syntax and did not receive a syntax error. I just
checked on the documentation and it does say Python 2.5 is required, which
as you mentioned you have installed.

Maybe double-check to make sure that you're executing this with the right
Python executable? I'm running Python 2.7 if it makes a difference.

Here's a reference to the file that's giving you the error:
https://github.com/django/django/blob/1.4.1/django/__init__.py

On Wed, Aug 22, 2012 at 5:00 PM, Bestrafung  wrote:

> I'm new to Django and though I've dabbled with Linux off and on for a
> decade I'm still learning so please go easy on me. I'm following this
> guideto
>  setup a Django 1.4.1 test project. So far I've setup Python 2.5 with
> MySQL-python-1.2.3 and setuptools, setup mod_wsgi, and edited
> .bash_profile. I've downloaded Django 1.4.1 (not trunk) and so far
> everything looks good. As soon as I run "django-admin.py startproject
> testproject" I receive an error and am having trouble resolving it. I
> apologize if this has come up before bet a quick search wasn't helpful.
> Thanks in advance for any assistance, the error is below:
>
> [-bash-3.2 root@server1: /home/username/sites/domain.com] #
> /home/username/sites/domain.com/django/bin/django-admin.py startproject
> testproject
> Traceback (most recent call last):
>   File "/home/username/sites/domain.com/django/bin/django-admin.py", line
> 2, in ?
> from django.core import management
>   File "/home/username/sites/domain.com/django/__init__.py", line 15
> parts = 2 if version[2] == 0 else 3
>^
> SyntaxError: invalid syntax
> [-bash-3.2 root@server1: /home/username/sites/domain.com] #
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/WszNLKVNcxcJ.
> 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: custom field for callable python object like class or function

2012-08-22 Thread Kurtis Mullins
Whoops,

foo = property(get_reference, set_reference)

should be

reference = property(get_reference, set_reference)

Sorry, was reading another page to make sure I have the property code right:
http://stackoverflow.com/questions/1454727/do-properties-work-on-django-model-fields

On Wed, Aug 22, 2012 at 6:15 PM, Kurtis Mullins wrote:

> It looks like you want to, basically, store a reference to a Python object
> in your Model. It shouldn't be too extremely difficult. I'd create a Model
> for this purpose though and just use extra methods to provide any
> functionality you need. Just as a quick prototypical example:
>
> class ReferenceModel(Model):
> _reference = models.CharField(max_length=150)
>
> def get_reference(self):
> """
> Load the string from self._reference and use some sort of a process
> to dynamically load the object.
> e.g.
> http://stackoverflow.com/questions/547829/how-to-dynamically-load-a-python-class
> """
>
> def set_reference(self, input):
> self._reference = input
>
> foo = property(get_reference, set_reference)
>
> Anyways, just a guess at one of many ways to possibly accomplish this task.
>
>
> On Wed, Aug 22, 2012 at 5:58 PM, Michael Palumbo <
> michael.palumb...@gmail.com> wrote:
>
>> Hi,
>>
>> Do you know a custom field for a callable python object like a Class or a
>> function ?
>>
>> It could store it as a string in the DB: "module1.module2.class"  or
>> "module1.module2.function"
>> With that string, it could load it as a real python object when you get
>> it from the DB.
>>
>> For example, you could do something like that:
>>
>> from module1.module2 import testme
>> mymodel.process = testme
>> mymodel.save() => stores the string "module1.module2.testme"
>>
>> # Later...
>> ins = mymodel.objects.get(..)
>> ins.process('OK') # ins.process can be called because it has been
>> resolved to the testme function
>>
>> Thanks.
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/sHDfKCKGBmEJ.
>> 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: custom field for callable python object like class or function

2012-08-22 Thread Kurtis Mullins
It looks like you want to, basically, store a reference to a Python object
in your Model. It shouldn't be too extremely difficult. I'd create a Model
for this purpose though and just use extra methods to provide any
functionality you need. Just as a quick prototypical example:

class ReferenceModel(Model):
_reference = models.CharField(max_length=150)

def get_reference(self):
"""
Load the string from self._reference and use some sort of a process
to dynamically load the object.
e.g.
http://stackoverflow.com/questions/547829/how-to-dynamically-load-a-python-class
"""

def set_reference(self, input):
self._reference = input

foo = property(get_reference, set_reference)

Anyways, just a guess at one of many ways to possibly accomplish this task.


On Wed, Aug 22, 2012 at 5:58 PM, Michael Palumbo <
michael.palumb...@gmail.com> wrote:

> Hi,
>
> Do you know a custom field for a callable python object like a Class or a
> function ?
>
> It could store it as a string in the DB: "module1.module2.class"  or
> "module1.module2.function"
> With that string, it could load it as a real python object when you get it
> from the DB.
>
> For example, you could do something like that:
>
> from module1.module2 import testme
> mymodel.process = testme
> mymodel.save() => stores the string "module1.module2.testme"
>
> # Later...
> ins = mymodel.objects.get(..)
> ins.process('OK') # ins.process can be called because it has been resolved
> to the testme function
>
> Thanks.
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/sHDfKCKGBmEJ.
> 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.



custom field for callable python object like class or function

2012-08-22 Thread Michael Palumbo
Hi,

Do you know a custom field for a callable python object like a Class or a 
function ?

It could store it as a string in the DB: "module1.module2.class"  or   
"module1.module2.function"
With that string, it could load it as a real python object when you get it 
from the DB.

For example, you could do something like that:

from module1.module2 import testme
mymodel.process = testme
mymodel.save() => stores the string "module1.module2.testme"

# Later...
ins = mymodel.objects.get(..)
ins.process('OK') # ins.process can be called because it has been resolved 
to the testme function

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/sHDfKCKGBmEJ.
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: I can't start new project

2012-08-22 Thread rafi r
thanks so much this helped me tons!!!
On Tuesday, December 27, 2011 9:27:06 AM UTC-5, Andre Terra (airstrike) wrote:
> My bet is that you're using Windows.
> 
> Open the Registry Editor (hit Winkey+R, "regedit" (no quotes), hit enter)
> 
> ---
> 
> Go to HKEY_CLASSES_ROOT\Applications\python.exe\shell\open\command
> 
> 
> and check that it looks somewhat like '"PYDIR\\python.exe" "%1" %*'
>  
> If you're missing the final  %*, it won't work.
> 
> 
> 
> ---
> 
> A different, one-time solution is to type the full paths in your command-line:
> 
> 
> 
> 
> C:\Python27\python.exe
> C:\path\to\django-admin.py startproject foobar
> 
> 
> 
> Also google for virtualenv and start using it!
> 
> 
> Cheers,
> AT
> 
> 
> 
> On Tue, Dec 27, 2011 at 12:01 PM, Varrant  wrote:
> 
> 
> Hello,
> 
> 
> 
> I have installed python 2.7 and Django 1.3.1, but when I type:
> 
> 
> 
> "django-admin.py startproject project"
> 
> 
> 
> I receive only something like 'help' for that command
> 
> 
> 
> How can i fix it?
> 
> 
> 
> I already tried reinstalling Python and Django...
> 
> 
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> 
> To post to this group, send email to django...@googlegroups.com.
> 
> To unsubscribe from this group, send email to 
> django-users...@googlegroups.com.
> 
> For more options, visit this group at 
> http://groups.google.com/group/django-users?hl=en.

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



SyntaxError Creating New Project

2012-08-22 Thread Bestrafung
I'm new to Django and though I've dabbled with Linux off and on for a 
decade I'm still learning so please go easy on me. I'm following this 
guideto
 setup a Django 1.4.1 test project. So far I've setup Python 2.5 with 
MySQL-python-1.2.3 and setuptools, setup mod_wsgi, and edited 
.bash_profile. I've downloaded Django 1.4.1 (not trunk) and so far 
everything looks good. As soon as I run "django-admin.py startproject 
testproject" I receive an error and am having trouble resolving it. I 
apologize if this has come up before bet a quick search wasn't helpful. 
Thanks in advance for any assistance, the error is below:

[-bash-3.2 root@server1: /home/username/sites/domain.com] # 
/home/username/sites/domain.com/django/bin/django-admin.py startproject 
testproject
Traceback (most recent call last):
  File "/home/username/sites/domain.com/django/bin/django-admin.py", line 
2, in ?
from django.core import management
  File "/home/username/sites/domain.com/django/__init__.py", line 15
parts = 2 if version[2] == 0 else 3
   ^
SyntaxError: invalid syntax
[-bash-3.2 root@server1: /home/username/sites/domain.com] #


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/WszNLKVNcxcJ.
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.



runserver error: "No module named app3"

2012-08-22 Thread Bill Beal
Hi all,

I have a Django project with apps that works OK on a Mac with Django 1.3 
and Python 2.6, and I'm trying to move it to a Linux box with Django 1.4 
and Python 2.7.  I created an empty project 'proj' with apps 'app1', 
'app2', 'app3' on the Linux system and carefully merged settings.py, 
urls.py etc. with the initial files that were created.  When I run 'python 
manage.py runserver' it says "Error: no module named app3" if app3 is the 
last in the list of installed apps (see below), but if I swap app2 and app3 
it claims app2 (now the last one in the list) is missing.  The error 
message seems to be lying to me, and I don't know where to look for the 
error.  In the settings.py file I have

INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'django.django-adminfiles',
'proj.app1',
'proj.app2',
'proj.app3',
)

I've looked around for anything on "Error: No module named xxx", but 
haven't found any that seem to relate to this behavior.  Has anyone seen 
this kind of error dependent on the order of the apps?  Is there any way I 
can force a more informative error?  I tried adding an empty module name at 
the end, and it gave me an error trace, but I couldn't figure out anything 
from  it.  My directory tree looks like this:

proj/
manage.py
proj/proj/
__init__.py
settings.py
urls.py
wsgi.py
proj/app1/
__init__.py
forms.py
models.py
tests.py
views.py
proj/app2/
__init__.py
forms.py
models.py
tests.py
views.py
proj/app3/
__init__.py
forms.py
models.py
tests.py
views.py
proj/templates/
. . .

Django 1.4 seems to have a second proj directory under the first level proj 
directory.  I didn't see this in 1.3.

-- 
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/-/xrnaaTiYFOEJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How to use Django with Apache and mod_wsgi

2012-08-22 Thread Seyfullah Tıkıç
Then do I have to delete 00_default_vhost.conf file?
What name can I give to this new created file?

2012/8/20 Joseph Mutumi 

> You would be good to organize your configuration. Try creating a file
> under /etc/apache2/vhosts.d/
> Probably my_domain.com (substitute my_domain.com with your actual domain).
>
> And move all the configuration to it:
> 
> ServerAdmin webmaster@my_domain.com
> DocumentRoot /usr/local/django/mysite/media/
> ServerName my_domain.com
> ServerAlias www.my_domain.com
>
> #WSGIDaemonProcess site-1 user=user-1 group=user-1 threads=25
> #WSGIProcessGroup site-1
>
> Alias /media/ /usr/local/django/mysite/media/
>
> 
> Order deny,allow
> Allow from all
> 
>
> WSGIScriptAlias / /home/seyfullah/django/mysite/apache/django.wsgi
>
> 
> Order deny,allow
> Allow from all
> 
>
> 
>
> You can remove the comments after you are sure its working
>
> Regards
>
>
> On Mon, Aug 20, 2012 at 2:39 PM, Joris  wrote:
>
>> The DocumentRoot directive is missing from the httpd.conf, indicating you
>> did not send all the required data. This may be because your attachment is
>> incomplete:
>>
>> There is an include statement in your httpd.conf: "Include
>> /etc/apache2/conf.d/*.conf"
>> All files from that conf.d folder are also processed. Please look in
>> files located in  /etc/apache2/conf.d/ for anything useful. Especially
>> files that contain a documentroot directive
>>
>> Also, it may help if you post the output of
>> apachectl -S
>> (note: some distros want apache2ctl instead of apachectl)
>>
>> jb
>>
>>
>>
>> On Monday, August 20, 2012 11:30:49 AM UTC+2, stikic wrote:
>>
>>> httpd.conf file is in the attachment.
>>>
>>> 2012/8/20, Joseph Mutumi :
>>> > Hello,
>>> >
>>> > Could you post the VirtualHost configuration for Apache?
>>> > That would greatly help us help you.
>>> >
>>> > Regards
>>> >
>>> > On Mon, Aug 20, 2012 at 12:30 AM, Seyfullah Tıkıç 
>>> wrote:
>>> >
>>> >> Hello,
>>> >>
>>> >> I read the article below.
>>> >> https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
>>> >>
>>> >> But still http://localhost redirects to
>>> >> /var/www/localhost/htdocs/index.html.
>>> >> I want http://localhost/ redirescts to
>>> /home/seyfullah/django/mysite.
>>> >> How can I do this?
>>> >>
>>> >> --
>>> >> SEYFULLAH TIKIÇ
>>> >>
>>> >> --
>>> >> You received this message because you are subscribed to the Google
>>> Groups
>>> >> "Django users" group.
>>> >> To post to this group, send email to django...@googlegroups.com.
>>> >> To unsubscribe from this group, send email to
>>> >> django-users...@googlegroups.com.
>>> >> For more options, visit this group at
>>> >> http://groups.google.com/group/django-users?hl=en.
>>> >>
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> Groups
>>> > "Django users" group.
>>> > To post to this group, send email to django...@googlegroups.com.
>>> > To unsubscribe from this group, send email to
>>> > django-users...@googlegroups.com.
>>> > For more options, visit this group at
>>> > http://groups.google.com/group/django-users?hl=en.
>>> >
>>> >
>>>
>>>
>>> --
>>> SEYFULLAH TIKIÇ
>>>
>>  --
>> 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/-/KkXJTQwbtYwJ.
>>
>> 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.
>



-- 
SEYFULLAH TIKIÇ

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



Re: How to use Django with Apache and mod_wsgi

2012-08-22 Thread Seyfullah Tıkıç
I checked my file again, it is not incomplete.

There is no file in /etc/apache2/conf.d

Output of apachectl -S is as below. I actually uninstalled mod_python, I
want to use mod_wsgi only.
Syntax error on line 49 of /etc/apache2/modules.d/16_mod_python.conf:
Invalid command 'PythonHandler', perhaps misspelled or defined by a module
not included in the server configuration

line 49 of /etc/apache2/modules.d/16_mod_python.conf is as below, I don't
know why it causes an error.

PythonHandler django.core.handlers.modpython


2012/8/20 Joris 

> The DocumentRoot directive is missing from the httpd.conf, indicating you
> did not send all the required data. This may be because your attachment is
> incomplete:
>
> There is an include statement in your httpd.conf: "Include
> /etc/apache2/conf.d/*.conf"
> All files from that conf.d folder are also processed. Please look in files
> located in  /etc/apache2/conf.d/ for anything useful. Especially files that
> contain a documentroot directive
>
> Also, it may help if you post the output of
> apachectl -S
> (note: some distros want apache2ctl instead of apachectl)
>
> jb
>
>
>
> On Monday, August 20, 2012 11:30:49 AM UTC+2, stikic wrote:
>
>> httpd.conf file is in the attachment.
>>
>> 2012/8/20, Joseph Mutumi :
>> > Hello,
>> >
>> > Could you post the VirtualHost configuration for Apache?
>> > That would greatly help us help you.
>> >
>> > Regards
>> >
>> > On Mon, Aug 20, 2012 at 12:30 AM, Seyfullah Tıkıç 
>> wrote:
>> >
>> >> Hello,
>> >>
>> >> I read the article below.
>> >> https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
>> >>
>> >> But still http://localhost redirects to
>> >> /var/www/localhost/htdocs/index.html.
>> >> I want http://localhost/ redirescts to /home/seyfullah/django/mysite.
>> >> How can I do this?
>> >>
>> >> --
>> >> SEYFULLAH TIKIÇ
>> >>
>> >> --
>> >> You received this message because you are subscribed to the Google
>> Groups
>> >> "Django users" group.
>> >> To post to this group, send email to django...@googlegroups.com.
>> >> To unsubscribe from this group, send email to
>> >> django-users...@googlegroups.com.
>> >> For more options, visit this group at
>> >> http://groups.google.com/group/django-users?hl=en.
>> >>
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Django users" group.
>> > To post to this group, send email to django...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > django-users...@googlegroups.com.
>> > For more options, visit this group at
>> > http://groups.google.com/group/django-users?hl=en.
>> >
>> >
>>
>>
>> --
>> SEYFULLAH TIKIÇ
>>
>  --
> 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/-/KkXJTQwbtYwJ.
>
> 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.
>



-- 
SEYFULLAH TIKIÇ

-- 
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: HttpResponseNotModified returning 200 code

2012-08-22 Thread Alexis Roda

Al 22/08/12 21:36, En/na Kevin Anthony ha escrit:

Here is my code:

id = get_id(request)
  if id is not None:
  host = request.GET['host']
  if host!=None:
  command =
command_queue.objects.all().filter(destination_hostname=host,user__id=id)
  if not command.count():
  HttpResponseNotModified()
  retval =
JSONResponse(command.values('command','command_text'),Extra={"success":True})
  command.delete()
  return retval
 return HttpResponseForbidden()

I know it's getting to the HttpResponseNotModified, but I'm still
getting a HTTP status code of 200.

Can someone point me in the correct direction?


return HttpResponseNotModified()



HTH

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



HttpResponseNotModified returning 200 code

2012-08-22 Thread Kevin Anthony
Here is my code:

id = get_id(request)
 if id is not None:
 host = request.GET['host']
 if host!=None:
 command =
command_queue.objects.all().filter(destination_hostname=host,user__id=id)
 if not command.count():
 HttpResponseNotModified()
 retval =
JSONResponse(command.values('command','command_text'),Extra={"success":True})
 command.delete()
 return retval
return HttpResponseForbidden()

I know it's getting to the HttpResponseNotModified, but I'm still getting a
HTTP status code of 200.

Can someone point me in the correct direction?
-- 
Thanks
Kevin Anthony
www.NoSideRacing.com

Do you use Banshee?
Download the Community Extensions:
http://banshee.fm/download/extensions/

-- 
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: View loaded twice / Database entry saved twice

2012-08-22 Thread James Verran
Yes, I think you are right! That would explain the strange behaviour - even
in the admin section the page is being loaded. Thank you!

On Wed, Aug 22, 2012 at 1:10 AM, Jeff Tchang  wrote:

> Is it possible you are testing using a browser and it is doing a request
> for the page and for favicon.ico? That would end up being 2 requests. You
> can use something like Chrome Developer Tools or Firebug to see.
>
> -Jeff
>
> On Tue, Aug 21, 2012 at 4:07 PM, James Verran  wrote:
>
>> Hi there, I'm trying to capture all url path data. (Except admin, and a
>> couple other paths.)
>>
>> At the end of my urls.py file, I'm using r'^(.*)$'... On my associated
>> view, I make a simple entry into a database - ie:
>> Test(path=capturedpath).save()
>>
>> The problem: my database entry is saved twice! Or rather, my view is
>> being loaded twice. I added a global variable to check- if not
>> globals()['already_saved']: Test(path=capturedpath).save()
>>
>> If I adjust the path: r'^test/(.*)$'  all works as expected (here my url
>> would be 
>> 'mysite.com/test/url/data/to/capture'
>> .)
>>
>> I'm using django 1.4. Any help/thoughts/suggestions would be much
>> appreciated.
>>
>> Thanks!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: What is the easy way to install DJango?

2012-08-22 Thread Amyth Arora
Here is an easy tutorial on how you can install django on windows
http://techstricks.com/install-django-on-windows-7/ .I am assuming
that you already have python installed on your computer, if not then
First install Python using this tutorial
http://techstricks.com/installing-python-2-7-on-windows-7/ and then
follow the tutorial on installing django.

Cheers

On Wed, Aug 22, 2012 at 7:59 PM, Demian Brecht  wrote:
> Er, it's easy to install on Windows until you want to install a package that
> has C extensions. Then, you're either scouring the web for pre-builts (which
> can be a pain depending on your architecture and your level of paranoia
> about the contents of the binaries) or you're installing a GNU toolchain on
> a Windows machine, which is far from easy for someone new(er) to Python
> development (unless they come from a Linux environment anyway). Examples of
> such modules are MySQLdb and pycrypto.
>
> I also +1 getting used to Linux for Python/Django development. Makes the
> world a happier place ;)
>
>
>
> On Wed, Aug 15, 2012 at 6:00 AM, Jirka Vejrazka 
> wrote:
>>
>> It's easy to install Django on a Windows machine to test it out and
>> develop code. Most of this is covered here:
>> https://docs.djangoproject.com/en/1.4/topics/install/
>>
>> In a nutshell, you need:
>> - Python 2.x (2.7) - install it if you already have not done so
>> - Django (start with a stable release e.g. 1.4, download link on the
>> main Django page)
>> - to install the downloaded Django package (covered in docs)
>> - to find your "django-admin.py" (most likely in C:\Python27\Scripts)
>> and use it to create your first project.
>> - follow the official tutorial to learn the basics
>>
>> https://docs.djangoproject.com/en/1.4/intro/tutorial01/
>>
>>   It's pretty straightforward, most people have trouble locating the
>> django-admin.py which is not on system PATH by default.
>>
>>  HTH
>>
>>Jirka
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
Thanks & Regards


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

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



Re: What is the easy way to install DJango?

2012-08-22 Thread Demian Brecht
Er, it's easy to install on Windows until you want to install a package
that has C extensions. Then, you're either scouring the web for pre-builts
(which can be a pain depending on your architecture and your level of
paranoia about the contents of the binaries) or you're installing a GNU
toolchain on a Windows machine, which is far from easy for someone new(er)
to Python development (unless they come from a Linux environment anyway).
Examples of such modules are MySQLdb and pycrypto.

I also +1 getting used to Linux for Python/Django development. Makes the
world a happier place ;)



On Wed, Aug 15, 2012 at 6:00 AM, Jirka Vejrazka wrote:

> It's easy to install Django on a Windows machine to test it out and
> develop code. Most of this is covered here:
> https://docs.djangoproject.com/en/1.4/topics/install/
>
> In a nutshell, you need:
> - Python 2.x (2.7) - install it if you already have not done so
> - Django (start with a stable release e.g. 1.4, download link on the
> main Django page)
> - to install the downloaded Django package (covered in docs)
> - to find your "django-admin.py" (most likely in C:\Python27\Scripts)
> and use it to create your first project.
> - follow the official tutorial to learn the basics
>
> https://docs.djangoproject.com/en/1.4/intro/tutorial01/
>
>   It's pretty straightforward, most people have trouble locating the
> django-admin.py which is not on system PATH by default.
>
>  HTH
>
>Jirka
>
> --
> 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: What is the easy way to install DJango?

2012-08-22 Thread Jani Tiainen

22.8.2012 14:56, Tom Evans kirjoitti:

On Wed, Aug 15, 2012 at 3:53 PM, Vibhu Rishi  wrote:

Hi,

If you are new to Django and are just getting around to learn it, I
recommend using BitNami Django stack for windows.
http://bitnami.org/stack/djangostack

So far, it has been the easiest to install on the windows machine.

Vibhu


I know a lot of people really like these bundled stacks, but there are
a few downsides to consider:

1) You get what the packagers have packaged. If that is not precisely
what you want, tough.
2) You gain no knowledge about how your stack is put together. If you
don't understand your stack, developing solutions using it becomes
trickier.
3) Django is not a language; its a python library. It's highly likely
you will also use other python libraries as part of your solution, so
working out how to deal with installing, upgrading and maintaining
python libraries is a useful skill. By just installing a stack, you
miss out on learning useful skills.

I don't want to put people off though; I'm sure the people at bitnami
have put together a good stack.

Cheers

Tom



I also agree that using any stack is simple way to get prepackaged 
"something" up and running.


But as Tom pointed out Django is just a python library. It's rather 
evitable to start need other libraries as well. Or if you happen to have 
some nice database backend like I do have Oracle and I use GeoDjango 
spatial parts that do require quite a bunch of external stuff to be 
installed. Never tried on bitnami stack but in general those will get 
tricky there.


I use windows environment for everyday development - as does about 20 my 
colleagues as well. I wrote small blog entry in April how I setup my 
environment. That includes python, virtualenv and TCC/LE that brings 
nice enhancement over standard CMD to make everything feel more 
"unix-like" environment without needs to do any virtual machine or dual 
boot tricks. But it's not hard to install everything it just requires 
some work. And after you get virtualenvs up and running setting up all 
kind of stuff is just a breeze.


http://djangonautlostinspace.wordpress.com/2012/04/16/django-and-windows/

I also know that there exists virtualenv-wrapper scripts for windows 
cmd/powershell but never got them working in my environment and I've 
been too lazy to try to fix them for my envs.


--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

--
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: authenticate=None mistery: can't authenticate from the web but it works from the command line

2012-08-22 Thread Jorge Garcia
Indeed it was a typo! 
Now that I have a valid user instance, I will use 
django.contrib.auth.login() to have a session. 

Thank you both for your help ;)

Le mercredi 22 août 2012 12:37:42 UTC+2, Tom Evans a écrit :
>
> In addition to the 'user'/'username' typo, this login view would not 
> log a user in. In order to log a user in, you must verify their 
> credentials by calling django.contrib.auth.authenticate(), which will 
> either return an authenticated user or None. 
>
> Once the credentials are verified, you must then call 
> django.contrib.auth.login() to persist login information in the users 
> session. Without calling login(), the user will only be authenticated 
> on the single request in which they authenticated. 
>
> More documentation on how to use authenticate and login is here: 
>
>
> https://docs.djangoproject.com/en/1.4/topics/auth/#django.contrib.auth.login 
>
> Cheers 
>
> Tom 
>
> On Sun, Aug 19, 2012 at 10:51 PM, Joseph Mutumi 
> > 
> wrote: 
> > Hello, 
> > 
> > I believe its a simple typo! 
> > 
> > authenticate(user=usuario, password=clave) 
> > 
> > should be 
> > 
> > authenticate(username=usuario, password=clave) 
> > 
> > Regards 
> > 
> > 
> > On Sun, Aug 19, 2012 at 3:35 PM, Jorge Garcia 
> > > 
>
> > wrote: 
> >> 
> >> Hi there. Im doing my first login form for an existing Django 
> application. 
> >> The thing is that when I give the correct usr/pswd from the web, 
> >> django.contrib.auth.authenticate returns systematically None. However, 
> when 
> >> I try the same thing from the Django shell it works.  I'm working with 
> a 
> >> "john" user created from the Django admin application, using the 
> "password 
> >> chang" form. Here's the code, and the Django command line output. 
> >> 
> >> My application and me will be eternally thankful for your help. 
> >> 
> >> ++COMMAND LINE 
> >> python manage.py shell 
> >> >>> from django.contrib.auth import authenticate 
> >> >>> user = authenticate(username='john', password='johnpassword') 
> >> >>> print user 
> >> john 
> >> 
> >> ++VIEWS.PY 
> >> from django.contrib.auth.models import User 
> >> 
> >> def index(request): 
> >> return render_to_response('unoporuno/index.html', None, 
> >> context_instance=RequestContext(request)) 
> >> 
> >> def login_cidesal(request): 
> >> usuario = request.POST['usuario'] 
> >> clave = request.POST['clave'] 
> >> user = authenticate(user=usuario, password=clave) 
> >> return HttpResponse("logging in user:" + usuario + " with 
> password:" + 
> >> clave + " and authenticate result=" + str(user)) 
> >> 
> >> ++URLS.PY 
> >> urlpatterns = patterns('unoporuno.views', 
> >>url(r'^$','index'), 
> >>url(r'login/', 'login_cidesal'), 
> >> 
> >> ++INDEX.HTML 
> >> http://www.w3.org/1999/xhtml"; xml:lang="es"> 
> >>  
> >>  
> >>  
> >>  
> >>  
> >>  
> >> {% csrf_token %} 
> >>  
> >>  >> border="0"/> 
> >> UnoporunO 
> >> Buscador de personas especializado en movilidad profesional 
> >>  
> >> Usuario:  
> >> Clave :  
> >>  
> >>  
> >>  
> >>  
> >> 
> >> ++WEB RESULT TYPING usuario=john clave=johnpassword 
> >> logging in user:john with password:johnpassword and authenticate 
> >> result=None 
> >> 
> >> -- 
> >> 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/-/1UKsQlJ5OB8J. 
> >> To post to this group, send email to 
> >> django...@googlegroups.com. 
>
> >> To unsubscribe from this group, send email to 
> >> django-users...@googlegroups.com . 
> >> For more options, visit this group at 
> >> http://groups.google.com/group/django-users?hl=en. 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> Groups 
> > "Django users" group. 
> > To post to this group, send email to 
> > django...@googlegroups.com. 
>
> > To unsubscribe from this group, send email to 
> > django-users...@googlegroups.com . 
> > For more options, visit this group at 
> > http://groups.google.com/group/django-users?hl=en. 
>

-- 
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/-/wQI7tZlhQDEJ.
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: conditional submit depending on ajax call

2012-08-22 Thread mapapage

>
> I can see what you mean.
>
Meanwhile, I tried the following and it seems to work:

$("#myform").submit(function() {
var rdatefrom=$('#id_rdatefrom').val()
 var arr_sdateText = rdatefrom.split("/");
 startday = arr_sdateText[0];
 startmonth = arr_sdateText[1]; 
 startyear = arr_sdateText[2];
  
   $.get(""+startday+"/"+startmonth+"/"+startyear+"/") function(data) {

   msg=data.msg;
   if(msg!=='None'){
 alert(msg);
 return false;} 
   else {
 $("#myform").unbind('submit');
 $("#myform").submit(); }
});
event.preventDefault();
}); 
Is it wrong?

-- 
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/-/_hvOnIWvhsoJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How I do to centralize logins OpenID in django?

2012-08-22 Thread Adam
Thank you!

Il giorno mercoledì 22 agosto 2012 09:39:43 UTC+2, Thomas Orozco ha scritto:
>
> +1 - If you are running both apps using the same database server, this 
> would probably be the simpler solution! 
> Le 22 août 2012 04:26, "Kurtis Mullins" > 
> a écrit :
>
>> I've never tried this approach; but maybe you could use the 
>> multi-database feature of Django to share a database for the 
>> Authentication/Sessions components? (
>> https://docs.djangoproject.com/en/dev/topics/db/multi-db/)
>>
>> On Tue, Aug 21, 2012 at 7:39 PM, Mustapha Aoussar 
>> 
>> > wrote:
>>
>>> Dear sirs,
>>> I have split my Django application into two sites with different 
>>> databases. I use OpenID (python_openid 2.2.5) for 
>>> authetication/registration but users of ''site A'' are different from 
>>> ''site B''.
>>>
>>> How can I do to centralize logins between apps running on different 
>>> databases?
>>>
>>> I have seen this article by Joseph Smarr at Plaxo (
>>> http://www.netvivs.com/openid-recipe/) and this Stackoverflow question (
>>> http://stackoverflow.com/questions/4395190/how-do-stackexchange-sites-associate-user-accounts-and-openid-logins)
>>>  
>>> but i don't know how can I do this with django.
>>>
>>> Can you help me please?
>>> Thanks!
>>>
>>> --
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django users" group.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msg/django-users/-/oHVzCzIer48J.
>>> To post to this group, send email to django...@googlegroups.com
>>> .
>>> To unsubscribe from this group, send email to 
>>> django-users...@googlegroups.com .
>>> For more options, visit this group at 
>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>

-- 
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/-/qzRkDOtBzSMJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: How I do to centralize logins OpenID in django?

2012-08-22 Thread Adam
Ok! but if I share the database  for the Authentication then will not be 
required registration for each site. I want a system similar to that used 
on StackExchange, for each site is required to register but the username 
doesn't change it is always the same for all sites.

Thank you very much! I will try with your solution.


Il giorno mercoledì 22 agosto 2012 04:26:47 UTC+2, Kurtis ha scritto:
>
> I've never tried this approach; but maybe you could use the multi-database 
> feature of Django to share a database for the Authentication/Sessions 
> components? (https://docs.djangoproject.com/en/dev/topics/db/multi-db/)
>
> On Tue, Aug 21, 2012 at 7:39 PM, Mustapha Aoussar 
> 
> > wrote:
>
>> Dear sirs,
>> I have split my Django application into two sites with different 
>> databases. I use OpenID (python_openid 2.2.5) for 
>> authetication/registration but users of ''site A'' are different from 
>> ''site B''.
>>
>> How can I do to centralize logins between apps running on different 
>> databases?
>>
>> I have seen this article by Joseph Smarr at Plaxo (
>> http://www.netvivs.com/openid-recipe/) and this Stackoverflow question (
>> http://stackoverflow.com/questions/4395190/how-do-stackexchange-sites-associate-user-accounts-and-openid-logins)
>>  
>> but i don't know how can I do this with django.
>>
>> Can you help me please?
>> Thanks!
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msg/django-users/-/oHVzCzIer48J.
>> To post to this group, send email to django...@googlegroups.com
>> .
>> To unsubscribe from this group, send email to 
>> django-users...@googlegroups.com .
>> For more options, visit this group at 
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/1k5FaVBVRNYJ.
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: skip fixtures loading on 'manage.py test myapp'

2012-08-22 Thread Anton Baklanov
exactly

On Wed, Aug 22, 2012 at 2:24 AM, Karen Tracey  wrote:

> That link doesn't really explain why south would be loading fixtures that
> Django itself wouldn't ordinarily load. Unless...do you have migrations
> that are loading fixtures?
>



-- 
Regards,
Anton Baklanov

-- 
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: What is the easy way to install DJango?

2012-08-22 Thread Tom Evans
On Wed, Aug 15, 2012 at 3:53 PM, Vibhu Rishi  wrote:
> Hi,
>
> If you are new to Django and are just getting around to learn it, I
> recommend using BitNami Django stack for windows.
> http://bitnami.org/stack/djangostack
>
> So far, it has been the easiest to install on the windows machine.
>
> Vibhu

I know a lot of people really like these bundled stacks, but there are
a few downsides to consider:

1) You get what the packagers have packaged. If that is not precisely
what you want, tough.
2) You gain no knowledge about how your stack is put together. If you
don't understand your stack, developing solutions using it becomes
trickier.
3) Django is not a language; its a python library. It's highly likely
you will also use other python libraries as part of your solution, so
working out how to deal with installing, upgrading and maintaining
python libraries is a useful skill. By just installing a stack, you
miss out on learning useful skills.

I don't want to put people off though; I'm sure the people at bitnami
have put together a good stack.

Cheers

Tom

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



Re: conditional submit depending on ajax call

2012-08-22 Thread Tom Evans
Your JS looks decidedly incorrect. You say the aim is to prevent the
form being submitted in certain scenarios, yet your form submit
handler neither returns true nor false. You return truthiness from
your anonymous AJAX handler, but that is not the same.

Secondly, your check to see whether to submit the form uses AJAX. The
first A is important there, the communication happens asynchronously.
This sequence of events occurs:

Form submit handler called
Form submit handler creates an AJAX request
AJAX request is submitted to the server
Form submit handler completes with no return value
Browser prepares to submit the form
Browser closes any open network connections the page has
Server attempts to write to closed socket, generating quoted exception
Browser submits form to server

You need to make your jquery AJAX call synchronous, and return
true/false from the appropriate location. "jquery synchronous ajax"
should give you all the information you need.

Cheers

Tom

On Wed, Aug 22, 2012 at 10:56 AM, mapapage  wrote:
> Hi!I'm trying to perform an ajax call on the submit of a form. The form will
> be submitted depending on the call's result.
> I'm doing sth like that:
>
> $("#myform").submit(function() {
> var rdatefrom=$('#id_rdatefrom').val();
> var arr_sdateText = rdatefrom.split("/");
> startday = arr_sdateText[0];
> startmonth = arr_sdateText[1];
> startyear = arr_sdateText[2];
>
>   $.get(""+startday+"/"+startmonth+"/"+startyear+"/")function(data) {
> msg=data.msg;
> if(msg!=='None'){
>  alert(msg);
>  return false;}
> return true;
>  });
>  });
> but the form is being submitted regardless the call's result while I get the
> monstrous:
>
> Traceback (most recent call last):
>   File "/usr/lib/python2.6/wsgiref/handlers.py", line 94, in run
> self.finish_response()
>   File "/usr/lib/python2.6/wsgiref/handlers.py", line 135, in
> finish_response
> self.write(data)
>   File "/usr/lib/python2.6/wsgiref/handlers.py", line 218, in write
> self.send_headers()
>   File "/usr/lib/python2.6/wsgiref/handlers.py", line 274, in send_headers
> self.send_preamble()
>   File "/usr/lib/python2.6/wsgiref/handlers.py", line 200, in send_preamble
> 'Date: %s\r\n' % format_date_time(time.time())
>   File "/usr/lib/python2.6/socket.py", line 300, in write
> self.flush()
>   File "/usr/lib/python2.6/socket.py", line 286, in flush
> self._sock.sendall(buffer)
> error: [Errno 32] Broken pipe
>
> What's going on?
>
>
> --
> 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/-/7G1wG2673jQJ.
> 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.



GeometryField in OSMGeoAdmin

2012-08-22 Thread geonition
Hi,

I have a problem with GeometryField not showing the saved geometry in the 
admin interface. The problem is that the GeometryField has a type of 
'GEOMETRY' when the value saved might have the type of e.g. 'POINT'. This 
leads to that the OpenLayersWidget will set the value as empty. I do not 
know why the widget do this, but my question is is there a workaround to 
make the geometry show as it should in the admin interface?

This is the line causing problems for me in OpenLayersWidget:
if value and value.geom_type.upper() != self.geom_type:
value = None


-- 
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/-/Y0pZr__NSbgJ.
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: Distinct Values in ModelChoiceField

2012-08-22 Thread Sithembewena Lloyd Dube
@Melvyn, thanks - that makes sense.

On Wed, Aug 22, 2012 at 3:18 AM, Melvyn Sopacua wrote:

> On 22-8-2012 3:04, Sithembewena Lloyd Dube wrote:
>
> > I found your response to the OP interesting, yet I cannot quite follow
> it.
> > Even if he sets a unique attribute (presumably Boolean/ Checkbox?)
>
> Nope, this unique attribute:
> 
>
> By design, the foreign key will now not contain duplicates so distinct
> is no longer necessary.
> --
> Melvyn Sopacua
>
> --
> 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.
>
>


-- 
Regards,
Sithembewena Lloyd Dube

-- 
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: authenticate=None mistery: can't authenticate from the web but it works from the command line

2012-08-22 Thread Tom Evans
In addition to the 'user'/'username' typo, this login view would not
log a user in. In order to log a user in, you must verify their
credentials by calling django.contrib.auth.authenticate(), which will
either return an authenticated user or None.

Once the credentials are verified, you must then call
django.contrib.auth.login() to persist login information in the users
session. Without calling login(), the user will only be authenticated
on the single request in which they authenticated.

More documentation on how to use authenticate and login is here:

https://docs.djangoproject.com/en/1.4/topics/auth/#django.contrib.auth.login

Cheers

Tom

On Sun, Aug 19, 2012 at 10:51 PM, Joseph Mutumi  wrote:
> Hello,
>
> I believe its a simple typo!
>
> authenticate(user=usuario, password=clave)
>
> should be
>
> authenticate(username=usuario, password=clave)
>
> Regards
>
>
> On Sun, Aug 19, 2012 at 3:35 PM, Jorge Garcia 
> wrote:
>>
>> Hi there. Im doing my first login form for an existing Django application.
>> The thing is that when I give the correct usr/pswd from the web,
>> django.contrib.auth.authenticate returns systematically None. However, when
>> I try the same thing from the Django shell it works.  I'm working with a
>> "john" user created from the Django admin application, using the "password
>> chang" form. Here's the code, and the Django command line output.
>>
>> My application and me will be eternally thankful for your help.
>>
>> ++COMMAND LINE
>> python manage.py shell
>> >>> from django.contrib.auth import authenticate
>> >>> user = authenticate(username='john', password='johnpassword')
>> >>> print user
>> john
>>
>> ++VIEWS.PY
>> from django.contrib.auth.models import User
>>
>> def index(request):
>> return render_to_response('unoporuno/index.html', None,
>> context_instance=RequestContext(request))
>>
>> def login_cidesal(request):
>> usuario = request.POST['usuario']
>> clave = request.POST['clave']
>> user = authenticate(user=usuario, password=clave)
>> return HttpResponse("logging in user:" + usuario + " with password:" +
>> clave + " and authenticate result=" + str(user))
>>
>> ++URLS.PY
>> urlpatterns = patterns('unoporuno.views',
>>url(r'^$','index'),
>>url(r'login/', 'login_cidesal'),
>>
>> ++INDEX.HTML
>> http://www.w3.org/1999/xhtml"; xml:lang="es">
>> 
>> 
>> 
>> 
>> 
>> 
>> {% csrf_token %}
>> 
>> > border="0"/>
>> UnoporunO
>> Buscador de personas especializado en movilidad profesional
>> 
>> Usuario: 
>> Clave : 
>> 
>> 
>> 
>> 
>>
>> ++WEB RESULT TYPING usuario=john clave=johnpassword
>> logging in user:john with password:johnpassword and authenticate
>> result=None
>>
>> --
>> 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/-/1UKsQlJ5OB8J.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

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



conditional submit depending on ajax call

2012-08-22 Thread mapapage
Hi!I'm trying to perform an ajax call on the submit of a form. The form 
will be submitted depending on the call's result. 
I'm doing sth like that:

$("#myform").submit(function() {
var rdatefrom=$('#id_rdatefrom').val();
var arr_sdateText = rdatefrom.split("/");
startday = arr_sdateText[0];
startmonth = arr_sdateText[1]; 
startyear = arr_sdateText[2];

  $.get(""+startday+"/"+startmonth+"/"+startyear+"/")function(data) {
msg=data.msg;
if(msg!=='None'){
 alert(msg);
 return false;}
return true;
 }); 
 }); 
but the form is being submitted regardless the call's result while I get 
the monstrous:

Traceback (most recent call last):
  File "/usr/lib/python2.6/wsgiref/handlers.py", line 94, in run
self.finish_response()
  File "/usr/lib/python2.6/wsgiref/handlers.py", line 135, in 
finish_response
self.write(data)
  File "/usr/lib/python2.6/wsgiref/handlers.py", line 218, in write
self.send_headers()
  File "/usr/lib/python2.6/wsgiref/handlers.py", line 274, in send_headers
self.send_preamble()
  File "/usr/lib/python2.6/wsgiref/handlers.py", line 200, in send_preamble
'Date: %s\r\n' % format_date_time(time.time())
  File "/usr/lib/python2.6/socket.py", line 300, in write
self.flush()
  File "/usr/lib/python2.6/socket.py", line 286, in flush
self._sock.sendall(buffer)
error: [Errno 32] Broken pipe

What's going on?


-- 
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/-/7G1wG2673jQJ.
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: Can somebody help me on how to handle this scenario?

2012-08-22 Thread Paul Backhouse
You shouldn't need to define "People" or "User", that already comes in
django.contrib.auth.models. Just import User and make that your foreign
key where needed. 

A smart way would be to use django.contrib.comments.

https://docs.djangoproject.com/en/dev/ref/contrib/comments/

For more complex commenting mechanisms take a look at django packages:

http://www.djangopackages.com/grids/g/commenting/


-- 
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: View loaded twice / Database entry saved twice

2012-08-22 Thread Martin J. Laubach
  Also, you should really only do saves on a POST request, never on GETs.

mjl

-- 
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/-/jIUH0iInCQ0J.
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: View loaded twice / Database entry saved twice

2012-08-22 Thread Jeff Tchang
Is it possible you are testing using a browser and it is doing a request
for the page and for favicon.ico? That would end up being 2 requests. You
can use something like Chrome Developer Tools or Firebug to see.

-Jeff

On Tue, Aug 21, 2012 at 4:07 PM, James Verran  wrote:

> Hi there, I'm trying to capture all url path data. (Except admin, and a
> couple other paths.)
>
> At the end of my urls.py file, I'm using r'^(.*)$'... On my associated
> view, I make a simple entry into a database - ie:
> Test(path=capturedpath).save()
>
> The problem: my database entry is saved twice! Or rather, my view is being
> loaded twice. I added a global variable to check- if not
> globals()['already_saved']: Test(path=capturedpath).save()
>
> If I adjust the path: r'^test/(.*)$'  all works as expected (here my url
> would be 
> 'mysite.com/test/url/data/to/capture'
> .)
>
> I'm using django 1.4. Any help/thoughts/suggestions would be much
> appreciated.
>
> Thanks!
>
> --
> 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: How I do to centralize logins OpenID in django?

2012-08-22 Thread Thomas Orozco
+1 - If you are running both apps using the same database server, this
would probably be the simpler solution!
Le 22 août 2012 04:26, "Kurtis Mullins"  a écrit :

> I've never tried this approach; but maybe you could use the multi-database
> feature of Django to share a database for the Authentication/Sessions
> components? (https://docs.djangoproject.com/en/dev/topics/db/multi-db/)
>
> On Tue, Aug 21, 2012 at 7:39 PM, Mustapha Aoussar <
> mustapha.aous...@gmail.com> wrote:
>
>> Dear sirs,
>> I have split my Django application into two sites with different
>> databases. I use OpenID (python_openid 2.2.5) for
>> authetication/registration but users of ''site A'' are different from
>> ''site B''.
>>
>> How can I do to centralize logins between apps running on different
>> databases?
>>
>> I have seen this article by Joseph Smarr at Plaxo (
>> http://www.netvivs.com/openid-recipe/) and this Stackoverflow question (
>> http://stackoverflow.com/questions/4395190/how-do-stackexchange-sites-associate-user-accounts-and-openid-logins)
>> but i don't know how can I do this with django.
>>
>> Can you help me please?
>> Thanks!
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/django-users/-/oHVzCzIer48J.
>> To post to this group, send email to django-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> django-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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