how to get text of a ChoiceField populated with ajax

2012-05-08 Thread HDayi
hi people,
i am new to all of this.
i have a form which has several selcet boxes. one is a
ModelChoiceField gets school list from database. the other is only a
ChoiceField and it's empty. when school   is chosen i populate the
ChoiceField using dajax. it works perfectly but...

while validating the form when calculating the cleaned_data value
returns index of the selected item and django does not validate the
form.

can you help me on this?
thx

-- 
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: Instalación en centOs 6.2

2012-05-08 Thread Segundo Acosta Delgado
Gracias, si de hecho ya lo pude hacer correr pero estoy teniendo problemas 
con el index.fcgi , la verdad como soy nuevo no entiendo algunas cosas pero 
ahi le voy dando, gracias de todas formas!!!

El lunes, 7 de mayo de 2012 05:14:30 UTC-5, francescortiz escribió:
>
> Para centos debes seguir los mismos pasos que en cualquier otro lugar. 
> Apache con fastcgi, o con wcgi, o nginx, o lighttpd, o cherokee... tu 
> mismo. Hay guias por todos lados. Solo debes tener en cuenta que 
> dependiendo del servidor que escojas, tu eres responsable de rearrancar las 
> instancias de django cuando se reinicia el servidor.
>
> También te recomiendo que mires el tema del los virtual envs, porqué sale 
> una versión de django más o menos cada año i poco, y no te interesa tener 
> que revisar todos los sitios antiguos cuando actualizes el sistema y te 
> suba la versión de django. Es mejor que cada instancia de django use su 
> propia versión de django y sus propias librerias.
>
> On Thursday, May 3, 2012 9:45:30 PM UTC+2, Segundo Acosta Delgado wrote:
>>
>> Como es la instalación en centOS 6.2 de 64 bits 
>
>

-- 
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/-/P-azye4fvJ4J.
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.



inspectdb+oracle

2012-05-08 Thread mapapage
I'm working on a django project on Ubuntu 10.04 with Oracle Database
Server
I use Oracle Database 10g xe universal Rel.10.2.0.1.0 against
cx_Oracle-5.0.4-10g-unicode-py26-1.x86_64

My db is generated by oracle 10gr2 enterprise edition (on Windows XP,
import done in US7ASCII character set and AL16UTF16 NCHAR character
set, import server uses AL32UTF8 character set, export client uses
EL8MSWIN1253 character set and AL16UTF16 NCHAR )

When I try django-admin.py inspectdb I get the following error:
 ..."indexes = connection.introspection.get_indexes(cursor,
table_name)
  File "/usr/lib/pymodules/python2.6/django/db/backends/oracle/
introspection.py", line 116, in get_indexes
for row in cursor.fetchall():
  File "/usr/lib/pymodules/python2.6/django/db/backends/oracle/
base.py", line 483, in fetchall
for r in self.cursor.fetchall()])
cx_Oracle.DatabaseError: OCI-22061: invalid format text [T".

I am aware of "inspectdb works with PostgreSQL, MySQL and SQLite." but
from posts I saw that it also works with oracle somehow. Does anyone
know how I could fix this prob?

Thx

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



system can not find specified path

2012-05-08 Thread AJAYI THEOPHILUS
I installed django with setup.py perfecctly but after configuring sqlite3 
database and running the syncdb command i received system can not find 
specified path so i uninstalled django but i kept getting the same message.

-- 
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/-/4tt7BkbVvFMJ.
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: Presentation Viewer on django

2012-05-08 Thread Jani Tiainen
To be able to do that you have to convert your presentation to something
more generic that can be shown. Plain HTML
and Flash are two popular formats to do that. For a free solution you can
use (headless) openoffice/liberoffice to automatically convert your ppt to
html/flash and then
show it on your page (inside frame).

Another option is to make sure that you return correct mime-types for a
(i)frame and then your users are required to have powerpoint installed on
their machines to be able to show it in browser. And I think it only works
for IE, not  for FF/Chrome/Safari...

On Tue, May 8, 2012 at 1:34 AM, Amr Abdel-wahab <
amr.mohamed.abdelwa...@gmail.com> wrote:

> I don't want to generate a pdf/ppt or edit it I just need to upload it
> in one page and show it in a frame in another page in the browser
>
> --
> 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.
>
>


-- 
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: inspectdb+oracle

2012-05-08 Thread Jani Tiainen
You're using old CX_Oracle (5.0.4) which is known to have issues with 
unicode. Try updating to 5.1.1 and see if problem persists.


8.5.2012 10:50, mapapage kirjoitti:

I'm working on a django project on Ubuntu 10.04 with Oracle Database
Server
I use Oracle Database 10g xe universal Rel.10.2.0.1.0 against
cx_Oracle-5.0.4-10g-unicode-py26-1.x86_64

My db is generated by oracle 10gr2 enterprise edition (on Windows XP,
import done in US7ASCII character set and AL16UTF16 NCHAR character
set, import server uses AL32UTF8 character set, export client uses
EL8MSWIN1253 character set and AL16UTF16 NCHAR )

When I try django-admin.py inspectdb I get the following error:
  ..."indexes = connection.introspection.get_indexes(cursor,
table_name)
   File "/usr/lib/pymodules/python2.6/django/db/backends/oracle/
introspection.py", line 116, in get_indexes
 for row in cursor.fetchall():
   File "/usr/lib/pymodules/python2.6/django/db/backends/oracle/
base.py", line 483, in fetchall
 for r in self.cursor.fetchall()])
cx_Oracle.DatabaseError: OCI-22061: invalid format text [T".

I am aware of "inspectdb works with PostgreSQL, MySQL and SQLite." but
from posts I saw that it also works with oracle somehow. Does anyone
know how I could fix this prob?

Thx




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



Save Tweepy tweets in database

2012-05-08 Thread coded kid
I want to save users tweets in my db (MySQL) But I'm finding it
difficult to get how I will go about it. The main problem is that, I
didn't create any models for it, I just input the below codes in my
views,since I'm getting users tweets through tweepy api.

The question now is, how will I save users tweets in my Database?

Kindly give me a reply if you know how I will solve this problem!
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.



Re: system can not find specified path

2012-05-08 Thread Babatunde Akinyanmi
Hi theo,
Why not show your settings.py file and the exact traceback

On 5/8/12, AJAYI THEOPHILUS  wrote:
> I installed django with setup.py perfecctly but after configuring sqlite3
> database and running the syncdb command i received system can not find
> specified path so i uninstalled django but i kept getting the same message.
>
> --
> 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/-/4tt7BkbVvFMJ.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
Sent from my mobile device

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



Re: Save Tweepy tweets in database

2012-05-08 Thread kenneth gonsalves
On Tue, 2012-05-08 at 03:19 -0700, coded kid wrote:
> I want to save users tweets in my db (MySQL) But I'm finding it
> difficult to get how I will go about it. The main problem is that, I
> didn't create any models for it, I just input the below codes in my
> views,since I'm getting users tweets through tweepy api.
> 
> The question now is, how will I save users tweets in my Database?
> 
> Kindly give me a reply if you know how I will solve this problem!
> Thanks. 

make a model to hold the tweets and save.
-- 
regards
Kenneth Gonsalves

-- 
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: Save Tweepy tweets in database

2012-05-08 Thread coded kid
creating the model is not a problem but the problem is how to make use of 
it in views.py. You have any idea?

On Tuesday, 8 May 2012 11:19:27 UTC+1, coded kid wrote:
>
> I want to save users tweets in my db (MySQL) But I'm finding it 
> difficult to get how I will go about it. The main problem is that, I 
> didn't create any models for it, I just input the below codes in my 
> views,since I'm getting users tweets through tweepy api. 
>
> The question now is, how will I save users tweets in my Database? 
>
> Kindly give me a reply if you know how I will solve this problem! 
> 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/-/xhk_1kmqwVwJ.
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: Hooking into Django Sessions

2012-05-08 Thread Tom Evans
On Mon, May 7, 2012 at 7:48 AM, M Oklah  wrote:
>
> Hello,
>
> Is it possible to hook into Django so that a user defined callback method is
> executed each time a session expires?
>
>
> Thanks,
>
> -Moe
>

Yes/no/maybe. Depends what you want to do.

First of all, nothing happens when sessions 'expire'. I say 'expire',
because nothing actually changes. The session has an expiry date, and
when you try to use a session after its expiry date has passed, you
will get a new session.

Another thing to note is that Django does not clean expired sessions
by default. Expired sessions will live forever* in the backend. Django
provides a management command that you can run that cleans expired
sessions from the session backend.

If you use the database session backend however, then sessions are
simply models. You can attach signals to model deletion, and if you
clean your session backend frequently, then your signal will get
called for each expired session.

It won't happen the moment your session expires, only when the session
is deleted. That might be enough for you, it might not.

Cheers

Tom

* Not forever. Until a new session key collides with an existing
(expired) session.

-- 
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: Save Tweepy tweets in database

2012-05-08 Thread Aziz Bookwala
Hey

You can go through the Django basic
documentationon
views. It should answer most of your questions.

On Tue, May 8, 2012 at 4:43 PM, coded kid  wrote:

> creating the model is not a problem but the problem is how to make use of
> it in views.py. You have any idea?
>
>
> On Tuesday, 8 May 2012 11:19:27 UTC+1, coded kid wrote:
>>
>> I want to save users tweets in my db (MySQL) But I'm finding it
>> difficult to get how I will go about it. The main problem is that, I
>> didn't create any models for it, I just input the below codes in my
>> views,since I'm getting users tweets through tweepy api.
>>
>> The question now is, how will I save users tweets in my Database?
>>
>> Kindly give me a reply if you know how I will solve this problem!
>> 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/-/xhk_1kmqwVwJ.
>
> 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.
>



-- 
- Aziz M. Bookwala

Website  | Twitter  |
Github 

-- 
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 Pagination Not Working!

2012-05-08 Thread Tom Evans
On Sun, May 6, 2012 at 10:56 PM, coded kid  wrote:
> I'm trying to paginate a page in order to display five statuses per
> page. After inputting these codes, it fails to paginate. Below are the
> codes for pagination and updating of status in my django app.
>
>
> Views:
>
>  def qask(request):
>          extra_data_context={}
>             #if there's nothing in the field do nothing.
>          if request. method=="POST":
>              form =AskForm(request.POST)
>              if form.is_valid():
>                  data=form.cleaned_data
>                  newask=Ask(
>                     user= request.user,
>                     status=data['status'],
>                     pub_date=datetime.datetime.now())
>                 newask.save()
>              extra_data_context.update({'AskForm':form})
>        else:
>            form = AskForm()
>            extra_data_context.update({'AskForm':form})
>
> extra_data_context.update({'Asks':Ask.objects.filter(user=request.user)})

So here you specify 'Asks' as all Ask objects associated with the current user.

>
>       plan=Ask.objects.all()
>       paginator=Paginator(plan, 5)
>
>       try:
>           page=int(request.GET.get('page','1'))
>       except ValueError:
>           page=1
>
>       try:
>          fp=paginator.page(page)
>      except (EmptyPage, InvalidPage):
>          fp=paginator.page(paginator.num_pages)

Here you paginate all Ask objects, and don't do anything with pagination object.


>      return render_to_response
> ('quik_ask.html',extra_data_context,context_instance=RequestContext(request))
>
> Template:
>  {% block content %}
>
>
>
>          {% for Ask in Asks %}
>       
>         {{Ask.user}}  
>         {{Ask.status}}
>           {{Ask.state}} | {{Ask.pub_date|timesince }} ago 
>
>          
>        {% endfor %}
>
>    
>       
>    {% if Asks.has_previous %}

And here you start using 'Asks' in the template as though it had been
paginated and was not a raw queryset. This is unlikely to work.

When you paginate a queryset, you need to create a paginator object
with that queryset, page the paginator to select an appropriate page,
and then pass the page to the template.

This is covered in mind numbing detail in the Django docs:

https://docs.djangoproject.com/en/1.4/topics/pagination/#using-paginator-in-a-view

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: Paramiko EOFErrors start to occur after a while

2012-05-08 Thread Phang Mulianto
Hi,

i also have the script to sftp using python...run with cron every 30 mins,
and suddently since last week, the eol errors come out..

i think this problem bcoz the sftp server..

are you trying rsync to transfer between host ?

On Tue, May 8, 2012 at 6:31 AM, Tino de Bruijn  wrote:

> Hi,
>
> Unfortunatly we can't move to Amazon S3. So what other file system or
> transfer method would you recommend? We had an NFS in place, but getting it
> to play nice with permissions was quite a hassle.
>
> How do other people do this?
>
> Tino
>
>
> On Wednesday, May 2, 2012 1:25:52 AM UTC+2, Kurtis wrote:
>
>> I messed with the SFTP implementatoin a while back. I noticed it was
>> pretty tough and, if I'm not mistaken, a bit out-dated. We ended up moving
>> to Amazon S3 so it wasn't a big deal.
>>
>> Anyways, maybe you could try using another file system? SSH isn't really
>> an ideal solution for this sort of a problem -- even though it works as a
>> great starting point.
>>
>> I'm not sure if that helps much but good luck to you!
>>
>> On Tue, May 1, 2012 at 11:49 AM, Tino de Bruijn  wrote:
>>
>>> Hi,
>>>
>>> My setup is the following: I have two webservers that serve all dynamic
>>> request. I have a seperate static file server (that also has some celery
>>> queue workers running). When images are uploaded by users, those images are
>>> uploaded to the webservers, and processed async by a queue. In the job they
>>> are transfered to the static file server and resized. For the admin
>>> however, I want the transfering and resizing done right then, so that when
>>> admins post content, it is immediatly visible. Admins post different
>>> content than users, so this is implemented by using a different field on
>>> the models. The admin images are transfered to the static file server
>>> directly by using sftpstorage from django-storages.
>>>
>>> The problem is that paramiko (used by django-storages for the sftp
>>> implementation) starts to throw EOFErrors. This doesn't always happen. When
>>> the mod_wsgi instance is fresh, everything works, but after a while these
>>> errors start occurring. Touching the wsgi.py file makes everything work
>>> again.
>>>
>>> I have build a retry loop (5 times) to try to circumvent network
>>> glitches, but it consistently fails. If it needs to retry it'll keep
>>> failing.
>>>
>>> I have two questions:
>>>
>>> 1) Does anybody have an idea why this could be happening?
>>> 2) Is this the best way to implement this strategy, or would you suggest
>>> a different technique?
>>>
>>> Thanks,
>>>
>>>
>>> Tino
>>>
>>> --
>>> 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/-/UXX_**dJrQJOwJ
>>> .
>>> 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
>>> .
>>>
>>
>>  --
> 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/-/20YX_C3Oo3AJ.
>
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>

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



Re: Django - Worldwide Developer Rates - Hourly Income - location and project duration specific

2012-05-08 Thread Raphael
LAST CALL 2 contribution.

Hello djangos - once again:

one last call to contribute. After this message almost enough people
should have been notified about our try to collect worldwide django
development project
data to being able to publish useful statistics.

We even are going to create statistics with the rare data we already
have collected + Try to get some comparison to other well known
development territories
such as Java, Java-Spring, Web-Engineering, Programming, SAP, C#,
Server Administration... (open source and proprietary fields).

Thanks again to those willing to contribute.
We already got some good feedback - and there are people out there
looking positively into the future with the confidence that such
statistics and 
comparisons will boost the average income/hourly rates.

Contribution link: http://develissimo.com/forum/topic/107887/

Cheers,
Raphael

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



server error occurred. Please contact the administrator.

2012-05-08 Thread ritvik
Hey guys i am gettting "server error occurred.  Please contact the
administrator."this message while i am running my django
application

my application is not calling even any url   please help me out this
is my error log

Traceback (most recent call last):
  File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run
self.result = application(self.environ, self.start_response)
  File "/usr/local/lib/python2.6/dist-packages/django/contrib/
staticfiles/handlers.py", line 67, in __call__
return self.application(environ, start_response)
  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
wsgi.py", line 216, in __call__
self.load_middleware()
  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py", line 51, in load_middleware
raise exceptions.ImproperlyConfigured('Middleware module "%s" does
not define a "%s" class' % (mw_module, mw_classname))
ImproperlyConfigured: Middleware module "django.middleware.csrf" does
not define a "CsrfResponseMiddleware" class


here is my setting.py file


# Django settings for mysite1 project.
import os.path

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', 'your_em...@example.com'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '/home/rohitd/workspace/
slm_uidatabase.db',  # Or path to database file if
using sqlite3.
'USER': '',  # Not used with sqlite3.
'PASSWORD': '',  # Not used with sqlite3.
'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
}
}

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-
uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
# URL that handles the media served from MEDIA_ROOT. Make sure to use
a
# trailing slash.
# Examples: "http://media.lawrence.com/media/";, "http://example.com/
media/"
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static
files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''

# URL prefix for static files.
# Example: "http://media.lawrence.com/static/";
STATIC_URL = '/static/'

# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/";, "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/
static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)

# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)

# Make this unique, and don't share it with anybody.
SECRET_KEY = '88^$#do)us^kzil0dtm7$t_0mrppz%p+mskovdq(ww0fi4i9o2'

# List of callables that know how to import templates from various
sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)

TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.csrf',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
#'django.middleware.csrf.CsrfViewMiddleware',
#This got added to view the post, not suggestable but need to use
this.
'django.middleware.csrf.CsrfResponseMiddleware',
'djang

Re: How to use ImageField??

2012-05-08 Thread Phang Mulianto
you would use MEDIA_URL for calling the image path to be view in  your
template.

and the image will be upload to the media root folder..

On Mon, May 7, 2012 at 8:35 PM, Boris Shemigon  wrote:

> MEDIA_ROOT
>  denotes
> an absolut path where your files are going to be stored.
> MEDIA_URL
>  is
> a relative url to the website's / that handles the media.
>
> For more details please you read the official 
> documentation
> .
>
>
> On Mon, May 7, 2012 at 7:33 PM, Boris Shemigon  wrote:
>
>> MEDIA_ROOTdenotes
>>  an absolut path where your files are going to be stored.
>> MEDIA_URLis
>>  a relative url to the website's / that handles the media.
>>
>> For more details please you read the official 
>> documentation
>> .
>>
>>
>>
>> On Mon, May 7, 2012 at 7:17 PM, atul khairnar wrote:
>>
>>> Hi,
>>> I am writing this ImageViewer app, just to get involved with Django. I
>>> have used *ImageField* to store images in database. I want to load the
>>> images on the clients browser from Django server. But, I think, i can't
>>> distinguish between *media root* and *media url*. I have attached the
>>> project with the mail. Please check the code and help me out. sorry for my
>>> English.
>>>
>>> --
>>> Atul Khairnar
>>> College of Engineering , Pune
>>> Cell - (+91)9579289613
>>>
>>>
>>>  --
>>> 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: server error occurred. Please contact the administrator.

2012-05-08 Thread azizmb.in
What version of django are you using?

On Tue, May 8, 2012 at 6:11 PM, ritvik  wrote:

> Hey guys i am gettting "server error occurred.  Please contact the
> administrator."this message while i am running my django
> application
>
> my application is not calling even any url   please help me out this
> is my error log
>
> Traceback (most recent call last):
>  File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run
>self.result = application(self.environ, self.start_response)
>  File "/usr/local/lib/python2.6/dist-packages/django/contrib/
> staticfiles/handlers.py", line 67, in __call__
>return self.application(environ, start_response)
>  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> wsgi.py", line 216, in __call__
>self.load_middleware()
>  File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/
> base.py", line 51, in load_middleware
>raise exceptions.ImproperlyConfigured('Middleware module "%s" does
> not define a "%s" class' % (mw_module, mw_classname))
> ImproperlyConfigured: Middleware module "django.middleware.csrf" does
> not define a "CsrfResponseMiddleware" class
>
>
> here is my setting.py file
>
>
> # Django settings for mysite1 project.
> import os.path
>
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
>
> ADMINS = (
># ('Your Name', 'your_em...@example.com'),
> )
>
> MANAGERS = ADMINS
>
> DATABASES = {
>'default': {
>'ENGINE': 'django.db.backends.sqlite3', # Add
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
>'NAME': '/home/rohitd/workspace/
> slm_uidatabase.db',  # Or path to database file if
> using sqlite3.
>'USER': '',  # Not used with sqlite3.
>'PASSWORD': '',  # Not used with sqlite3.
>'HOST': '',  # Set to empty string for
> localhost. Not used with sqlite3.
>'PORT': '',  # Set to empty string for
> default. Not used with sqlite3.
>}
> }
>
> # Local time zone for this installation. Choices can be found here:
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
> # although not all choices may be available on all operating systems.
> # On Unix systems, a value of None will cause Django to use the same
> # timezone as the operating system.
> # If running in a Windows environment this must be set to the same as
> your
> # system time zone.
> TIME_ZONE = 'America/Chicago'
>
> # Language code for this installation. All choices can be found here:
> # http://www.i18nguy.com/unicode/language-identifiers.html
> LANGUAGE_CODE = 'en-us'
>
> SITE_ID = 1
>
> # If you set this to False, Django will make some optimizations so as
> not
> # to load the internationalization machinery.
> USE_I18N = True
>
> # If you set this to False, Django will not format dates, numbers and
> # calendars according to the current locale
> USE_L10N = True
>
> # Absolute filesystem path to the directory that will hold user-
> uploaded files.
> # Example: "/home/media/media.lawrence.com/media/"
> MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
> # URL that handles the media served from MEDIA_ROOT. Make sure to use
> a
> # trailing slash.
> # Examples: "http://media.lawrence.com/media/";, "http://example.com/
> media/ "
> MEDIA_URL = '/media/'
>
> # Absolute path to the directory static files should be collected to.
> # Don't put anything in this directory yourself; store your static
> files
> # in apps' "static/" subdirectories and in STATICFILES_DIRS.
> # Example: "/home/media/media.lawrence.com/static/"
> STATIC_ROOT = ''
>
> # URL prefix for static files.
> # Example: "http://media.lawrence.com/static/";
> STATIC_URL = '/static/'
>
> # URL prefix for admin static files -- CSS, JavaScript and images.
> # Make sure to use a trailing slash.
> # Examples: "http://foo.com/static/admin/";, "/static/admin/".
> ADMIN_MEDIA_PREFIX = '/static/admin/'
>
> # Additional locations of static files
> STATICFILES_DIRS = (
># Put strings here, like "/home/html/static" or "C:/www/django/
> static".
># Always use forward slashes, even on Windows.
># Don't forget to use absolute paths, not relative paths.
> )
>
> # List of finder classes that know how to find static files in
> # various locations.
> STATICFILES_FINDERS = (
>'django.contrib.staticfiles.finders.FileSystemFinder',
>'django.contrib.staticfiles.finders.AppDirectoriesFinder',
> #'django.contrib.staticfiles.finders.DefaultStorageFinder',
> )
>
> # Make this unique, and don't share it with anybody.
> SECRET_KEY = '88^$#do)us^kzil0dtm7$t_0mrppz%p+mskovdq(ww0fi4i9o2'
>
> # List of callables that know how to import templates from various
> sources.
> TEMPLATE_LOADERS = (
>'django.template.loaders.filesystem.Loader',
>'django.template.loaders.app_directories.Loader',
> # 'django.template.loaders.eggs.Loader',
> )
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>'django.core.context_

Re: Paramiko EOFErrors start to occur after a while

2012-05-08 Thread Kurtis Mullins
Hey,

I'd take a look at these options if you want to stick with Django-Storages
( http://django-storages.readthedocs.org/en/latest/index.html  listed on
the top of the page).

Otherwise, I wonder if you could use the hadoop fileystem or some other,
similar distributed file system built for high performance computing? I
agree though with your problems using NFS -- I've had a ton of trouble with
it in the past. It's not pleasant to work with at all.

On Tue, May 8, 2012 at 7:51 AM, Phang Mulianto  wrote:

> Hi,
>
> i also have the script to sftp using python...run with cron every 30
> mins,  and suddently since last week, the eol errors come out..
>
> i think this problem bcoz the sftp server..
>
> are you trying rsync to transfer between host ?
>
>
> On Tue, May 8, 2012 at 6:31 AM, Tino de Bruijn  wrote:
>
>> Hi,
>>
>> Unfortunatly we can't move to Amazon S3. So what other file system or
>> transfer method would you recommend? We had an NFS in place, but getting it
>> to play nice with permissions was quite a hassle.
>>
>> How do other people do this?
>>
>> Tino
>>
>>
>> On Wednesday, May 2, 2012 1:25:52 AM UTC+2, Kurtis wrote:
>>
>>> I messed with the SFTP implementatoin a while back. I noticed it was
>>> pretty tough and, if I'm not mistaken, a bit out-dated. We ended up moving
>>> to Amazon S3 so it wasn't a big deal.
>>>
>>> Anyways, maybe you could try using another file system? SSH isn't really
>>> an ideal solution for this sort of a problem -- even though it works as a
>>> great starting point.
>>>
>>> I'm not sure if that helps much but good luck to you!
>>>
>>> On Tue, May 1, 2012 at 11:49 AM, Tino de Bruijn  wrote:
>>>
 Hi,

 My setup is the following: I have two webservers that serve all dynamic
 request. I have a seperate static file server (that also has some celery
 queue workers running). When images are uploaded by users, those images are
 uploaded to the webservers, and processed async by a queue. In the job they
 are transfered to the static file server and resized. For the admin
 however, I want the transfering and resizing done right then, so that when
 admins post content, it is immediatly visible. Admins post different
 content than users, so this is implemented by using a different field on
 the models. The admin images are transfered to the static file server
 directly by using sftpstorage from django-storages.

 The problem is that paramiko (used by django-storages for the sftp
 implementation) starts to throw EOFErrors. This doesn't always happen. When
 the mod_wsgi instance is fresh, everything works, but after a while these
 errors start occurring. Touching the wsgi.py file makes everything work
 again.

 I have build a retry loop (5 times) to try to circumvent network
 glitches, but it consistently fails. If it needs to retry it'll keep
 failing.

 I have two questions:

 1) Does anybody have an idea why this could be happening?
 2) Is this the best way to implement this strategy, or would you
 suggest a different technique?

 Thanks,


 Tino

 --
 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/-/UXX_**dJrQJOwJ
 .
 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
 .

>>>
>>>  --
>> 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/-/20YX_C3Oo3AJ.
>>
>> 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

Question regarding Generic Foreign Keys and relations

2012-05-08 Thread David
I am trying to abstract a log app that I have made for my project to make 
it more DRY. In order to achieve this I have tried to implement Generic FKs

class Modification(models.Model):
content_type = models.ForeignKey(ContentType)
object_id  = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
action = models.PositiveSmallIntegerField(choices=ACTION_TYPE_CHOICES, 
db_index=True)
modifier = models.ForeignKey(User)
modified_on = models.DateTimeField(auto_now=True)

This appears to function as intended.

I also have another app that I would like to query the logs for:

class NewApp(models.Model):
prefix = models.CharField(max_length=50,choices=PREFIXES, blank=True)
first_name = models.CharField(max_length=255)
last_name = models.CharField(max_length=255)
modifications = generic.GenericRelation(Modification)

Is it possible please to query and return the relevant results from both 
models in one queryset? For example, I want to do something similar to this:

content_type = ContentType.objects.get_for_model(NewApp)
last_modified = 
Modification.objects.select_related().distinct('object_id').filter(content_type=content_type).order_by('object_id',
 
'-modified_on')

The above, doesn't, but I need to achieve the fields from NewApp as well as 
Modification.

Thank you for any assistance.

-- 
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/-/OO4VfEagK6EJ.
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 get text of a ChoiceField populated with ajax

2012-05-08 Thread francescortiz
You have to make sure that the javascript code that populates the second 
select box sets the value properly, or create a custom form validation 
(custom form/field clean methods).

On Tuesday, May 8, 2012 5:59:19 AM UTC+2, HDayi wrote:
>
> hi people, 
> i am new to all of this. 
> i have a form which has several selcet boxes. one is a 
> ModelChoiceField gets school list from database. the other is only a 
> ChoiceField and it's empty. when school   is chosen i populate the 
> ChoiceField using dajax. it works perfectly but... 
>
> while validating the form when calculating the cleaned_data value 
> returns index of the selected item and django does not validate the 
> form. 
>
> can you help me on this? 
> thx 
>

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

2012-05-08 Thread Kurtis Mullins
cleaned_data should return the value of the field, not the index. Did you
create your own clean__fieldname method?

On Tue, May 8, 2012 at 11:35 AM, francescortiz wrote:

> You have to make sure that the javascript code that populates the second
> select box sets the value properly, or create a custom form validation
> (custom form/field clean methods).
>
>
> On Tuesday, May 8, 2012 5:59:19 AM UTC+2, HDayi wrote:
>>
>> hi people,
>> i am new to all of this.
>> i have a form which has several selcet boxes. one is a
>> ModelChoiceField gets school list from database. the other is only a
>> ChoiceField and it's empty. when school   is chosen i populate the
>> ChoiceField using dajax. it works perfectly but...
>>
>> while validating the form when calculating the cleaned_data value
>> returns index of the selected item and django does not validate the
>> form.
>>
>> can you help me on this?
>> thx
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/ezZh3lD2mRcJ.
>
> 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: server error occurred. Please contact the administrator.

2012-05-08 Thread James Pyrich

CsrfResponseMiddleware was deprecated in Django 1.3, removed for 1.4.

From the 1.3 code:

DEPRECATED
Middleware that post-processes a response to add a csrfmiddlewaretoken.

This exists for backwards compatibility and as an interim measure until
applications are converted to using use the csrf_token template tag
instead. It will be removed in Django 1.4.


On 5/8/12 10:30 AM, rohit dwivedi wrote:

django 1.4.   but i don think so its version problem

On Tue, May 8, 2012 at 7:06 PM, azizmb.in  
mailto:m...@azizmb.in>> wrote:


What version of django are you using?

On Tue, May 8, 2012 at 6:11 PM, ritvik mailto:rohitdwived...@gmail.com>> wrote:

Hey guys i am gettting "server error occurred.  Please contact the
administrator."this message while i am running my django
application

my application is not calling even any url   please help me
out this
is my error log

Traceback (most recent call last):
 File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run
   self.result = application(self.environ, self.start_response)
 File "/usr/local/lib/python2.6/dist-packages/django/contrib/
staticfiles/handlers.py", line 67, in __call__
   return self.application(environ, start_response)
 File
"/usr/local/lib/python2.6/dist-packages/django/core/handlers/
wsgi.py", line 216, in __call__
   self.load_middleware()
 File
"/usr/local/lib/python2.6/dist-packages/django/core/handlers/
base.py", line 51, in load_middleware
   raise exceptions.ImproperlyConfigured('Middleware module
"%s" does
not define a "%s" class' % (mw_module, mw_classname))
ImproperlyConfigured: Middleware module
"django.middleware.csrf" does
not define a "CsrfResponseMiddleware" class


here is my setting.py file


# Django settings for mysite1 project.
import os.path

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
   # ('Your Name', 'your_em...@example.com
'),
)

MANAGERS = ADMINS

DATABASES = {
   'default': {
   'ENGINE': 'django.db.backends.sqlite3', # Add
'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or
'oracle'.
   'NAME': '/home/rohitd/workspace/
slm_uidatabase.db',  # Or path to database
file if
using sqlite3.
   'USER': '',  # Not used with sqlite3.
   'PASSWORD': '',  # Not used with sqlite3.
   'HOST': '',  # Set to empty string for
localhost. Not used with sqlite3.
   'PORT': '',  # Set to empty string for
default. Not used with sqlite3.
   }
}

# Local time zone for this installation. Choices can be found
here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating
systems.
# On Unix systems, a value of None will cause Django to use
the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the
same as
your
# system time zone.
TIME_ZONE = 'America/Chicago'

# Language code for this installation. All choices can be
found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'

SITE_ID = 1

# If you set this to False, Django will make some
optimizations so as
not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates,
numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-
uploaded files.
# Example: "/home/media/media.lawrence.com/media/
"
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media")
# URL that handles the media served from MEDIA_ROOT. Make sure
to use
a
# trailing slash.
# Examples: "http://media.lawrence.com/media/";,
"http://example.com/
media/ "
MEDIA_URL = '/media/'

# Absolute path to the directory static files should be
collected to.
# Don't put anything in this directory yourself; store your static
files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/
"
STATIC_ROOT = ''

#

Re: Upload files without form

2012-05-08 Thread kooliah

As often happens to me, things are much less complicated than i figure out

I loose hours running after UploadedFile, HttpRequest, etc.
Finally, it was my fault, a wrong path

Using os.path.join(settings.MEDIA_ROOT, 'images') create a new tree from 
static folder


Using os.path.join(settings.MEDIA_URL, 'images') return '/static/images' 
that gives error (path does not exist) while using 'static/images' it 
works now



(it's a test command, in real example i will load name from a file 
passed by args)

--
from django.core.management.base import BaseCommand, CommandError
import os

ffiles = []
ffiles.append('/mnt/hostdir/project/fotoalkatron/SNC110.jpg')
ffiles.append('/mnt/hostdir/project/fotoalkatron/SNC111.jpg')
ffiles.append('/mnt/hostdir/project/fotoalkatron/SNC112.jpg')

class Command(BaseCommand):
def handle(self, *args, **options):
_upload_img()
def _upload_img(fname):
for fpathname in ffiles:
fname = os.path.split(fpathname)[1]
_dst= os.path.join( 'static/images', fname)
myfl = open(fpathname,'r')
cntn = myfl.read()
myfl.close()
fdst = open(_dst,'wb')
fdst.write(cntn)
fdst.close()
---


On 05/08/2012 01:19 AM, kooliah wrote:

I need to upload a list of images to a project.
I've found tons of pages about how to upload a file using a 
form...(that's clearly written on django official docs) :-)


But i need to do it by a custom django-admin command because i have to 
link theese files(900) to respective records in the project


I tryed with shutil.copy too, but it copies files and immediately 
delete it. i saw them by file manager in the right folder, but after 
1-2 seconds they disappeared.


So i have a list
f[1]='/path/to/source/image1.jpg'
f[2]='/path/to/source/image2.jpg'
f[3]='/path/to/source/image3.jpg'
.
.
f[n]='/path/to/source/imagen.jpg'

and i need to upload to

os.path.join(settings.MEDIA_ROOT, 'images')

Does someone already done it WITHOUT USING FORMS, or can help me...

Thanks to all

Alkatron



--
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: server error occurred. Please contact the administrator.

2012-05-08 Thread Python_Junkie
I am not an expert on the csrf module, but the error is pointing towards 
this module.

I am using 'django.middleware.csrf.CsrfViewMiddleware', with django 1.3 and 
app is working just fine.
If I were you I would research this module in the django web page and focus 
on this module

On Tuesday, May 8, 2012 8:41:52 AM UTC-4, ritvik wrote:
>
> Hey guys i am gettting "server error occurred.  Please contact the 
> administrator."this message while i am running my django 
> application 
>
> my application is not calling even any url   please help me out this 
> is my error log 
>
> Traceback (most recent call last): 
>   File "/usr/lib/python2.6/wsgiref/handlers.py", line 93, in run 
> self.result = application(self.environ, self.start_response) 
>   File "/usr/local/lib/python2.6/dist-packages/django/contrib/ 
> staticfiles/handlers.py", line 67, in __call__ 
> return self.application(environ, start_response) 
>   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ 
> wsgi.py", line 216, in __call__ 
> self.load_middleware() 
>   File "/usr/local/lib/python2.6/dist-packages/django/core/handlers/ 
> base.py", line 51, in load_middleware 
> raise exceptions.ImproperlyConfigured('Middleware module "%s" does 
> not define a "%s" class' % (mw_module, mw_classname)) 
> ImproperlyConfigured: Middleware module "django.middleware.csrf" does 
> not define a "CsrfResponseMiddleware" class 
>
>
> here is my setting.py file 
>
>
> # Django settings for mysite1 project. 
> import os.path 
>
> DEBUG = True 
> TEMPLATE_DEBUG = DEBUG 
>
> ADMINS = ( 
> # ('Your Name', 'your_em...@example.com'), 
> ) 
>
> MANAGERS = ADMINS 
>
> DATABASES = { 
> 'default': { 
> 'ENGINE': 'django.db.backends.sqlite3', # Add 
> 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. 
> 'NAME': '/home/rohitd/workspace/ 
> slm_uidatabase.db',  # Or path to database file if 
> using sqlite3. 
> 'USER': '',  # Not used with sqlite3. 
> 'PASSWORD': '',  # Not used with sqlite3. 
> 'HOST': '',  # Set to empty string for 
> localhost. Not used with sqlite3. 
> 'PORT': '',  # Set to empty string for 
> default. Not used with sqlite3. 
> } 
> } 
>
> # Local time zone for this installation. Choices can be found here: 
> # http://en.wikipedia.org/wiki/List_of_tz_zones_by_name 
> # although not all choices may be available on all operating systems. 
> # On Unix systems, a value of None will cause Django to use the same 
> # timezone as the operating system. 
> # If running in a Windows environment this must be set to the same as 
> your 
> # system time zone. 
> TIME_ZONE = 'America/Chicago' 
>
> # Language code for this installation. All choices can be found here: 
> # http://www.i18nguy.com/unicode/language-identifiers.html 
> LANGUAGE_CODE = 'en-us' 
>
> SITE_ID = 1 
>
> # If you set this to False, Django will make some optimizations so as 
> not 
> # to load the internationalization machinery. 
> USE_I18N = True 
>
> # If you set this to False, Django will not format dates, numbers and 
> # calendars according to the current locale 
> USE_L10N = True 
>
> # Absolute filesystem path to the directory that will hold user- 
> uploaded files. 
> # Example: "/home/media/media.lawrence.com/media/" 
> MEDIA_ROOT = os.path.join(os.path.dirname(__file__), "media") 
> # URL that handles the media served from MEDIA_ROOT. Make sure to use 
> a 
> # trailing slash. 
> # Examples: "http://media.lawrence.com/media/";, "http://example.com/ 
> media/ " 
> MEDIA_URL = '/media/' 
>
> # Absolute path to the directory static files should be collected to. 
> # Don't put anything in this directory yourself; store your static 
> files 
> # in apps' "static/" subdirectories and in STATICFILES_DIRS. 
> # Example: "/home/media/media.lawrence.com/static/" 
> STATIC_ROOT = '' 
>
> # URL prefix for static files. 
> # Example: "http://media.lawrence.com/static/"; 
> STATIC_URL = '/static/' 
>
> # URL prefix for admin static files -- CSS, JavaScript and images. 
> # Make sure to use a trailing slash. 
> # Examples: "http://foo.com/static/admin/";, "/static/admin/". 
> ADMIN_MEDIA_PREFIX = '/static/admin/' 
>
> # Additional locations of static files 
> STATICFILES_DIRS = ( 
> # Put strings here, like "/home/html/static" or "C:/www/django/ 
> static". 
> # Always use forward slashes, even on Windows. 
> # Don't forget to use absolute paths, not relative paths. 
> ) 
>
> # List of finder classes that know how to find static files in 
> # various locations. 
> STATICFILES_FINDERS = ( 
> 'django.contrib.staticfiles.finders.FileSystemFinder', 
> 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 
> #'django.contrib.staticfiles.finders.DefaultStorageFinder', 
> ) 
>
> # Make this unique, and don't share it with anybody. 
> SECRET_KEY = 

Open Django Central - June 8/9

2012-05-08 Thread Steve Holden
OK, anyone want to help build the broader Django community? Open
Django Central is on June 8 and 9 - http://opendjango/central/ the
registration site is open and the hotel is taking reservations at an
amazingly low rate if you are flying in from elsewhere.

Chicago locals please note I am flying in to talk to the Chicago
Djangonauts Spring Meetup on Wednesday May 16th - they live over on
the django-chicago Google group - and hope to see you there to swell
their numbers! I'll be taking input about the event there, and will be
happy to hear your ideas to make it even better.

regards
 Steve

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



Filter by retirement age?

2012-05-08 Thread Lachlan Musicman
Hola,

I have a model Person with a dob = models.DateField()

I would like to filter by age - in particular only include people less than
60 years old.

I am having no luck getting the syntax right and was looking for pointers?

  queryset=Person.objects.filter(dob__year__gte
= datetime.datetime.today().year-61)

gets me an error like: Join on field 'dob' not permitted. Did you misspell
'year' for the lookup type?

RETIRE_Y = datetime.datetime.today().year-61
...
  queryset=Person.objects.filter(dob__gte =
datetime(RETIRE_Y,1,1,

gives me errors like: 'module' object is not callable

I don't want to create a new field or function on the Person object that
would calculate "age" everyday...

What am I doing wrong/how can I make it right?

cheers
L.

-- 
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: Filter by retirement age?

2012-05-08 Thread Nikolas Stevenson-Molnar
On your second attempt, the problem is that you are trying to call the
datetime module, not the datetime class. Change it to
datetime.datetime(...) and you should be fine there.

_Nik

On 5/8/2012 4:12 PM, Lachlan Musicman wrote:
> Hola,
>
> I have a model Person with a dob = models.DateField()
>
> I would like to filter by age - in particular only include people less
> than 60 years old.
>
> I am having no luck getting the syntax right and was looking for pointers?
>
>   queryset=Person.objects.filter(dob__year__gte
> = datetime.datetime.today().year-61)
>
> gets me an error like: Join on field 'dob' not permitted. Did you
> misspell 'year' for the lookup type?
>  
> RETIRE_Y = datetime.datetime.today().year-61
> ...
>   queryset=Person.objects.filter(dob__gte =
> datetime(RETIRE_Y,1,1,
>
> gives me errors like: 'module' object is not callable
>
> I don't want to create a new field or function on the Person object
> that would calculate "age" everyday...
>
> What am I doing wrong/how can I make it right?
>
> cheers
> L.
> -- 
> 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.



Django Comment Moderation: Anything wrong with using "moderate_after = 0"?

2012-05-08 Thread Gchorn
I'm building a simple blog with class "Post" as follows:

class Post(models.Model):
title = models.CharField(max_length=1000)
author = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
text = models.TextField(max_length=1)

I'm trying to implement the simplest possible comment form and comment 
moderation using the built-in Django comments app.  One thing I've noticed 
is that under "Built-in moderation 
options"
 
in the docs, there is no option to set the "is_public" field for all 
comments to "False" by default.  The closest thing is the 
"CommentModerator.moderate()" method listed just below under "Adding custom 
moderation methods."  Since I don't want to add any custom methods unless 
necessary just yet, is there anything wrong with simply setting 
"auto_moderate_field" to "pub_date", and then just setting "moderate_after" 
to 0?

In other words, is there anything wrong with setting the comments to be 
automatically moderated zero days after each blog post is published?  I 
want to make sure I didn't miss any potential security issues, or violate 
any general programming principles in doing so (I'm still new to 
programming in general).

thanks!
Guillaume

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



How do you write a django model that can crunch numbers and automatically populate another field with results?

2012-05-08 Thread Mika
There's a more detailed version of this question where I've embedded
graphics and explained my algorithm to make it more clear on
stackoverflow. I haven't gotten a response on it yet so I thought I
might come here and see if anyone can help me out.

http://stackoverflow.com/questions/10493279/how-do-you-write-a-django-model-that-can-automatically-normalize-data

In a nutshell, I'm putting together a music recommendation engine and
I need to store data about the different tracks in a sqlite database.
I've set it up so that you can easily add the data using the admin
interface. There's one particular piece of data for each track called
tfidf that's basically a sentiment score for the lyrics. I'm trying to
set up the model in such a way once you manually enter the tfidf value
of the track in admin, it automatically calculates a normalized value
for it. The algorithm basically just looks at the tfidf value of the
track and subtracts the smallest tfidf value of all the tracks in the
column from that. Then it divides that number by the difference of the
largest tfidf and the smallest tfidf values in the column. That gives
you a number between 0 and 1.

The problem is that django doesn't seem to have the methods that would
allow me to automatically select minimum and maximum tfidf values in a
table the way I could with SQL statements. Basically, to code this
algorithm, I need to be able to select minimum and maximum tfidf
values in a column, along with the tfidf value of the track, and then
it's just a matter of doing calculations. I'm pretty new to django and
am not fully aware of what it's capable of. The model for the table
I'm talking about is this:

class Party(models.Model):
song = models.CharField(max_length = 30)
tfidf = models.FloatField(max_length = 50)
normalized_tfidf = models.FloatField(max_length = 50)


Anybody have any idea what tools are available in django to
automatically take the tfidf data, do calculations on it, and then
automatically have the results populate the normalized_tfidf field?

thnx

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



limit row in change view

2012-05-08 Thread Nenad Cikic
Hello!
I am trying to undestand how to limit visible rows in change view. It seems 
to me a common need, but can not find info in django docs.
I am using the admin interface.
So I have one model and his admin is something as:

ordering = ('-datum','krajnjikorisnik','tipimpulse','impulsecijena')

def queryset(self, request):
   qs=super(KrajnjiKorisnikImpulseAdmin, self).queryset(request)
   qs=qs.filter(bla bla bla)
   return qs

With the queryset of above I filter just the needed rows. I have check with 
postgre log, and indeed the correct SELECT statement is generated.

Now I want to get just the top x elements.
I continue to get
   "Cannot reorder a query once a slice has been taken."
or
"Cannot filter a query once a slice has been taken."

I have tried to change my queryset function to:
1.
def queryset(self, request):
   qs=super(KrajnjiKorisnikImpulseAdmin, 
self).queryset(request)[0:2]
   qs=qs.filter(bla bla bla)
   return qs
2. i have treid to manually construct the queryset for testing purpose as:
def queryset(self, request):
   qs=KrajnjiKorisnikImpulse.objects.all()[0:2]
   return qs
and i have also commented the ordering statement

Both are giving the above errors. Is not limiting the rows a common feature 
one might want, or is not relevant since admin views have pages?

Thanks
Nenad

-- 
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/-/t0Y-wdjz4wMJ.
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 do you write a django model that can crunch numbers and automatically populate another field with results?

2012-05-08 Thread Andy McKay
You can hook into the model signal so that when the model changes, you
do you calculation and change your models.

https://docs.djangoproject.com/en/dev/ref/signals/#django.db.models.signals.post_save

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