Re: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread kamal sharma
When i try the same code from python Shell then it is working fine.

Here is the working output:
>>> import cx_Oracle
>>> from pprint import pprint
>>> connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar', 'db'))
>>> cursor = cx_Oracle.Cursor(connection)
>>> sql = "SELECT xyz FROM table_name where rownum < 10"
>>> cursor.execute(sql)
[]
>>> data = cursor.fetchall()
>>> pprint(data)
[('Robert Craig',),
 ('Darren Kerr',),
 ('Aviva Garrett',),
 ('Pasvorn Boonmark',),
 ('Dave Wittbrodt',),
 ('Pasvorn Boonmark',),
 ('Rajkumaran Chandrasekaran',),
 ('Pasvorn Boonmark',),
 ('Pasvorn Boonmark',)]


But when i use the same code in django views.py then it does not work
and Getting error as:
Exception Value:

Error while trying to retrieve text for error ORA-01804


def cases(request, db_name, prnum=None, message=''):
connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar', 'db'))
cursor = cx_Oracle.Cursor(connection)
sql = "SELECT xyz FROM table_name where rownum < 10"
cursor.execute(sql)
data = cursor.fetchall()
pprint(data)
cursor.close()
connection.close()
return render_to_response('web/cases.html', {}, RequestContext(request,
{
 'first': 'test1',
 'last': 'test2',
}))


Thanks,


On Fri, Apr 22, 2011 at 1:01 AM, Ian  wrote:

> On Apr 21, 11:03 am, kamal sharma  wrote:
> > Error while trying to retrieve text for error ORA-01804
> >
> > Here is my code to fetch the data from database.
> >
> > def cases(request, dbname, prnum=None, message=''):
> >
> > connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar',
> 'xyz'))
> > cursor = cx_Oracle.Cursor(connection)
> > sql = "SELECT fielname FROM tablename where rownum < 10"
> > cursor.execute(sql)
> > names = [row[0] for row in cursor.fetchall()]
> > cursor.close()
> > connection.close()
>
> First of all, why are you creating your own connection instead of
> using the Django ORM?
>
> Anyway, the proper way to create a cx_Oracle connection is with the
> cx_Oracle.connect factory function, and the proper way to create a
> cursor is with the connection.cursor() method.  See the cx_Oracle docs
> and the DB-API docs for details.  However, I think there is something
> more going on here.
>
> ORA-01804:  failure to initialize timezone information
> Cause:  The timezone information file was not properly read.
> Action: Please contact Oracle Customer Support.
>
> This and the fact that cx_Oracle wasn't able to look up the error code
> itself suggest that there may be something wrong with your Oracle
> client installation.  Or it may be that your webserver is also
> blocking access to the files in the client directory.  What happens if
> you try the same code from a Python shell?
>
> --
> 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: bound form with ModelChoiceField

2011-04-21 Thread Andy McKay

On 2011-04-21, at 4:07 PM, ekms wrote:
> So, what is the correct way to create a bound form of
> ModelChoiceField? I  could store request.POST or myform.data instead
> of myform.cleaned_data, but I don't know if this is right.

You are confusing me when you say a bound form of a ModelChoiceField. Since one 
is a form and one is a field. You can create a ModelForm given a Model and its 
instance or primary key as outlined here: 

http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#modelform
--
  Andy McKay
  a...@clearwind.ca
  twitter: @andymckay
 

-- 
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: Using auth.login() with multiple databases

2011-04-21 Thread Andy McKay

On 2011-04-21, at 6:30 PM, Lawrence wrote:

> 4. Add a custom login() method to my custom authentication backend?
> This sounds like an option I could undertake but I'm unsure of the
> syntax to select the appropriate database and perform all of the
> required login features like saving the User ID to the session, etc.

I would do this. Find some appropriate way of storing your database as a string 
and then do a lookup on get_user to use that. I wouldn't worry too much about 
what's there, just write something for your particular use case. 

Presumably you also have another user database where you can store data 
particular to you application such as session and profiles since your other 
databases sound immutable?
--
  Andy McKay
  a...@clearwind.ca
  twitter: @andymckay
 

-- 
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 ORM question about lookups that span relationships

2011-04-21 Thread Oleg Lomaka
Blog.objects.filter(entry__pub_date__lte=date(2011, 4, 1),
  entry__headline__contains='Easter
').latest('pub_date')

Or

Blog.objects.filter(entry__pub_date__lte=date(2011, 4, 1),
  entry__headline__contains='Easter
').order_by('-pub_date')[0]

On Thu, Apr 21, 2011 at 10:25 PM, Carsten Fuchs wrote:

>
> I'm currently reading <
> http://docs.djangoproject.com/en/1.3/topics/db/queries/#lookups-that-span-relationships
> >.
>
> What I seem to understand is how I can find all blogs that have entries
> that
>- where published *sometime* before or at April 1st,
>- and have the word "Easter" in the headline:
>
> Blog.objects.filter(entry__pub_date__lte=date(2011, 4, 1),
> entry__headline__contains='Lennon')
>
>
> What I'm wondering about is how I can find blogs whose *most recent* entry
> before or at April 1st has the word "Easter" in the headline.
>
> Can this be expressed with the Django ORM? How?
>
>

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread Oleg Lomaka
On Fri, Apr 22, 2011 at 1:20 AM, octopusgrabbus
wrote:

> Here is the pertinent code:
>
> def reconcile_inv(request):
>errors = []
>cs_list = []
>return_dc = {}
> cs_hold_rec_count = 0
> try:
>   cs_hold_rec_count = CsInvHold.objects.count()
>qs = CsInvHold.objects.filter(inventory_ok=0)
>   if qs:
>   cs_list.append(['','Customer Synch Data On Hold Due To
> Missing From AMR Inventory', ''])
>   cs_list.append(['PremiseID', 'Endpoint ID', 'Date
> Entered'])
>
>   for each_q in qs:
>   cs_list.append([str(each_q.premiseid),
> int(each_q.endpointid), str(each_q.last_update)])
>
> except ObjectDoesNotExist:
>   cs_hold_rec_count = 0
>
> My understanding is this line of code -- qs =
> CsInvHold.objects.filter(inventory_ok=0) -- should return a query set.
> It seems to return a CsInvHold object reference. Why does that happen?
>

As nobody can understand what do you mean by this, I'll ask another
question. How do you know this is the object reference? What is the
statement, that identified this for you?

As to returning a list instead of queryset, you can use list comprehension
to create a list you need. For example, if you need a list of IDs and
last_updates from your queryset, you can write:

ids_list = [(o.id, o.last_update) for o in qs]

Or you can do just qs.values('id', 'last_update'), which will return a list
of dictionaries in form {'id": 1, 'last_update': datetime(2011, 01, 01)}

Also take a look at values_list() method of QuerySet.
http://docs.djangoproject.com/en/dev/ref/models/querysets/#values
http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-list

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



Looking for an awesome Python Developer as well as a Tester.

2011-04-21 Thread Jerimiah - New Market Lab
Hello,

New Market Lab has a couple of contract job opportunities for work on
an application that we are developing for our client, Envision
Telepharmacy ( www.envision-rx.com). We are producing a telepharmacy
application that enables a pharmacist to work with multiple hospitals
over the internet. We have some exciting projects that are listed
below.

If you are interested or know anyone who would be a good fit, please
have them send their resume and a 2 paragraph description of a project
that they are proud of to j...@newmarketlab.com.

Thank you,
Jerimiah Welch
--
Director - New Market Design Lab

-

Web Application Developer(s)

Position Summary

Work with other developers, embedded systems programmers, and UI
designers to integrate better functionality into our web application.
Research and evaluate fax and bar-coding enhancements, integrate
diverse databases, integrate video streaming, and develop reporting
and help functionality.

Telepharmacy helps hospitals increase patient safety and lower costs
by sharing a pharmacist over the internet. Our rapidly-growing company
is at the leading edge of Telepharmacy user experience and we love
what we do. Come join a focused and motivated group of people to
develop a system that saves money and lives! This is a full-time
contractor position and we believe in telecommuting.

 We are looking for someone who has successfully completed projects in
some or all of the following areas (See details below). All of these
areas involve research and cooperation, so we need someone who can
take initiative to pick up the phone and cooperate with diverse
groups.

* Database mining and report generation
* Server-side graphics generation
* Image-based barcode recognition
* Fax – IP integration
* HL7 database integration
* NDC database integration
* Secure video streaming
*Android application development

We think that the person who would be successful in this role would
be:

* Proficient as a "full stack" web developer
* Experienced with a RDBMS, query tuning, server-based performance
tweaking - PostgreSQL preferred.
* Experience with SOLR/Lucene
* Proficient with Python and a python-based MVC web framework (Django
preferably)
* Proficient in Core Javascript, jQuery, experience with Comet/long-
polling is a plus
* Understanding of Linux systems optimization. Apache experience a
major plus
* Experienced in Multiple programming languages

--

Web Application and Accessory Hardware Tester

Position Summary

Envision Telepharmacy is looking for a Superstar Software tester with
Web application and Hardware driver testing expertise. This is a
contract position that involves working with people in design,
development, and deployment departments to test improvements to our
enterprise-level web application and hardware accessories. Envision
develops Telepharmacy software that helps hospitals increase patient
safety and lower costs by supporting remote telepharmacist
supervision. We are a rapidly growing company at the leading edge of
Telepharmacy user experience and we love what we do. Come join a
focused and motivated group of people to ensure software system
reliability and save lives!

Performance Objectives

1.  Organize and manage the testing process. Translate our existing
feature test list into a clear testing plan that covers a variety of
Windows-based Network environments, Operating Systems, and Browser
configurations. (WinXP, Win7 - IE7, IE8 -  64 & 32 bit) On a regular
basis, clearly communicate with the team about the state of the
testing plan. Evaluate the feature set and create time estimates. Work
with the project manager to update and maintain an accurate project
schedule. Work with IT support staff at Envision to segment and
delegate testing responsibility.  Use browser-based automated testing
tools to automate redundant and regressive tasks.

2.  Ensure high reliability, security, and uptime for our web
application through systematic testing. Systematically test the Web
application and associated hardware to ensure functionality across
platforms.  Ensure HIPAA compliance by imaginatively testing for
security holes. Test for uptime reliability and ensure scalability by
simulating heavy use loads. Analyze Server Capabilities. Set up server
tracking logs to test server hardware bottlenecks. Set up network
traffic tracking logs.

3.  Clearly communicate with the UI designers and developers to
understand the desired functionality. Help to anticipate and resolve
edge cases. Use clear and frequent communication to overcome the
challenges of working remotely with a team spread across the country.

4.  Create succinct and clear bug reports. Create great bug reports

Re: ModelForm unbound

2011-04-21 Thread Constantine
Let me show example

on form i have two coerced fieds (ModelChoiceField)
queryset for second field based on first

so, using simpleform i can modify second queryset using
firstfield_clean
but using modelform i should do it twise:
in init for form instantiation and in field_clean for save
what about DRY?

> which presumably are already valid,
> otherwise they should not have been saved

db essentials could be invalid if there hard validation logic exists

On Apr 21, 7:35 pm, Daniel Roseman  wrote:
> On Thursday, April 21, 2011 8:16:36 AM UTC+1, Constantine wrote:
>
> > Hi
>
> > i've used some logic in clean_field methods, but when i've migrated to
> > ModelForm, was very surprised that clean methods does not invoked
> > after some investigation i realized that model instane does not makes
> > modelform bound automatically
>
> > i'm expect that model validation also triggered as pointed here
>
> >http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-is-...
> > but models.py contradicts
> >     def is_valid(self):
> >         """
> >         Returns True if the form has no errors. Otherwise, False. If
> > errors are
> >         being ignored, returns False.
> >         """
> >         return self.is_bound and not bool(self.errors)
>
> > model with instance only WILL NOT trigger validation
>
> I'm not sure why that would surprise you, or why you would want it to work
> any other way. Form validation is for validating user input, not for
> checking already-saved instances (which presumably are already valid,
> otherwise they should not have been saved).
> --
> DR.

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



Using auth.login() with multiple databases

2011-04-21 Thread Lawrence
We have multiple databases for authentication. Basically one database
per department. Before the obvious question is asked, I cannot merge
nor sync the various databases into one Django managed admin database.
The database schema cannot change and I am hoping I can work around
this in Django code.

For example purposes let's say our databases are: 'sales', 'support'
and 'engineering'. The users on each database are unique and we cannot
sync the databases.

I have setup settings.py to include a dictionary for all database
connections:

DATABASES = {
'default': {
STANDARD DB CONNECTION DETAILS
},
'sales_users': {
STANDARD DB CONNECTION DETAILS
},
'support_users': {
STANDARD DB CONNECTION DETAILS
},
'engineering_users': {
STANDARD DB CONNECTION DETAILS
},

I have a custom login form that includes an additional field over the
standard form username and password. The additional field is
'department'.

On the login form, I am capturing the department, username and
password.

I have also written a custom authentication backend to handle the
additional field for authentication. The custom authenticate method
takes the following arguments: self, email, password and db_to_use.

The custom authentication backend authenticate method does the
following:

def authenticate(self, username=None, password=None, db_to_use=None,
**kwargs):
user = User.objects.using(db_to_use).get(username=username)
if user.check_password(password):
return user
return None

Up to this point everything works as expected. If on the login form a
user submits the following:

Department: sales
Username: User1
Password: Password

My login view will collect the POST values and then pass to:

user = auth.authenticate(username=username, password=password,
db_to_use=dbalias)

I am able to confirm that this this successfully returns the user
object from the custom authentication backend. This would have queried
the appropriate database based on the department entered
('sales_users') and returned the user object.

The next part is where I'm having issue.

After successfully returning an authenticated user object (and making
sure that the user isn't None and isn't inactive), I then call the
auth.login(request, user) method.

However, I'm finding that auth.login() is failing because auth.login()
is then using the 'default' database rather than the 'sales_users'
database connection as per the example above. This results in the user
never seeming to get "logged in". I'm not sure how to "persist" the
use of the appropriate database after the authenticate() call and into
the login() call.

I've looked at the Django source and it seems that the
django.contrib.auth.login() method is supposed to save the
BACKEND_SESSION_KEY but I'm not sure how this relates to the login()
method using the database that was specified in my custom
authentication backend.

I've gone through the Multiple Database documentation and am not sure
what to try next. My thoughts are:

1. Implement a routing system, but I'm not sure how that applies to
the login issue I am experiencing.

2. Implement a database manager, but again I'm not sure how this
applies to the login issue I am experiencing.

3. Edit ModelAdmin to expose multiple databases to Django's admin
interface. I'm also unsure as to this option since I'm not using the
admin interface but just need a way to force the login() method to use
a difference database.

4. Add a custom login() method to my custom authentication backend?
This sounds like an option I could undertake but I'm unsure of the
syntax to select the appropriate database and perform all of the
required login features like saving the User ID to the session, etc.

If anyone has any hints, tips or insights into the problem I have I
would really appreciate it!

Thanks,

Lawrence.


-- 
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: Extremely Frustrated

2011-04-21 Thread Kenny Meyer
Can you give us the following information:
 - Django version installed on your system
 - Full tracebacks, not just what type of Exception has been thrown.

Please?

Kenny



On Thu, Apr 21, 2011 at 4:00 PM, Gandeida  wrote:
> Hello,
>
> I have been working through the Django Book, and I keep getting syntax
> errors in the examples in Chapter 6.
>
> The following example works:
>
> class BookAdmin(admin.ModelAdmin):
>    list_display = ('title', 'publisher', 'publication_date')
>    list_filter = ('publication_date',)
>    date_hierarchy = 'publication_date'
>    ordering = ('-publication_date',)
>    fields = ('title', 'authors', 'publisher', 'publication_date')
>
> The next one, however, does not - it throws a syntax error:
>
> class BookAdmin(admin.ModelAdmin):
>    list_display = ('title', 'publisher', 'publication_date')
>    list_filter = ('publication_date',)
>    date_hierarchy = 'publication_date'
>    ordering = ('-publication_date',)
>    fields = ('title', 'authors', 'publisher')
>
> Nor can I add fields back in to this example or I get a syntax error:
>
> class BookAdmin(admin.ModelAdmin):
>    list_display = ('title', 'publisher', 'publication_date')
>    list_filter = ('publication_date',)
>    date_hierarchy = 'publication_date'
>    ordering = ('-publication_date',)
>    filter_horizontal = ('authors',)
>    (would like to still define fields, but throws a syntax error)
>
> Same with this one:
>
> class BookAdmin(admin.ModelAdmin):
>    list_display = ('title', 'publisher', 'publication_date')
>    list_filter = ('publication_date',)
>    date_hierarchy = 'publication_date'
>    ordering = ('-publication_date',)
>    filter_horizontal = ('authors',)
>    raw_id_fields = ('publisher',)
>    (would like to still define fields, but throws a syntax error)
>
>
> Could someone please show me how to include "fields = ('title',
> 'authors', 'publisher')" without getting an error?
>
> Thanks,
> Gandeida
>
> --
> 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: The import staticfiles_urlpatterns is not working in django 1.3

2011-04-21 Thread Ernesto Guevara
Hello Brian!
This right, in fact that word "import" I inadvertently pasted, but the
import does not work.

from django.contrib.staticfiles.urls import staticfiles_urlpatterns

The problem was that when doing the import, it does not appear available by
pressing ctrl + backspace in Eclipse, that is, the import does not exist.

In fact, not need it, and even configure the urls.py.
With the configuration that I have informed the css work

Thanks!


2011/4/21 Brian Neal 

> On Apr 21, 12:48 pm, Guevara  wrote:
> > Hello!
> > My project is failing to import the staticfiles_urlpatterns, using
> > Eclipse Helios:
> >
> > urls.py
> >
> > import from django.contrib.staticfiles.urls staticfiles_urlpatterns
> >
> > In django 1.3 I already have:
> >
> > INSTALLED_APPS = (
> > 'django.contrib.staticfiles'
> > )
> >
> > In the folder:
> > / usr/local/lib/python2.6/dist-packages/django/contrib/staticfiles
> >
> > Why do not you think the staticfiles_urlpatterns?
> >
> > Thanks!
>
> Please post your code and the exact error. For one thing, your import
> statement isn't valid Python. It should be:
>
> from django.contrib.staticfiles.urls import staticfiles_urlpatterns
>
> Best,
> BN
>
> --
> 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: two similar ways to show data, but only one working

2011-04-21 Thread Michael
2011/4/22 W Craig Trader  only matches upper and lower case letters.
>
> - Craig -
>

Hi Craig,
Sorry for this confusion, my hostnames only contains letters,
i should have copy/pasted my url instead writing this example...
-> so the problem still exists.

-- 
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: The import staticfiles_urlpatterns is not working in django 1.3

2011-04-21 Thread Brian Neal
On Apr 21, 12:48 pm, Guevara  wrote:
> Hello!
> My project is failing to import the staticfiles_urlpatterns, using
> Eclipse Helios:
>
> urls.py
>
> import from django.contrib.staticfiles.urls staticfiles_urlpatterns
>
> In django 1.3 I already have:
>
> INSTALLED_APPS = (
> 'django.contrib.staticfiles'
> )
>
> In the folder:
> / usr/local/lib/python2.6/dist-packages/django/contrib/staticfiles
>
> Why do not you think the staticfiles_urlpatterns?
>
> Thanks!

Please post your code and the exact error. For one thing, your import
statement isn't valid Python. It should be:

from django.contrib.staticfiles.urls import staticfiles_urlpatterns

Best,
BN

-- 
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: The import staticfiles_urlpatterns is not working in django 1.3

2011-04-21 Thread Guevara
The problem was the documentation, the manual of utilization says one
thing, but the Contrib documentation says another, I follow contrib
doc:

This is the configuration that worked:

settings.py


STATIC_ROOT = ''
STATIC_URL = '/static/'

STATICFILES_DIRS = (
 "/home/guevara/workspace/imobiliaria/static",
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
)

And call CSS in base.html:



Thanks!




On 21 abr, 14:48, Guevara  wrote:
> Hello!
> My project is failing to import the staticfiles_urlpatterns, using
> Eclipse Helios:
>
> urls.py
>
> import from django.contrib.staticfiles.urls staticfiles_urlpatterns
>
> In django 1.3 I already have:
>
> INSTALLED_APPS = (
> 'django.contrib.staticfiles'
> )
>
> In the folder:
> / usr/local/lib/python2.6/dist-packages/django/contrib/staticfiles
>
> Why do not you think the staticfiles_urlpatterns?
>
> 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: two similar ways to show data, but only one working

2011-04-21 Thread W Craig Trader

On 04/21/2011 05:08 PM, Michael wrote:

I try to do the same with
http://127.0.0.1:8000/host/hostname1
to print every package that is installed on hostname1


urls.py
---
[...]
 (r'^host/(?P[a-zA-Z]+)$', 'packages.views.host'),
[]



For starters, the pattern you've registered won't match 'hostname1' since it only matches upper and 
lower case letters.


- Craig -

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



bound form with ModelChoiceField

2011-04-21 Thread ekms
Hello,

I have a form with a ModelChoiceField, and when I want to create a new
bound form using the first form cleaned_data (that I stored in a
session before), I get an error when rendering the template ("Caught
TypeError while rendering: int() argument must be a string or a
number").
This is because  ModelChoiceField cleaned_data normalizes to an
object, not to the id of the object, (id that is the expected int).

So, what is the correct way to create a bound form of
ModelChoiceField? I  could store request.POST or myform.data instead
of myform.cleaned_data, but I don't know if this is right.

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



two similar ways to show data, but only one working

2011-04-21 Thread Michael
Hi,

I`m new to Django and I`m trying to write an application "packages" that reads 
data
from a mysql-database and prints the installed software for any hostname.

For example:
http://127.0.0.1:8000/package/mutt
prints every host on which the package "mutt" is installed. 
This works without errors.

I try to do the same with 
http://127.0.0.1:8000/host/hostname1
to print every package that is installed on hostname1

However, the only thing i see is the empty template -> the object_list seems to
contain no entries.

I don`t understand this because the two ways to call the functions seems so 
similar.
(see my application below).

What I`m missing here?



models.py
-
class Prog(models.Model):
hostname = models.CharField(max_length=20)
status = models.CharField(max_length=2)
name = models.CharField(max_length=50)
version = models.CharField(max_length=50)
description = models.TextField()
def __unicode__(self):
return self.name

urls.py
---
[...]
(r'^host/(?P[a-zA-Z]+)$', 'packages.views.host'),
(r'^packages/(?P[a-zA-Z0-9_.-]+)$', 'packages.views.package'),
[]

views.py

def host(request, host):
package_list = Dpkg.objects.filter(hostname=host)
return render_to_response('host/detail.html', { 'package_list ' : 
package_list})

def package(request, package):   
package_list = Dpkg.objects.filter(name=package).order_by('-version')
return render_to_response('packages/detail.html', {'package_list': 
package_list})


In both templates is the same code:

{% for package in package_list %}
{{ package.hostname }} {{ package.name }} {{ package.version }}
{% endfor %}


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.



annotate() for subgroups within a column

2011-04-21 Thread Ariana
Hi everyone,

I'm brand-new to Django so this may be a noob question; however, I've
been stuck on this one query for a couple of days now and can't seem
to reach a solution. I'm working with a model called Update, which
represents an update to a user's score in a match. I am trying to
return the most recent score for each user in a given match. Here's my
Update class:

class Update(models.Model):
   updater = models.ForeignKey(User, related_name='updaterUser')
   updatee = models.ForeignKey(User, related_name='updateeUser')
   match = models.ForeignKey(Match)
   createdOn = models.DateTimeField(auto_now_add=True)
   lastUpdated = models.DateTimeField(auto_now=True,auto_now_add=True)
   isLatest = models.BooleanField()
   score = models.IntegerField()

   def __unicode__(self):
  return 'Update to %s: %s updated %s at %s' % (self.match.name,
self.updater, self.updatee, self.lastUpdated)

and here is the view where I am trying to fetch the correct data:

def matchDetail(request, match_id):
   m = get_object_or_404(Match, id=match_id)
   matchUpdates = Update.objects.filter(match=m)
   u = matchUpdates.order_by('-lastUpdated')
   s =
matchUpdates.filter(pk__in=(matchUpdates.values('updatee').annotate(Max('pk'
   return render_to_response('match.html', {'match': m, 'updates': u,
'scores': s})

Basically what I need to do is return one row for each updatee where
lastUpdated is highest for that particular updatee. I tried a few
different things for s. First I tried annotating the updatees with the
highest lastUpdated datetime:

s = matchUpdates.values('updatee').annotate(Max('lastUpdated'))

This returned the correct results, but was useless, because I need to
return the whole row, not just the values for updatee. Adding other
columns to values() resulted in incorrect results, because annotate
looks at all columns, and I need it to look at updatee only. Then I
tried annotating within a subquery, which I thought would work for
sure:

s =
matchUpdates.filter(pk__in=(matchUpdates.values('updatee').annotate(Max('pk'

but it threw me an error: "Caught DatabaseError while rendering: only
a single result allowed for a SELECT that is part of an expression." I
can't really find documentation on this error, but as far as I can
tell, it's an issue with sqlite and not with Django.

If it helps at all, this could be accomplished with the following SQL:

SELECT updatee, score, id
   FROM Update
   WHERE lastUpdated = (
   SELECT max(lastUpdated)
   FROM Update as u
   WHERE u.updatee = Update.updatee)

I am really stumped on how to accomplish this in Django, and would
prefer not to use raw SQL if I can help it. Can anyone point me in the
right direction?

Thanks very much for your help.
-A

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



Extremely Frustrated

2011-04-21 Thread Gandeida
Hello,

I have been working through the Django Book, and I keep getting syntax
errors in the examples in Chapter 6.

The following example works:

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

The next one, however, does not - it throws a syntax error:

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

Nor can I add fields back in to this example or I get a syntax error:

class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'publisher', 'publication_date')
list_filter = ('publication_date',)
date_hierarchy = 'publication_date'
ordering = ('-publication_date',)
filter_horizontal = ('authors',)
(would like to still define fields, but throws a syntax error)

Same with this one:

class BookAdmin(admin.ModelAdmin):
list_display = ('title', 'publisher', 'publication_date')
list_filter = ('publication_date',)
date_hierarchy = 'publication_date'
ordering = ('-publication_date',)
filter_horizontal = ('authors',)
raw_id_fields = ('publisher',)
(would like to still define fields, but throws a syntax error)


Could someone please show me how to include "fields = ('title',
'authors', 'publisher')" without getting an error?

Thanks,
Gandeida

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread Javier Guerra Giraldez
On Thu, Apr 21, 2011 at 5:20 PM, octopusgrabbus
 wrote:
> It seems to return a CsInvHold object reference.

you still don't show why you think that's happening.  what tests have
you done?  what do you mean by "it seems to"?

-- 
Javier

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



Re: django advent for 1.3

2011-04-21 Thread flowpoke
PURE WIN, Idan.

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread octopusgrabbus
Here is the pertinent code:

def reconcile_inv(request):
errors = []
cs_list = []
return_dc = {}
cs_hold_rec_count = 0
try:
   cs_hold_rec_count = CsInvHold.objects.count()
   qs = CsInvHold.objects.filter(inventory_ok=0)
   if qs:
   cs_list.append(['','Customer Synch Data On Hold Due To
Missing From AMR Inventory', ''])
   cs_list.append(['PremiseID', 'Endpoint ID', 'Date
Entered'])

   for each_q in qs:
   cs_list.append([str(each_q.premiseid),
int(each_q.endpointid), str(each_q.last_update)])

except ObjectDoesNotExist:
   cs_hold_rec_count = 0

My understanding is this line of code -- qs =
CsInvHold.objects.filter(inventory_ok=0) -- should return a query set.
It seems to return a CsInvHold object reference. Why does that happen?

Given that I have a CsInvHold object reference, is there a way to get
a list of the values, instead of explicitly pulling them out in these
lines?

   for each_q in qs:
   cs_list.append([str(each_q.premiseid),
int(each_q.endpointid), str(each_q.last_update)])

This has nothing to do with the function being called. I'm asking 1
about the documentation and 2 about a possible method in the Django
model that would return a list.


On Apr 21, 12:37 pm, octopusgrabbus  wrote:
> Here is my model (shortened for brevity). It was generated by
> inspectdb. I am running Django 1.2 with mod_wsgi, on Ubuntu 10.04 and
> apache2.
>
> class CsInvHold(models.Model):
>     action = models.CharField(max_length=3, db_column='Action',
> blank=True) # Field name made lowercase.
> .
> .
> .
>     inventory_ok = models.IntegerField(null=True, blank=True)
>     last_update = models.DateTimeField()
>     class Meta:
>         db_table = u'cs_inv_hold'
>
> This is from my views.py,
>
>     try:
>        cs_hold_rec_count = CsInvHold.objects.count()
>        cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)
>
>     except ObjectDoesNotExist:
>        cs_hold_rec_count = 0
>
>     if request.method == 'POST':
>         if 0 == cs_hold_rec_count:
>             errors.append('There are no customer synch records on
> hold.')
>         else:
>             rc = sendCsHoldRpt(cs_hold_rec_list)
>             if 1 == rc:
>                 errors.append('There were no recipients defined for
> the report.')
>
>     return_dc['errors'] = errors
>     return_dc['cs_hold_rec_count'] = cs_hold_rec_count
>
>     return render_to_response('reconcile_inv.html', return_dc,
> context_instance=RequestContext(request))
>
> The .count() function works perfectly. What am I doing wrong to get an
> object instance instead of the list?
> Thank you.

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread Ramiro Morales
On Thu, Apr 21, 2011 at 1:37 PM, octopusgrabbus
 wrote:
> [...]
>
>    try:
>       cs_hold_rec_count = CsInvHold.objects.count()
>       cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)
>
>    except ObjectDoesNotExist:
>       cs_hold_rec_count = 0
>
>    if request.method == 'POST':
>        if 0 == cs_hold_rec_count:
>            errors.append('There are no customer synch records on
> hold.')
>        else:
>            rc = sendCsHoldRpt(cs_hold_rec_list)

You don't tell us where and how does the behavior of filter()
you claim happens shows itself. e.g. an exception or error that
says ' I expect a queryset here and I got a model instance' .

Maybe it is in your sendCsHoldRpt() function? But you don't
share code tracebacks or debug output. You keep adding
unrelated leads and findings but haven't correctly described
your initial problem. This doesn't make it easy to try to help you.

Also, neither .count() nor .filter() raise ObjectDoesNotExist
so that try/catch block isn´t necessary. .filter() returns
and empty queryset if no model instance matches its
criteria. Maybe the problem is related to that and you are
mis-diagnosing it?

-- 
Ramiro Morales

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread octopusgrabbus
I've asked two questions:

1) Why do I get back an Object reference, when the docs say it's a
query set?
2) How can I dump that object's values into a list instead of
iterating each column?


On Apr 21, 5:06 pm, Daniel Roseman  wrote:
> On Thursday, April 21, 2011 9:17:54 PM UTC+1, octopusgrabbus wrote:
>
> > I posted in the original problem.
> > cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)
>
> How is that a problem? What's wrong with it?
>
>
>
> > Right now, I can get what I need by doing this:
>
> >       qs = CsInvHold.objects.filter(inventory_ok=0)
> >        if qs:
> >            cs_list.append(['','Customer Synch Data On Hold Due To
> > Missing From AMR Inventory', ''])
> >            cs_list.append(['PremiseID', 'Endpoint ID', 'Date
> > Entered'])
>
> >            for each_q in qs:
> >                cs_list.append([str(each_q.premiseid),
> > int(each_q.endpointid), str(each_q.last_update)])
>
> > I want to get the entire result set without iteration through the
> > columns.
>
> What does that mean?
> You iterate through the members of the queryset, not the columns. Then you
> append a list consisting of various elements from each field in that member.
> What is wrong with this? What do you actually want to achieve and in what
> way does this not fulfill your requirement?
>
> > In addition from what I read in the documentation, I was supposed to
> > get a QuerySet returned on a filter, not a model object reference.
> > I'm not sure why this is happening.
>
> Why *what* is happening?

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread Daniel Roseman
On Thursday, April 21, 2011 9:17:54 PM UTC+1, octopusgrabbus wrote:
>
> I posted in the original problem. 
> cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0) 
>

How is that a problem? What's wrong with it? 
 

> Right now, I can get what I need by doing this: 
>
>   qs = CsInvHold.objects.filter(inventory_ok=0) 
>if qs: 
>cs_list.append(['','Customer Synch Data On Hold Due To 
> Missing From AMR Inventory', '']) 
>cs_list.append(['PremiseID', 'Endpoint ID', 'Date 
> Entered']) 
>
>for each_q in qs: 
>cs_list.append([str(each_q.premiseid), 
> int(each_q.endpointid), str(each_q.last_update)]) 
>
> I want to get the entire result set without iteration through the 
> columns. 
>

What does that mean?
You iterate through the members of the queryset, not the columns. Then you 
append a list consisting of various elements from each field in that member. 
What is wrong with this? What do you actually want to achieve and in what 
way does this not fulfill your requirement? 
 

> In addition from what I read in the documentation, I was supposed to 
> get a QuerySet returned on a filter, not a model object reference. 
> I'm not sure why this is happening. 


Why *what* is happening? 

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread octopusgrabbus
I posted in the original problem.
cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)

Right now, I can get what I need by doing this:

  qs = CsInvHold.objects.filter(inventory_ok=0)
   if qs:
   cs_list.append(['','Customer Synch Data On Hold Due To
Missing From AMR Inventory', ''])
   cs_list.append(['PremiseID', 'Endpoint ID', 'Date
Entered'])

   for each_q in qs:
   cs_list.append([str(each_q.premiseid),
int(each_q.endpointid), str(each_q.last_update)])

I want to get the entire result set without iteration through the
columns.

In addition from what I read in the documentation, I was supposed to
get a QuerySet returned on a filter, not a model object reference.
I'm not sure why this is happening.



On Apr 21, 3:08 pm, Daniel Roseman  wrote:
> On Thursday, April 21, 2011 7:52:02 PM UTC+1, octopusgrabbus wrote:
>
> > I have been able to narrow my question down. I can pull individual
> > columns from the returned model object reference. How can I get all
> > those columns in a list. Wrapping in a list() function returns an
> > error object is not iterable error.
>
> > After four messages from you in this thread, it is still not at all clear
>
> where your problem is. What function? What list? What error? Where?
> --
> DR.

-- 
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: Is the initial value of a form field available in the template?

2011-04-21 Thread Sarang
This works:

form.initial.fieldname

-- 
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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread Ian
On Apr 21, 11:03 am, kamal sharma  wrote:
> Error while trying to retrieve text for error ORA-01804
>
> Here is my code to fetch the data from database.
>
> def cases(request, dbname, prnum=None, message=''):
>
>     connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar', 'xyz'))
>     cursor = cx_Oracle.Cursor(connection)
>     sql = "SELECT fielname FROM tablename where rownum < 10"
>     cursor.execute(sql)
>     names = [row[0] for row in cursor.fetchall()]
>     cursor.close()
>     connection.close()

First of all, why are you creating your own connection instead of
using the Django ORM?

Anyway, the proper way to create a cx_Oracle connection is with the
cx_Oracle.connect factory function, and the proper way to create a
cursor is with the connection.cursor() method.  See the cx_Oracle docs
and the DB-API docs for details.  However, I think there is something
more going on here.

ORA-01804:  failure to initialize timezone information
Cause:  The timezone information file was not properly read.
Action: Please contact Oracle Customer Support.

This and the fact that cx_Oracle wasn't able to look up the error code
itself suggest that there may be something wrong with your Oracle
client installation.  Or it may be that your webserver is also
blocking access to the files in the client directory.  What happens if
you try the same code from a Python shell?

-- 
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 ORM question about lookups that span relationships

2011-04-21 Thread Carsten Fuchs

Hi all,

I'm currently reading 
.


What I seem to understand is how I can find all blogs that have entries that
- where published *sometime* before or at April 1st,
- and have the word "Easter" in the headline:

Blog.objects.filter(entry__pub_date__lte=date(2011, 4, 1), 
entry__headline__contains='Lennon')



What I'm wondering about is how I can find blogs whose *most recent* 
entry before or at April 1st has the word "Easter" in the headline.


Can this be expressed with the Django ORM? How?

I'd be very grateful for advice.

Many thanks and best regards,
Carsten




--
   Cafu - the open-source Game and Graphics Engine
for multiplayer, cross-platform, real-time 3D Action
  Learn more at http://www.cafu.de



smime.p7s
Description: S/MIME Cryptographic Signature


Re: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread Daniel Roseman
On Thursday, April 21, 2011 7:52:02 PM UTC+1, octopusgrabbus wrote:
>
> I have been able to narrow my question down. I can pull individual 
> columns from the returned model object reference. How can I get all 
> those columns in a list. Wrapping in a list() function returns an 
> error object is not iterable error. 
>
> After four messages from you in this thread, it is still not at all clear 
where your problem is. What function? What list? What error? Where?
--
DR. 

-- 
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: filtering drop downs according to logged in user

2011-04-21 Thread Dan Gentry
I have set the choices list in the view:

choices =
SomeModel.objects.filter(user=request.user).values_list('id','label')

Then, after the form is instantiated, modify the choices attribute of
the ChoiceField:

form = SomeOtherModelForm()
form.fields['model_dropdown'].choices = choices

Works in a similar fashion with a ModelChoiceField and the queryset
attribute.

On Apr 21, 10:10 am, "Szabo, Patrick \(LNG-VIE\)"
 wrote:
> Hi,
>
> I want to filter the dropdownlists that are automatically used to select
> a foreign-key in forms (in my views).
>
> Normally that could easily be done with "class Meta" in the Modelform.
>
> Thing is i want to filter by an attribute of the current
> userspecificly the groups that the user is assigned to.
>
> So how do i do that ?!
>
> Can i acces request.user in the models somehow ?!
>
> Kind regards
>
> . . . . . . . . . . . . . . . . . . . . . . . . . .
> Patrick Szabo
>  XSLT Developer
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> mailto:patrick.sz...@lexisnexis.at
> Tel.: +43 (1) 534 52 - 1573
> Fax: +43 (1) 534 52 - 146

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread octopusgrabbus
I have been able to narrow my question down. I can pull individual
columns from the returned model object reference. How can I get all
those columns in a list. Wrapping in a list() function returns an
error object is not iterable error.

On Apr 21, 12:37 pm, octopusgrabbus  wrote:
> Here is my model (shortened for brevity). It was generated by
> inspectdb. I am running Django 1.2 with mod_wsgi, on Ubuntu 10.04 and
> apache2.
>
> class CsInvHold(models.Model):
>     action = models.CharField(max_length=3, db_column='Action',
> blank=True) # Field name made lowercase.
> .
> .
> .
>     inventory_ok = models.IntegerField(null=True, blank=True)
>     last_update = models.DateTimeField()
>     class Meta:
>         db_table = u'cs_inv_hold'
>
> This is from my views.py,
>
>     try:
>        cs_hold_rec_count = CsInvHold.objects.count()
>        cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)
>
>     except ObjectDoesNotExist:
>        cs_hold_rec_count = 0
>
>     if request.method == 'POST':
>         if 0 == cs_hold_rec_count:
>             errors.append('There are no customer synch records on
> hold.')
>         else:
>             rc = sendCsHoldRpt(cs_hold_rec_list)
>             if 1 == rc:
>                 errors.append('There were no recipients defined for
> the report.')
>
>     return_dc['errors'] = errors
>     return_dc['cs_hold_rec_count'] = cs_hold_rec_count
>
>     return render_to_response('reconcile_inv.html', return_dc,
> context_instance=RequestContext(request))
>
> The .count() function works perfectly. What am I doing wrong to get an
> object instance instead of the list?
> Thank you.

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread octopusgrabbus
I've also added this to force the QuerySet to evaluate, and I'm still
getting the object reference:

   for list_element in CsInvHold.objects.filter(inventory_ok=0):
   cs_list.append(list_element)



On Apr 21, 12:37 pm, octopusgrabbus  wrote:
> Here is my model (shortened for brevity). It was generated by
> inspectdb. I am running Django 1.2 with mod_wsgi, on Ubuntu 10.04 and
> apache2.
>
> class CsInvHold(models.Model):
>     action = models.CharField(max_length=3, db_column='Action',
> blank=True) # Field name made lowercase.
> .
> .
> .
>     inventory_ok = models.IntegerField(null=True, blank=True)
>     last_update = models.DateTimeField()
>     class Meta:
>         db_table = u'cs_inv_hold'
>
> This is from my views.py,
>
>     try:
>        cs_hold_rec_count = CsInvHold.objects.count()
>        cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)
>
>     except ObjectDoesNotExist:
>        cs_hold_rec_count = 0
>
>     if request.method == 'POST':
>         if 0 == cs_hold_rec_count:
>             errors.append('There are no customer synch records on
> hold.')
>         else:
>             rc = sendCsHoldRpt(cs_hold_rec_list)
>             if 1 == rc:
>                 errors.append('There were no recipients defined for
> the report.')
>
>     return_dc['errors'] = errors
>     return_dc['cs_hold_rec_count'] = cs_hold_rec_count
>
>     return render_to_response('reconcile_inv.html', return_dc,
> context_instance=RequestContext(request))
>
> The .count() function works perfectly. What am I doing wrong to get an
> object instance instead of the list?
> Thank you.

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



Running Django tests from Python

2011-04-21 Thread Shawn Milochik
I want to use pyinotify[1] to monitor my project directory and run my
unit tests whenever I save a .py file.

The monitoring part is working. All I need now is to know how to call
the tests from my "watcher" script.

As noted in the docs[2], I'm already running  setup_test_environment()
in my script.

Now, how do I do the equivalent of the following from within my Python script?
python manage.py test myapp1 myapp2

[1] https://github.com/seb-m/pyinotify
[2] 
http://docs.djangoproject.com/en/1.3/topics/testing/#running-tests-outside-the-test-runner

Thanks,
Shawn

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



The import staticfiles_urlpatterns is not working in django 1.3

2011-04-21 Thread Guevara
Hello!
My project is failing to import the staticfiles_urlpatterns, using
Eclipse Helios:

urls.py

import from django.contrib.staticfiles.urls staticfiles_urlpatterns

In django 1.3 I already have:

INSTALLED_APPS = (
'django.contrib.staticfiles'
)

In the folder:
/ usr/local/lib/python2.6/dist-packages/django/contrib/staticfiles

Why do not you think the staticfiles_urlpatterns?

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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread kamal sharma
Thanks a lot. Now that issue is resolved after i execute below command.

sudo ln -s /opt/app/oracle/products/11.2.0/lib/libclntsh.so.11.1

But now i am getting databse error. Any pointer please?

Exception Value:

Error while trying to retrieve text for error ORA-01804


Here is my code to fetch the data from database.

def cases(request, dbname, prnum=None, message=''):

connection = cx_Oracle.Connection("%s/%s@%s" % ('foo', 'bar', 'xyz'))
cursor = cx_Oracle.Cursor(connection)
sql = "SELECT fielname FROM tablename where rownum < 10"
cursor.execute(sql)
names = [row[0] for row in cursor.fetchall()]
cursor.close()
connection.close()

Thanks,
Kamal

On Thu, Apr 21, 2011 at 9:31 PM, kamal sharma wrote:

> After creating soft link, still it is giving the same error. Do i need to
> create soft link for any other files? My response are inline with KS:
>
> On Thu, Apr 21, 2011 at 9:21 PM, Ian  wrote:
>
>> On Apr 21, 9:39 am, kamal sharma  wrote:
>> > Here is the error I am getting now:
>> >
>> > cd /usr/local/lib
>> >
>> > /usr/local/lib> sudo ln
>> > /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
>> > ln: ./libclntsh.so.10.1 is on a different file system
>> >
>> > /usr/local/lib> cd /usr/lib/
>> > /usr/lib> sudo ln /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
>> > ln: ./libclntsh.so.10.1 is on a different file system
>>
>> Right, it's not possible to create hard links across file systems.
>> Create a soft link instead using "ln -s" (soft links are usually
>> preferable anyway).
>>
>
> KS: Ok i have created soft link and it is fine.
>  sudo ln -s /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
>
>>
>> > Also set this in .cshrc file
>> >
>> > setenv LD_LIBRARY_PATH "$ORACLE_HOME/lib32:$ORACLE_HOME/lib"
>> > setenv LD_LIBRARY_PATH /usr/X11R6/lib:/usr/local/lib
>> >
>> > echo $LD_LIBRARY_PATH
>> > /usr/X11R6/lib:/usr/local/lib
>> > echo $ORACLE_HOME/
>> > /opt/app/oracle/products/11.2.0/
>>
>> Is this in your .cshrc file or the WSGI user's .cshrc?  And are you
>> sure it's using csh and not bash?
>>
>
> KS: Yes it  .cshrc file.
>
>>
>> --
>>
>> 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: filtering drop downs according to logged in user

2011-04-21 Thread Cal Leeming [Simplicity Media Ltd]
Completely off topic but, what exactly does an "XSLT Developer" do?

On Thu, Apr 21, 2011 at 3:10 PM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:

>  Hi,
>
>
>
> I want to filter the dropdownlists that are automatically used to select a
> foreign-key in forms (in my views).
>
> Normally that could easily be done with „class Meta“ in the Modelform.
>
> Thing is i want to filter by an attribute of the current user….specificly
> the groups that the user is assigned to.
>
>
>
> So how do i do that ?!
>
> Can i acces request.user in the models somehow ?!
>
>
>
> Kind regards
>
>  . . . . . . . . . . . . . . . . . . . . . . . . . .
>
>  **
>
> Patrick Szabo
> XSLT Developer
>
> LexisNexis
> Marxergasse 25, 1030 Wien
>
> patrick.sz...@lexisnexis.at
>
> Tel.: +43 (1) 534 52 - 1573
>
> Fax: +43 (1) 534 52 - 146
>
>
>
>  --
> 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: filtering drop downs according to logged in user

2011-04-21 Thread Oleg Lomaka
As an option, you can pass a request.user to form's __init__ method from
your view. Example:

class YourForm(forms.ModelForm):
def __init__(self, user, *args, **kwargs):
self.user = user
super(YourForm, self).__init__(*args, **kwargs)
# here you can modify any self.fields depends on your user

in view
def your_view(request):
form = YourForm(request.user, request.POST)

On Thu, Apr 21, 2011 at 5:10 PM, Szabo, Patrick (LNG-VIE) <
patrick.sz...@lexisnexis.at> wrote:

>  Hi,
>
>
>
> I want to filter the dropdownlists that are automatically used to select a
> foreign-key in forms (in my views).
>
> Normally that could easily be done with „class Meta“ in the Modelform.
>
> Thing is i want to filter by an attribute of the current user….specificly
> the groups that the user is assigned to.
>
>
>
> So how do i do that ?!
>
> Can i acces request.user in the models somehow ?!
>
>
>

-- 
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: Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread octopusgrabbus
BTW: I had already noticed the mention that QuerySets are lazy here
http://docs.djangoproject.com/en/1.2/topics/db/queries/#field-lookups,
but how to I cause the query set to access the database. A print isn't
going to help me when I want to send a list to a function that will
write it into a file.

On Apr 21, 12:37 pm, octopusgrabbus  wrote:
> Here is my model (shortened for brevity). It was generated by
> inspectdb. I am running Django 1.2 with mod_wsgi, on Ubuntu 10.04 and
> apache2.
>
> class CsInvHold(models.Model):
>     action = models.CharField(max_length=3, db_column='Action',
> blank=True) # Field name made lowercase.
> .
> .
> .
>     inventory_ok = models.IntegerField(null=True, blank=True)
>     last_update = models.DateTimeField()
>     class Meta:
>         db_table = u'cs_inv_hold'
>
> This is from my views.py,
>
>     try:
>        cs_hold_rec_count = CsInvHold.objects.count()
>        cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)
>
>     except ObjectDoesNotExist:
>        cs_hold_rec_count = 0
>
>     if request.method == 'POST':
>         if 0 == cs_hold_rec_count:
>             errors.append('There are no customer synch records on
> hold.')
>         else:
>             rc = sendCsHoldRpt(cs_hold_rec_list)
>             if 1 == rc:
>                 errors.append('There were no recipients defined for
> the report.')
>
>     return_dc['errors'] = errors
>     return_dc['cs_hold_rec_count'] = cs_hold_rec_count
>
>     return render_to_response('reconcile_inv.html', return_dc,
> context_instance=RequestContext(request))
>
> The .count() function works perfectly. What am I doing wrong to get an
> object instance instead of the list?
> Thank you.

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



Why Django Model Filter Returns Model Object Instance Instead of QuerySet?

2011-04-21 Thread octopusgrabbus
Here is my model (shortened for brevity). It was generated by
inspectdb. I am running Django 1.2 with mod_wsgi, on Ubuntu 10.04 and
apache2.

class CsInvHold(models.Model):
action = models.CharField(max_length=3, db_column='Action',
blank=True) # Field name made lowercase.
.
.
.
inventory_ok = models.IntegerField(null=True, blank=True)
last_update = models.DateTimeField()
class Meta:
db_table = u'cs_inv_hold'

This is from my views.py,

try:
   cs_hold_rec_count = CsInvHold.objects.count()
   cs_hold_rec_list = CsInvHold.objects.filter(inventory_ok=0)

except ObjectDoesNotExist:
   cs_hold_rec_count = 0

if request.method == 'POST':
if 0 == cs_hold_rec_count:
errors.append('There are no customer synch records on
hold.')
else:
rc = sendCsHoldRpt(cs_hold_rec_list)
if 1 == rc:
errors.append('There were no recipients defined for
the report.')

return_dc['errors'] = errors
return_dc['cs_hold_rec_count'] = cs_hold_rec_count

return render_to_response('reconcile_inv.html', return_dc,
context_instance=RequestContext(request))

The .count() function works perfectly. What am I doing wrong to get an
object instance instead of the list?
Thank you.

-- 
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: object with version

2011-04-21 Thread Oleg Lomaka
Take a look at django-reversion

On Thu, Apr 21, 2011 at 5:43 PM, Brian Craft wrote:

> I need to create objects with version tracking, a bit like wiki
> content. Anyone done this in django?
>
> I could create a model with a content field and a version field. But
> I'm not sure how to query (for example) all the latest versions of a
> set of objects. I'm sure there's a raw sql method via joins, but is
> that the best way in 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-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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread kamal sharma
After creating soft link, still it is giving the same error. Do i need to
create soft link for any other files? My response are inline with KS:

On Thu, Apr 21, 2011 at 9:21 PM, Ian  wrote:

> On Apr 21, 9:39 am, kamal sharma  wrote:
> > Here is the error I am getting now:
> >
> > cd /usr/local/lib
> >
> > /usr/local/lib> sudo ln
> > /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
> > ln: ./libclntsh.so.10.1 is on a different file system
> >
> > /usr/local/lib> cd /usr/lib/
> > /usr/lib> sudo ln /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
> > ln: ./libclntsh.so.10.1 is on a different file system
>
> Right, it's not possible to create hard links across file systems.
> Create a soft link instead using "ln -s" (soft links are usually
> preferable anyway).
>

KS: Ok i have created soft link and it is fine.
 sudo ln -s /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1

>
> > Also set this in .cshrc file
> >
> > setenv LD_LIBRARY_PATH "$ORACLE_HOME/lib32:$ORACLE_HOME/lib"
> > setenv LD_LIBRARY_PATH /usr/X11R6/lib:/usr/local/lib
> >
> > echo $LD_LIBRARY_PATH
> > /usr/X11R6/lib:/usr/local/lib
> > echo $ORACLE_HOME/
> > /opt/app/oracle/products/11.2.0/
>
> Is this in your .cshrc file or the WSGI user's .cshrc?  And are you
> sure it's using csh and not bash?
>

KS: Yes it  .cshrc file.

>
> --
> 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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread Ian
On Apr 21, 9:39 am, kamal sharma  wrote:
> Here is the error I am getting now:
>
> cd /usr/local/lib
>
> /usr/local/lib> sudo ln
> /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
> ln: ./libclntsh.so.10.1 is on a different file system
>
> /usr/local/lib> cd /usr/lib/
> /usr/lib> sudo ln /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
> ln: ./libclntsh.so.10.1 is on a different file system

Right, it's not possible to create hard links across file systems.
Create a soft link instead using "ln -s" (soft links are usually
preferable anyway).

> Also set this in .cshrc file
>
> setenv LD_LIBRARY_PATH "$ORACLE_HOME/lib32:$ORACLE_HOME/lib"
> setenv LD_LIBRARY_PATH /usr/X11R6/lib:/usr/local/lib
>
> echo $LD_LIBRARY_PATH
> /usr/X11R6/lib:/usr/local/lib
> echo $ORACLE_HOME/
> /opt/app/oracle/products/11.2.0/

Is this in your .cshrc file or the WSGI user's .cshrc?  And are you
sure it's using csh and not bash?

-- 
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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread kamal sharma
Here is the error I am getting now:

cd /usr/local/lib

/usr/local/lib> sudo ln
/opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
ln: ./libclntsh.so.10.1 is on a different file system

/usr/local/lib> cd /usr/lib/
/usr/lib> sudo ln /opt/app/oracle/products/11.2.0/lib/libclntsh.so.10.1
ln: ./libclntsh.so.10.1 is on a different file system

Also set this in .cshrc file

setenv LD_LIBRARY_PATH "$ORACLE_HOME/lib32:$ORACLE_HOME/lib"
setenv LD_LIBRARY_PATH /usr/X11R6/lib:/usr/local/lib

echo $LD_LIBRARY_PATH
/usr/X11R6/lib:/usr/local/lib
echo $ORACLE_HOME/
/opt/app/oracle/products/11.2.0/


Thanks

On Thu, Apr 21, 2011 at 8:23 PM, brad  wrote:

> This may be related to Oracle's shared libraries not being in the path
> recognized by your web server. I created hard links to the Oracle shared
> libraries in /user/local/lib to get cx_oracle working.
>
> I have a blog post that outlines what I did, here:
> http://bradmontgomery.net/blog/gahhh-django-virtualenv-and-cx_oracle/
>
> The comment by Graham Dumpleton is worth reading, as he mentions a few
> other techniques to make this work.
>
> --
> 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: Formset and Choices with Objects

2011-04-21 Thread Shawn Milochik
For the first question, you can use the form's 'instance' property to
access the underlying model instance.

For the latter, it sounds like you just need to concatenate the stuff
you display.

-- 
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 build a social network

2011-04-21 Thread shacker
On Apr 20, 4:23 pm, Rodrigo Ruiz  wrote:
> Hi, I'm a new programmer and I want to make a social network like
> facebook or orkut.

"social network" is a pretty vague term. I think you need to define
the list of actual features you want the site to have and  how they
should operate (after you learn web development and Django basics, of
course). Start by defining criteria for behaviors like:

- Is all content public unless explicitly marked private? If  so, you
would need a mechanism for testing the permissions of any given user
to view any given piece of content.

- Can any user "follow" any other user? Does the followee need to
grant permission before the follow relationship is established? What
happens when you follow someone? Do you get emails about their content
updates?

- Can users "tag" each other?  What is the mechanism for tagging? How
do you parse content fields for these tags? Does this fire a signal
that sends an email?

And so on. Be as specific as possible at the outset so you know what
you're actually building. Get clear in your head about how data is
modeled, how tables (classes) will relate to one another. Figure out
which parts of the site you can build with 3rd party reusable apps
(such as django-registration and django-profiles) and which you'll
need to build yourself. Start by building out the data model and
testing relations in the admin, and go from there.

Django is an awesome choice. Here's the social network I built in
Django: http://bucketlist.org/

Scot


-- 
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: Formset and Choices with Objects

2011-04-21 Thread Dan Gentry
I should have included that my desire is to access these objects in
the template.

On Apr 21, 11:22 am, Dan Gentry  wrote:
> I'm trying to use a formset to display a variable number of detail
> rows on a form.  It's what they were created for, right?
>
> However, in order to display more detail in each row, I'd like to have
> access to the object behind it - to reference columns not displayed,
> follow foreign key relationships, etc., but I can't see how to do it.
> Any advice?
>
> On the same form, I'd like a similar functionality for the choices in
> a series of radio buttons.  The choices attribute only accepts a list
> of two values - index and label.  The design calls for several pieces
> of data (date, time, location) and the radio button in a tabular
> format.  Any thoughts here?
>
> Thanks for pondering my questions.
>
> Dan Gentry

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



Formset and Choices with Objects

2011-04-21 Thread Dan Gentry
I'm trying to use a formset to display a variable number of detail
rows on a form.  It's what they were created for, right?

However, in order to display more detail in each row, I'd like to have
access to the object behind it - to reference columns not displayed,
follow foreign key relationships, etc., but I can't see how to do it.
Any advice?

On the same form, I'd like a similar functionality for the choices in
a series of radio buttons.  The choices attribute only accepts a list
of two values - index and label.  The design calls for several pieces
of data (date, time, location) and the radio button in a tabular
format.  Any thoughts here?

Thanks for pondering my questions.

Dan Gentry

-- 
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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread brad
This may be related to Oracle's shared libraries not being in the path 
recognized by your web server. I created hard links to the Oracle shared 
libraries in /user/local/lib to get cx_oracle working.

I have a blog post that outlines what I did, here:
http://bradmontgomery.net/blog/gahhh-django-virtualenv-and-cx_oracle/

The comment by Graham Dumpleton is worth reading, as he mentions a few other 
techniques to make this work.

-- 
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: Banners and Ads managment

2011-04-21 Thread Alex s
Thank you Bartek.

And what about Ads management ?
Regards
Alex

2011/4/21 Bartek Górny 

> On Wed, 20 Apr 2011 22:52:39 -0300
> Alex s  wrote:
>
> > Hi people
> >
> > Have anyone some experience to explain about use a django app for
> > Banners managment ?
> >
> > Thanks
> > Alex
> >
>
> I use this: https://bitbucket.org/bartekgorny/djbanner
>
> Bartek
>
> --
> "Jeśli boli cię gardło, ciesz się że nie jesteś żyrafą
> (zauważone w aptece)
>
> --
> 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.



object with version

2011-04-21 Thread Brian Craft
I need to create objects with version tracking, a bit like wiki
content. Anyone done this in django?

I could create a model with a content field and a version field. But
I'm not sure how to query (for example) all the latest versions of a
set of objects. I'm sure there's a raw sql method via joins, but is
that the best way in 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-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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread kamal sharma
Thanks David for quick response. I have already tried that option, but it
does not work.

Here is the diff which i have added.


Index: app.wsgi
===
+os.environ["LD_LIBRARY_PATH"] = "/opt/app/oracle/products/11.2.0/lib"

 # figure out where on disk this gnatatui install is hiding
 base_path = __file__.split('/web/app.wsgi')[0]

Am i missing something?

Thanks,
Kamal

On Thu, Apr 21, 2011 at 4:27 PM, David Markey  wrote:

> At the top of the WSGI script, set the LD_LIBRARY_PATH environment
> variable.
>
>
> On 21 April 2011 11:07, kamalp.sha...@gmail.com 
> wrote:
>
>> Hi,
>>
>> I have installed cx_Oracle module in one of my Solaris box and then
>> trying to create a django page to read data from oracle db. But I am
>> getting following errors.
>>
>>
>> mod_wsgi (pid=2600): Exception occurred processing WSGI script '/opt/
>> www/ui/foo/web/app.wsgi'.
>> Traceback (most recent call last):
>> File "/opt/www/ui/foo/web/app.wsgi", line 30, in application
>> return _application(environ, start_response)
>> File "/usr/local/packages/python/2.6.6/lib/python2.6/site-packages/
>> django/core/handlers/wsgi.py", line 230, in __call__
>> self.load_middleware()
>> File "/usr/local/packages/python/2.6.6/lib/python2.6/site-packages/
>> django/core/handlers/base.py", line 42, in load_middleware
>> raise exceptions.ImproperlyConfigured('Error importing middleware %s:
>> "%s"' % (mw_module, e))
>> ImproperlyConfigured: Error importing middleware web.web.framework:
>> "ld.so.1: httpd: fatal: libclntsh.so.11.1: open failed: No such file
>> or directory"
>>
>>
>> I have tried from python shell and i can able to import cx_Oracle
>> module as follows:
>>
>> bash-3.00$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
>> bash-3.00$ python
>> Python 2.4.4 (#1, Jan 10 2007, 01:25:01) [C] on sunos5
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> import cx_Oracle
>> >>>
>>
>> But from the web I am getting the ImproperlyConfigured: configured
>> error. Can someone please help me to resolve this issue.
>>
>> FYI,
>>
>> I have followed this link to install cx_oracle module.
>>
>> http://agiletesting.blogspot.com/2005/05/installing-and-using-cxoracle-on-unix.html
>>
>> Please let me know if you need more info.
>>
>> Thanks,
>> Kamal
>>
>> --
>> 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: escaping metacharacter in url pattern

2011-04-21 Thread Raúl Cumplido
sorry copy error:

*u*rl(r'^cgi-bin/DocDB/ShowDocument\$',
'docDB.views.retrieveDocumentVersion'),

2011/4/21 Raúl Cumplido 

> Hi,
>
> That data is not part of the path they are part of the querystring. It
> would be better to set your urls.py as:
>
> rl(r'^cgi-bin/DocDB/ShowDocument\$',
> 'docDB.views.retrieveDocumentVersion'),
>
> And retrieve values in your view as:
>
> request.GET.get('docid', '')
> and
> request.GET.get('version', '')
>
> Look at the documentation here:
>
>
> http://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.QueryDict
>
> Raúl
>
>
>
> On Thu, Apr 21, 2011 at 3:59 PM, Michel30  wrote:
>
>> Hey guy's,
>>
>> I'm trying to replicate behaviour of a legacy CMS and stick it into a
>> new Django project.
>>
>> Here is an example of my url:
>>
>> http://hostname:port/cgi-bin/DocDB/ShowDocument?docid=19530=1
>>
>> I want to filter the docid and version with a regex in a urlpattern to
>> use later in a function:
>>
>>url(r'^cgi-bin/DocDB/ShowDocument\?docid=(?P\d+)\?
>> version=(?P\d+)', 'docDB.views.retrieveDocumentVersion'),
>>
>> I've tried about every way of escaping the '? ' but can't get it to
>> work...
>>
>> Any ideas anyone?
>>
>> 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.
>>
>>
>
>
> --
> Raúl Cumplido
>



-- 
Raúl Cumplido

-- 
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: escaping metacharacter in url pattern

2011-04-21 Thread Raúl Cumplido
Hi,

That data is not part of the path they are part of the querystring. It would
be better to set your urls.py as:

rl(r'^cgi-bin/DocDB/ShowDocument\$', 'docDB.views.retrieveDocumentVersion'),

And retrieve values in your view as:

request.GET.get('docid', '')
and
request.GET.get('version', '')

Look at the documentation here:

http://docs.djangoproject.com/en/1.3/ref/request-response/#django.http.QueryDict

Raúl


On Thu, Apr 21, 2011 at 3:59 PM, Michel30  wrote:

> Hey guy's,
>
> I'm trying to replicate behaviour of a legacy CMS and stick it into a
> new Django project.
>
> Here is an example of my url:
>
> http://hostname:port/cgi-bin/DocDB/ShowDocument?docid=19530=1
>
> I want to filter the docid and version with a regex in a urlpattern to
> use later in a function:
>
>url(r'^cgi-bin/DocDB/ShowDocument\?docid=(?P\d+)\?
> version=(?P\d+)', 'docDB.views.retrieveDocumentVersion'),
>
> I've tried about every way of escaping the '? ' but can't get it to
> work...
>
> Any ideas anyone?
>
> 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.
>
>


-- 
Raúl Cumplido

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



filtering drop downs according to logged in user

2011-04-21 Thread Szabo, Patrick (LNG-VIE)
Hi, 

 

I want to filter the dropdownlists that are automatically used to select
a foreign-key in forms (in my views).

Normally that could easily be done with "class Meta" in the Modelform.

Thing is i want to filter by an attribute of the current
userspecificly the groups that the user is assigned to.

 

So how do i do that ?!

Can i acces request.user in the models somehow ?!

 

Kind regards


. . . . . . . . . . . . . . . . . . . . . . . . . .
Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: +43 (1) 534 52 - 1573 
Fax: +43 (1) 534 52 - 146 





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



escaping metacharacter in url pattern

2011-04-21 Thread Michel30
Hey guy's,

I'm trying to replicate behaviour of a legacy CMS and stick it into a
new Django project.

Here is an example of my url:

http://hostname:port/cgi-bin/DocDB/ShowDocument?docid=19530=1

I want to filter the docid and version with a regex in a urlpattern to
use later in a function:

url(r'^cgi-bin/DocDB/ShowDocument\?docid=(?P\d+)\?
version=(?P\d+)', 'docDB.views.retrieveDocumentVersion'),

I've tried about every way of escaping the '? ' but can't get it to
work...

Any ideas anyone?

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: ModelForm unbound

2011-04-21 Thread Daniel Roseman


On Thursday, April 21, 2011 8:16:36 AM UTC+1, Constantine wrote:
>
> Hi 
>
> i've used some logic in clean_field methods, but when i've migrated to 
> ModelForm, was very surprised that clean methods does not invoked 
> after some investigation i realized that model instane does not makes 
> modelform bound automatically 
>
> i'm expect that model validation also triggered as pointed here 
>
> http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-is-valid-method-and-errors
>  
> but models.py contradicts 
> def is_valid(self): 
> """ 
> Returns True if the form has no errors. Otherwise, False. If 
> errors are 
> being ignored, returns False. 
> """ 
> return self.is_bound and not bool(self.errors) 
>
> model with instance only WILL NOT trigger validation 
>


I'm not sure why that would surprise you, or why you would want it to work 
any other way. Form validation is for validating user input, not for 
checking already-saved instances (which presumably are already valid, 
otherwise they should not have been saved).
--
DR.

-- 
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: cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread David Markey
At the top of the WSGI script, set the LD_LIBRARY_PATH environment variable.

On 21 April 2011 11:07, kamalp.sha...@gmail.com wrote:

> Hi,
>
> I have installed cx_Oracle module in one of my Solaris box and then
> trying to create a django page to read data from oracle db. But I am
> getting following errors.
>
>
> mod_wsgi (pid=2600): Exception occurred processing WSGI script '/opt/
> www/ui/foo/web/app.wsgi'.
> Traceback (most recent call last):
> File "/opt/www/ui/foo/web/app.wsgi", line 30, in application
> return _application(environ, start_response)
> File "/usr/local/packages/python/2.6.6/lib/python2.6/site-packages/
> django/core/handlers/wsgi.py", line 230, in __call__
> self.load_middleware()
> File "/usr/local/packages/python/2.6.6/lib/python2.6/site-packages/
> django/core/handlers/base.py", line 42, in load_middleware
> raise exceptions.ImproperlyConfigured('Error importing middleware %s:
> "%s"' % (mw_module, e))
> ImproperlyConfigured: Error importing middleware web.web.framework:
> "ld.so.1: httpd: fatal: libclntsh.so.11.1: open failed: No such file
> or directory"
>
>
> I have tried from python shell and i can able to import cx_Oracle
> module as follows:
>
> bash-3.00$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
> bash-3.00$ python
> Python 2.4.4 (#1, Jan 10 2007, 01:25:01) [C] on sunos5
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import cx_Oracle
> >>>
>
> But from the web I am getting the ImproperlyConfigured: configured
> error. Can someone please help me to resolve this issue.
>
> FYI,
>
> I have followed this link to install cx_oracle module.
>
> http://agiletesting.blogspot.com/2005/05/installing-and-using-cxoracle-on-unix.html
>
> Please let me know if you need more info.
>
> Thanks,
> Kamal
>
> --
> 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.



cx_Oracle error: ImproperlyConfigured

2011-04-21 Thread kamalp.sha...@gmail.com
Hi,

I have installed cx_Oracle module in one of my Solaris box and then
trying to create a django page to read data from oracle db. But I am
getting following errors.


mod_wsgi (pid=2600): Exception occurred processing WSGI script '/opt/
www/ui/foo/web/app.wsgi'.
Traceback (most recent call last):
File "/opt/www/ui/foo/web/app.wsgi", line 30, in application
return _application(environ, start_response)
File "/usr/local/packages/python/2.6.6/lib/python2.6/site-packages/
django/core/handlers/wsgi.py", line 230, in __call__
self.load_middleware()
File "/usr/local/packages/python/2.6.6/lib/python2.6/site-packages/
django/core/handlers/base.py", line 42, in load_middleware
raise exceptions.ImproperlyConfigured('Error importing middleware %s:
"%s"' % (mw_module, e))
ImproperlyConfigured: Error importing middleware web.web.framework:
"ld.so.1: httpd: fatal: libclntsh.so.11.1: open failed: No such file
or directory"


I have tried from python shell and i can able to import cx_Oracle
module as follows:

bash-3.00$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib
bash-3.00$ python
Python 2.4.4 (#1, Jan 10 2007, 01:25:01) [C] on sunos5
Type "help", "copyright", "credits" or "license" for more information.
>>> import cx_Oracle
>>>

But from the web I am getting the ImproperlyConfigured: configured
error. Can someone please help me to resolve this issue.

FYI,

I have followed this link to install cx_oracle module.
http://agiletesting.blogspot.com/2005/05/installing-and-using-cxoracle-on-unix.html

Please let me know if you need more info.

Thanks,
Kamal

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



ModelForm unbound

2011-04-21 Thread Constantine
Hi

i've used some logic in clean_field methods, but when i've migrated to
ModelForm, was very surprised that clean methods does not invoked
after some investigation i realized that model instane does not makes
modelform bound automatically

i'm expect that model validation also triggered as pointed here
http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#the-is-valid-method-and-errors
but models.py contradicts
def is_valid(self):
"""
Returns True if the form has no errors. Otherwise, False. If
errors are
being ignored, returns False.
"""
return self.is_bound and not bool(self.errors)

model with instance only WILL NOT trigger validation

-- 
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: Banners managment

2011-04-21 Thread Bartek Górny
On Wed, 20 Apr 2011 22:52:39 -0300
Alex s  wrote:

> Hi people
> 
> Have anyone some experience to explain about use a django app for
> Banners managment ?
> 
> Thanks
> Alex
> 

I use this: https://bitbucket.org/bartekgorny/djbanner

Bartek

-- 
"Jeśli boli cię gardło, ciesz się że nie jesteś żyrafą
(zauważone w aptece)

-- 
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 call user-defined database functions through the Django query syntax?

2011-04-21 Thread Riccardo Vianello
Hi Andrew,

On Thu, Apr 21, 2011 at 7:59 AM, Andrew Dalke  wrote:
> I must say that I looked at the code with some dismay. Not because of
> the code, but because it looks like it's a *lot* of work to handle
> UDFs. I had hoped it would be much easier.

I'm sure the code could be simplified and polished (and there are some
parts that I know to require some substantial rework).. now that I
have a working prototype and I spent some time reading the sources I
was just about to start asking some more specific question on the
list, but my impression was that if explicit support for this kind of
specializations already existed, then django-gis would have used that.

>> Depending on your plans, it
>> would be interesting if we could collaborate on this.
>
> [...]
>
> So yes, I'm interested (though I would implement a comparable OEChem
> back-end), but no, it's not going to be in the next few months.

Sounds fine, I will also be attending EuroPython next June, so at the
latest we might have a chance to talk again about this on that
occasion.

Cheers,
Riccardo

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