Re: How to add a ManyToManyField "dynamically" to a model?

2011-12-22 Thread Hanne Moa
On 20 December 2011 19:07, huseyin yilmaz  wrote:
> Generic forign key might help you

I want to avoid Generic Foreign Keys as I don't like them much,
philosophically speaking. I want something that is easier to work with
from the SQL side of things.


HM

-- 
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: forms.CharField() remove text

2011-12-22 Thread Timothy Makobu
Also, I just found out from here
https://docs.djangoproject.com/en/1.3/topics/forms/ that i can just:

{{form.field_name}}

which makes things even more flexible.


2011/12/22 Timothy Makobu 

> Fantastic. Thanks Amao.
>
>
> 2011/12/22 Branton Davis 
>
>> AmaoZhao's answer is probably the best.  You can also try:
>>
>> class PostForm(forms.Form):
>> post = forms.CharField(label='', help_text=None, max_length=160,
>>  widget=forms.Textarea(attrs={'rows':3, "cols":70,}))
>>
>> The auto_id parameter only controls whether label tags and id attributes
>> are rendered (based on the field name):
>> https://docs.djangoproject.com/en/dev/ref/forms/api/#configuring-html-label-tags
>>
>>
>>
>> On Wed, Dec 21, 2011 at 11:20 PM, AmaoZhao  wrote:
>>
>>>  于 2011年12月22日 06:04, Timothy Makobu 写道:
>>>
>>> ow do I get rid of the "Post:
>>>
>>> The template render the form is {{field.label}} and {{field}}, you only
>>> need to display {{filed}}, for example:
>>>
>>> {% for field in form %}
>>> {{field}}
>>> {% endfor %}
>>>
>>> Hope this can help 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.
>>>
>>
>>  --
>> 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: forms.CharField() remove text

2011-12-22 Thread Daniel Roseman
On Thursday, 22 December 2011 09:09:16 UTC, @timkofu wrote:
>
> Also, I just found out from here 
> https://docs.djangoproject.com/en/1.3/topics/forms/ that i can just:
>
> {{form.field_name}}
>
> which makes things even more flexible.
>
 
Don't forget that you will need to render the validation error messages (if 
any) separately in that case, with {{ form.field_name.errors }} 
--
DR.

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



Compare two tables in a secondary database

2011-12-22 Thread kr0na
Im trying to compare two tables in a second database that is a
migrated database from mssql. The second database doesn't have any
apps for it, it will only be used for queries.

This are my models for the two tables.
from django.db import models

class invGroups(models.Model):
groupID = models.SmallIntegerField(primary_key = True)
categoryID = models.SmallIntegerField()

def __unicode__(self):
return self.item

class Meta:
db_table = 'invGroups'

class invTypes(models.Model):
typeID = models.SmallIntegerField(primary_key = True)
typeName = models.CharField(max_length = 200)
published = models.SmallIntegerField()
groupID = models.SmallIntegerField()

def __unicode__(self):
return self.item

class Meta:
db_table = 'invTypes'

And the query so far.
item_search_results = invTypes.objects.using(
'DataDump'
).filter(
typeName__icontains = search_query
)[0:15]

I currently can select from only one database, and the query is what i
have so far. I tried to use ForeignKey with no results. Can I do this
without using a RAW query? Im trying to achieve this query:
SELECT
typeName
FROM
invGroups,
invTypes
WHERE
invTypes.groupID = invGroups.groupID and
invGroups.categoryID in (7, 8, 9, 18, 20) and
invTypes.typeName like 'query%'
ORDER BY
invTypes.typeName;

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



Select field with default text

2011-12-22 Thread talbronstien
Hi,

I want to have a field in a form class which will render as select in
html. But, I want default text shown as "Select Blood Type". My
declaration is

gender = forms.ChoiceField(required=False,choices =
USER_BLOOD_CHOICES).

But, if I add an option value in html, as Select
Blood Type". I get an error, as this is not valid value (as
this is not required and user may not select an option). How can I
handle this?

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: Compare two tables in a secondary database

2011-12-22 Thread Tom Evans
On Thu, Dec 22, 2011 at 12:27 PM, kr0na  wrote:
> Im trying to compare two tables in a second database that is a
> migrated database from mssql. The second database doesn't have any
> apps for it, it will only be used for queries.
>
> This are my models for the two tables.
> from django.db import models
>
> class invGroups(models.Model):
>        groupID = models.SmallIntegerField(primary_key = True)
>        categoryID = models.SmallIntegerField()
>
>        def __unicode__(self):
>                return self.item
>
>        class Meta:
>                db_table = 'invGroups'
>
> class invTypes(models.Model):
>        typeID = models.SmallIntegerField(primary_key = True)
>        typeName = models.CharField(max_length = 200)
>        published = models.SmallIntegerField()
>        groupID = models.SmallIntegerField()
>
>        def __unicode__(self):
>                return self.item
>
>        class Meta:
>                db_table = 'invTypes'
>
> And the query so far.
> item_search_results = invTypes.objects.using(
>        'DataDump'
> ).filter(
>        typeName__icontains = search_query
> )[0:15]
>
> I currently can select from only one database, and the query is what i
> have so far. I tried to use ForeignKey with no results.

I didn't really understand what you are asking here. Where does the
second database come into it?

> Can I do this
> without using a RAW query? Im trying to achieve this query:
> SELECT
> typeName
> FROM
> invGroups,
> invTypes
> WHERE
> invTypes.groupID = invGroups.groupID and
> invGroups.categoryID in (7, 8, 9, 18, 20) and
> invTypes.typeName like 'query%'
> ORDER BY
> invTypes.typeName;
>

First off, currently your objects are not related to each other. You
need to specify a foreign key relationship between the two related
models:

class invTypes(models.Model):
   typeID = models.SmallIntegerField(primary_key = True)
   typeName = models.CharField(max_length = 200)
   published = models.SmallIntegerField()
   group = models.ForeignKey('invGroups', db_column='groupID')

Then, you can simply use Django's ORM to query the tables:

invType.objects.filter(invgroups__categoryid__in[7,8,9,8,20],
typename__ilike=query).values_list('typename', flat=True)

Django will do an explicit join, rather than the implicit one in your query.

There are a few other things I find strange with your code:

Readability: your class names should be UpperCamelCase and your
variable, function and method names either lowerCamelCase or
lower_case_with_underscores. PEP 8 (and me) prefer the latter.

Straight up bugs: Both model's unicode methods refer to self.item, but
there is no self.item.

Specifying the type and name of your primary key. Django will auto add
a primary key with a sane type if you don't. You've chosen
SmallIntegerField - in most databases, this will have a maximum value
of 32,768, meaning you can put that many items in your DB table and no
more.

It could be you are mapping Django onto an existing DB structure,
which would explain the strange model attribute names. When doing
this, it's easier to have a sensible python name for the attribute,
and specify the actual column name in the db_column argument, as I did
adding the ForeignKey.

Cheers

Tom

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



Re: Select field with default text

2011-12-22 Thread Tom Evans
On Thu, Dec 22, 2011 at 12:37 PM, talbronstien  wrote:
> Hi,
>
> I want to have a field in a form class which will render as select in
> html. But, I want default text shown as "Select Blood Type". My
> declaration is
>
> gender = forms.ChoiceField(required=False,choices =
> USER_BLOOD_CHOICES).
>
> But, if I add an option value in html, as Select
> Blood Type". I get an error, as this is not valid value (as
> this is not required and user may not select an option). How can I
> handle this?
>
> thanks
>

Don't add an option in HTML. Job done.

The way I normally do this is to add the invalid choice into the list
of choices, and then assert that their choice is not the invalid
choice:

class FooForm(forms.Form):
  INVALID_CHOICE = -1
  WIBBLE = 1
  FOO_CHOICES = (
  (INVALID_CHOICE, "Select..."),
  (WIBBLE, 'Wibble'), )
  fooselect = forms.ChoiceField(choices=FOO_CHOICES)

  def clean_fooselect(self):
if self.cleaned_data.get('foochoice') == INVALID_CHOICE:
  raise forms.ValidationError('Your choice sucked')

Cheers

Tom

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



Using filter for serialized model.Field's

2011-12-22 Thread jrief
Hi,
I have i weird problem when using model fields JSONField and
PickledObjectField together with the filter function.

from jsonfield.fields import JSONField
from picklefield.fields import PickledObjectField

class Item(models.Model):
picklefield = PickledObjectField(null=True, blank=True)
jsonfield = JSONField(null=True, blank=True)

if I store a dict in this model

mydict = {'description': 'Hello', }
item1 = Item.objects.create(picklefield=mydict)
item1.save()
item2 = Item.objects.filter(picklefield=mydict)
item2.exists() # returns True, as expected

if however my dict looks like this

mydict = {'description': None, 'name': u'Color', 'id': 1L,
'option': 'red'}
...same code as above...
item2.exists() # returns False

Then I tested the same with JSONField. There, I also expect that item2
shall exists, but this function also returns False.

Then I tested with mydict as

mydict = [ 2, 3, 4 ]
item1 = Item.objects.create(jsonfield=mydict)
item1.save()
item2 = Item.objects.filter(jsonfield=mydict)
item2.exists() # returns True, as expected

BTW, this example also works with PickledObjectField.

I don't think its a bug in both implementations of JSONField and
PickledObjectField, because they always serialize to the same string.

Is this undefined behavior intentional and I missed to read some
documentation? How can I solve this, without having to serialize the
objects manually?

Any help is greatly appreciated.

-- 
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: Which IDE should I use for Django?

2011-12-22 Thread jrief
Eclipse + PyDev

-- 
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: Select field with default text

2011-12-22 Thread Andre Terra
You could perhaps subclass ChoiceField to allow for custom empty_labels.

This code is highly untested and written so casually it shouldn't be pasted
anywhere.

# your forms.py
from django.forms.fields import ChoiceField

class MyCustomChoiceField(ChoiceField):
def __init__(self, *args, **kwargs):
self.empty_label = kwargs.pop('empty_label', None)
super(MyCustomChoiceField, self).__init__(*args, **kwargs)
self.choices = self.custom_choices(choices)

def custom_choices(self, choices):
if self.empty_label is not None:
yield (u"", self.empty_label)

for choice in self.choices:
yield choice

# 

I assume something like this would work? I actually believe it should even
come with django.


Cheers,
AT

On Thu, Dec 22, 2011 at 11:05 AM, Tom Evans wrote:

> On Thu, Dec 22, 2011 at 12:37 PM, talbronstien 
> wrote:
> > Hi,
> >
> > I want to have a field in a form class which will render as select in
> > html. But, I want default text shown as "Select Blood Type". My
> > declaration is
> >
> > gender = forms.ChoiceField(required=False,choices =
> > USER_BLOOD_CHOICES).
> >
> > But, if I add an option value in html, as Select
> > Blood Type". I get an error, as this is not valid value (as
> > this is not required and user may not select an option). How can I
> > handle this?
> >
> > thanks
> >
>
> Don't add an option in HTML. Job done.
>
> The way I normally do this is to add the invalid choice into the list
> of choices, and then assert that their choice is not the invalid
> choice:
>
> class FooForm(forms.Form):
>  INVALID_CHOICE = -1
>  WIBBLE = 1
>  FOO_CHOICES = (
>  (INVALID_CHOICE, "Select..."),
>  (WIBBLE, 'Wibble'), )
>  fooselect = forms.ChoiceField(choices=FOO_CHOICES)
>
>  def clean_fooselect(self):
>if self.cleaned_data.get('foochoice') == INVALID_CHOICE:
>  raise forms.ValidationError('Your choice sucked')
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
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: Which IDE should I use for Django?

2011-12-22 Thread Lord Max
For me Eric con linux and pyScripter on windows
To my point of view debug is fundamental

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



am I understanding sessions correctly?

2011-12-22 Thread Chris Curvey
The short version:  when processing a request, does Django *always*
collect session information from the session store before starting the
view?

The long version:

i have an application that makes heavy use of AJAX.  When a user
changes something on the page, the page fires an AJAX POST to apply
the changes to the database, then a series of AJAX GETs to refresh
other portions of the page.

Some of the GETs are expensive, so I have some process_response()
middleware that caches the HTML generated by the GET in the Django
session.  (It's the standard database session store.)  I also have
some process_request() middleware that either returns the cached HTML
if it can, or invalidates the cache on any POST.

Just to add to the fun, I have a four identical Django/mod_wsgi
instances running behind a round-robin load balancer.  So the POST
request might get handled by Django1, the first GET by Django2, the
second GET by Django3, and so on.

My problem is that sometimes the results of the POST are not visible
in the results of the GET.  The problem is intermittent, which is
leading me to point the finger at my cacheing strategy.  My assumption
was that Django would reload the session from the database every time
before starting my view code, but I'm wondering if that is not true
(or if there is some other issue that I'm not thinking about).

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



Weekly discussion/randoms thread..

2011-12-22 Thread Cal Leeming [Simplicity Media Ltd]
Since starting, PythonWeekly seems to have been sending out some quite
useful and interesting information..

Although it's not directly related to Django, a lot of the information is
highly relevant to every day Django use.

It also got me thinking, perhaps it would be nice to have a weekly thread
on django-users, where users post useful comments/links in easy to read
bullet points. - Kinda similar to the thread we had a while back where
everyone posted their IDE layouts in a simple 1 line sentence. It wouldn't
need to be in any particular format, and there's always something new to
learn!

Here's some stuff I learnt this week.

* Trying to catch and handle MemoryError exceptions is fun!
* Python Duck Typing (lol, I'd never even heard of this before, an
interesting concept -  http://en.wikipedia.org/wiki/Duck_typing#In_Python  )
* reload() is unsafe
* copy() might not always return expected results
* Using '__name__ == '__main__' is standard practise, but it shouldn't be!
* David Beazley has done some very interesting articles -
http://www.dabeaz.com/talks.html
* Heroku's site design made me cry - but has an interesting feature set. (
http://www.heroku.com/ )
* Graphite looks AWESOME ( http://graphite.wikidot.com/screen-shots )
* I hate Scrapy ( http://doc.scrapy.org/en/latest/intro/overview.html ) -
bloated crawl-ware tbh.
* socketio looks really nice - https://github.com/stephenmcd/django-socketio
* codes examples on data analysis with "pandas" makes me excited - looks a
tad confusing though  ( http://pandas.sourceforge.net/ )


-- Forwarded message --
From: Python Weekly 
Date: Thu, Dec 22, 2011 at 4:01 PM
Subject: Python Weekly (Issue 14 - December 22, 2011)
To: cal.leem...@simplicitymedialtd.co.uk


  Email not displaying correctly? View it in your
browser.
  Welcome to issue 14 of Python Weekly. I wish you all Happy Holidays
and I look forward to 2012, sending you the best Python related links.

*Articles, Tutorials and Talks*

 Save the Monkey: Reliably Writing to
MongoDB
 MongoDB replica sets claim "automatic failover" when a primary server goes
down, and they live up to the claim, but handling failover in your
application code takes some care. This post walks you through writing a
failover-resistant application in Python using a new feature in PyMongo
2.1: the ReplicaSetConnection.

 Crawling the Android
Marketplace
 This article shows how you can use python based crawler to crawl the
android marketplace. The crawler script is available on github.

 SockJS benchmarking with PyPy, CPython and
Node
 The article that shows benchmarking SockJS server performance with PyPy,
CPython and Node. This test covers raw messaging performance over Websocket
connection(s) for different server implementations of the SockJS protocol.
The results are quite impressive with PyPy.

 Unfortunate 
Python
 This post shows some of the things you should avoid when writing code
using Python.

 Android Applications Using Python and SL4A, Part 1: Set Up Your
Development 
Environment
 This series of articles explores how to use Python and Scripting Layer for
Android (SL4A) to build applications for the Google Android platform. This
article, the first in the series, shows what you need to do to get
everything installed and running.

 Tornado Unit Testing: Eventually
Correct
 Tornado is one of the major async web frameworks for Python, but unit
testing async code is a total pain. This post reviews what the problem is,
look at some klutzy solutions, and propose a better way.

 How to Log Out from an AppEngine App
Only
 This post explains how to add a logout page to an AppEngine Python
application, which will log out of the application only, without logging
out of all of Google (e.g. Gmail, Calendar, Picasa, YouTube).

 Flask and Mongodb on
PyPy
 This post describes how Paylogic team got everything working using PyPy
and some performance measurements and the outcome of a couple of simple
benchmarks.

 Python 
co-routines

Re: Which IDE should I use for Django?

2011-12-22 Thread Cal Leeming [Simplicity Media Ltd]
Personally - I'd recommend Sublime Text 2 - but this is a text editor, not
really an IDE.

But, it doesn't come with 'useful' code completion or code intellisense.

It also really depends on what sort of developer you are..

If you came from a background of using a text editor like vi/nano/editra,
then Sublime Text 2 is the way for you.

However if you came from the background of having a fully integrated IDE,
then maybe Komodo or PyCharm.

Imo, I'm yet to find an IDE that I felt was 'integrated' and 'clean' enough
to justify moving from Komodo or Sublime Text 2.

Hope this helps.

Cal

On Mon, Dec 19, 2011 at 10:34 AM, Alec Taylor wrote:

> I'm looking for a Django IDE which incorporates the following features:
> - Syntax-highlighting
> - Projects (all code file of the project shown separated by directory
> in a sidebar)
> - Tabs (with close buttons on tab)
> - Code-completion (with good introspection)
> - Text-zoom support
> - Start/stop Django server
> - Run+restart Django server shell (manage.py shell) in project (i.e. below
> code)
>
> I program on Windows and Linux, so it would be great if the IDE is
> supported on both platforms.
>
> Previously I was using Editra, but I requested an automatic import
> into embedded interpreter feature in April, which they still haven't
> integrated. So I am looking at alternatives :)
>
> Thanks for all suggestions,
>
> Alec Taylor
>
> --
> 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: Compare two tables in a secondary database

2011-12-22 Thread Edvinas Narbutas
Im trying to query the second DB for information. Its a back up from
another database, its separate from default, here is the settings.py
-> DATABASES:

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '#',
'USER': '#',
'PASSWORD': '#',
'HOST': '',
'PORT': '',
},
'userxml': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '#',
'USER': '#',
'PASSWORD': '#',
'HOST': '',
'PORT': '',
},
'DataDump': {
'ENGINE': 'django.db.backends.mysql',
'NAME': '#',
'USER': '#',
'PASSWORD': #',
'HOST': '',
'PORT': '',
}
}

So the two tables are in DataDump DB. So what im trying to do is
DataDump --> table1(field) compare with table2(field). I hope this
makes it more clear, the DB is already populated with values, i just
need to compare couple of tables. Im not going to write anything to
the table, just going to use it for reads.
>From your example i came up with this (the SmallInteger is ok because
the values go up only a couple of thousand):

class itemSearch(models.Model):
invgroupstable = models.ForeignKey('invGroups', db_column = 
'categoryID')
invtypestable = models.ForeignKey('invTypes', db_column = 'typeName')

class invGroups(models.Model):
groupID = models.SmallIntegerField(primary_key = True)
categoryID = models.SmallIntegerField()

class Meta:
db_table = 'invGroups'

class invTypes(models.Model):
typeID = models.SmallIntegerField(primary_key = True)
typeName = models.CharField(max_length = 200)
published = models.SmallIntegerField()
groupID = models.SmallIntegerField()

class Meta:
db_table = 'invTypes'

And the query is like this:

item_search_results = itemSearch.objects.using(
'DataDump'
).filter(
invgroupstable__categoryid__in[7, 8, 9, 18, 20],
invtypestable__typename_ilike = search_query
)[0:15]

And i get this error,

global name 'invgroupstable__categoryid__in' is not defined

I think im really miss understanding something here.






















On Thu, Dec 22, 2011 at 2:57 PM, Tom Evans  wrote:
> On Thu, Dec 22, 2011 at 12:27 PM, kr0na  wrote:
>> Im trying to compare two tables in a second database that is a
>> migrated database from mssql. The second database doesn't have any
>> apps for it, it will only be used for queries.
>>
>> This are my models for the two tables.
>> from django.db import models
>>
>> class invGroups(models.Model):
>>        groupID = models.SmallIntegerField(primary_key = True)
>>        categoryID = models.SmallIntegerField()
>>
>>        def __unicode__(self):
>>                return self.item
>>
>>        class Meta:
>>                db_table = 'invGroups'
>>
>> class invTypes(models.Model):
>>        typeID = models.SmallIntegerField(primary_key = True)
>>        typeName = models.CharField(max_length = 200)
>>        published = models.SmallIntegerField()
>>        groupID = models.SmallIntegerField()
>>
>>        def __unicode__(self):
>>                return self.item
>>
>>        class Meta:
>>                db_table = 'invTypes'
>>
>> And the query so far.
>> item_search_results = invTypes.objects.using(
>>        'DataDump'
>> ).filter(
>>        typeName__icontains = search_query
>> )[0:15]
>>
>> I currently can select from only one database, and the query is what i
>> have so far. I tried to use ForeignKey with no results.
>
> I didn't really understand what you are asking here. Where does the
> second database come into it?
>
>> Can I do this
>> without using a RAW query? Im trying to achieve this query:
>> SELECT
>> typeName
>> FROM
>> invGroups,
>> invTypes
>> WHERE
>> invTypes.groupID = invGroups.groupID and
>> invGroups.categoryID in (7, 8, 9, 18, 20) and
>> invTypes.typeName like 'query%'
>> ORDER BY
>> invTypes.typeName;
>>
>
> First off, currently your objects are not related to each other. You
> need to specify a foreign key relationship between the two related
> models:
>
> class invTypes(models.Model):
>       typeID = models.SmallIntegerField(primary_key = True)
>       typeName = models.CharField(max_length = 200)
>       published = models.SmallIntegerField()
>       group = models.ForeignKey('invGroups', db_column='groupID')
>
> Then, you can simply use Django's ORM to query the tables:
>
> invType.objects.filter(invgroups__categoryid__in[7,8,9,8,20],
>    typename__ilike=query).values_list('typename', flat=True)
>
> Django will do an explicit join, rather than the implicit one in your query.
>
> There are a few other things I find strange with your code:
>
> Readability: your class names should be UpperCamelCase and your
> variable, function and method names either lowerCamelCase or
> lower_case_with_underscores. PEP 8 (and me) prefer the latter.
>
> Straight up bugs: Both model's unicode methods refer to self.item, but
> ther

how to use asyncore socket in django views.py

2011-12-22 Thread Kay
if I have easy asyncore socket code as follow:

--

import socket
import asyncore

class asysocket(asyncore.dispatcher):

def __init__(self,host,port):
asyncore.dispatcher.__init__(self)
self.create_socket(socket.AF_INET, socket.SOCK_STREAM)
self.set_reuse_addr()
self.bind((host, port))
self.listen(10)
print 'server is waiting for socket connection...'

def handle_accept(self):
new,addr = self.accept()
print 'received from address', addr
data = new.recv(1024)
print repr(data)

def handle_close(self):
self.close()

server = asysocket('127.0.0.1',1234)
asyncore.loop()



then how to use this in my django project views.py to let it
automatically work for receiving connection

while i start the project as "python manage.py runserver [port]"??

thanks

kay

-- 
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: Weekly discussion/randoms thread..

2011-12-22 Thread Cal Leeming [Simplicity Media Ltd]
Sure, here you go:

Taken from: 
http://excess.org/article/2011/12/unfortunate-python/



if __name__ == '__main__':
This little wart has long been a staple of many python introductions. It
lets you treat a python script as a module, or a module as a python script.
Clever, sure, but it's better to keep your scripts and modules separate in
the first place.

If you treat a module like a script, then something imports the module
you're in trouble: now you have two copies of everything in that module.

I have used this trick to make running tests easier, but setuptools already
provides a better hook for running tests. For scripts setuptools has an
answer too, just give it a name and a function to call, and you're done.

My last criticism is that a single line of python should never be 10
alphanumeric characters and 13 punctuation characters. All those
underscores are there as a warning that some special non-obvious
language-related thing is going on, and it's not even necessary.

See also setuptools/distribute automatic script creation

and also PEP 366 pointed out by agentultra on HN

---

On Thu, Dec 22, 2011 at 6:58 PM, Nikolas Stevenson-Molnar <
nik.mol...@consbio.org> wrote:

>  Could you provide a link to the bit about __name__ == __main__? I'd be
> interested in learning more about that...
>
> Thanks,
> _Nik
>
> 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.



geodjango admin polygonfield with hole

2011-12-22 Thread Josh K
I've set up geodjango to use the OSMGeoAdmin model. One of the models
I've created has a PolygonField. GeoDjango states it follows the
OpenGIS Simple Features specification. The spec lists a polygon as
being able to have a "hole". So does anyone know how to draw a hole on
the OSMGeoAdmin model slippy map interface? I've been trying forever!
I can draw a polygon, and I can change my model to be
MultiPolygonField and I can draw multiple polygons at the same time,
but I cannot figure out how to draw a polygon with a hole!

Let me know if my question isn't clear or you need more info.

-- 
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 filter for serialized model.Field's

2011-12-22 Thread Matt Schinckel
I'm guessing it's got to do with testing for equality. It will be 
restricted to how the field prepares data for querying the database, and 
(speaking as the maintainer of JSONField) you need to be very careful with 
querying on json fields, as the data is stored as a string, so changes 
about how it serialises can affect query results.

You can restrict queries to `__contains` queries, and query for keys, but 
there is not really any way to have structured queries that exactly match a 
defined dict, for instance.

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



Professional forum software that integrates with Django

2011-12-22 Thread Mark Stahler
Does any one know of a professional forum package, commercial or open
source like vBulletin, phpBB or similar that easily integrates with
Django's authentication system?

-- 
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: Compare two tables in a secondary database

2011-12-22 Thread Python_Junkie
I think you are limiting yourself by excluding sql.

I use the ORM for the admin side of the house and I use sql for all of
my web based presentations.

SQL will do everything that you want to achieve.

ORM has limitations as you have seen.

On Dec 22, 7:27 am, kr0na  wrote:
> Im trying to compare two tables in a second database that is a
> migrated database from mssql. The second database doesn't have any
> apps for it, it will only be used for queries.
>
> This are my models for the two tables.
> from django.db import models
>
> class invGroups(models.Model):
>         groupID = models.SmallIntegerField(primary_key = True)
>         categoryID = models.SmallIntegerField()
>
>         def __unicode__(self):
>                 return self.item
>
>         class Meta:
>                 db_table = 'invGroups'
>
> class invTypes(models.Model):
>         typeID = models.SmallIntegerField(primary_key = True)
>         typeName = models.CharField(max_length = 200)
>         published = models.SmallIntegerField()
>         groupID = models.SmallIntegerField()
>
>         def __unicode__(self):
>                 return self.item
>
>         class Meta:
>                 db_table = 'invTypes'
>
> And the query so far.
> item_search_results = invTypes.objects.using(
>         'DataDump'
> ).filter(
>         typeName__icontains = search_query
> )[0:15]
>
> I currently can select from only one database, and the query is what i
> have so far. I tried to use ForeignKey with no results. Can I do this
> without using a RAW query? Im trying to achieve this query:
> SELECT
> typeName
> FROM
> invGroups,
> invTypes
> WHERE
> invTypes.groupID = invGroups.groupID and
> invGroups.categoryID in (7, 8, 9, 18, 20) and
> invTypes.typeName like 'query%'
> ORDER BY
> invTypes.typeName;

-- 
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: Weekly discussion/randoms thread..

2011-12-22 Thread Russell Keith-Magee
On Fri, Dec 23, 2011 at 12:39 AM, Cal Leeming [Simplicity Media Ltd] <
cal.leem...@simplicitymedialtd.co.uk> wrote:

> Since starting, PythonWeekly seems to have been sending out some quite
> useful and interesting information..
>
> Although it's not directly related to Django, a lot of the information is
> highly relevant to every day Django use.
>
> It also got me thinking, perhaps it would be nice to have a weekly thread
> on django-users, where users post useful comments/links in easy to read
> bullet points. - Kinda similar to the thread we had a while back where
> everyone posted their IDE layouts in a simple 1 line sentence. It wouldn't
> need to be in any particular format, and there's always something new to
> learn!
>
> ... and a pony! :-)

Seriously -- this is a great idea -- so much so, that you're not the first
person to suggest it. The most recent attempt (that I'm aware of) was

http://djangoweek.ly/

but that's one in a long line of newsletters. The problem is that these
things take a lot of time to produce, and it's a pretty thankless task.

So, yes -- absolutely -- a weekly newsletter would be a great idea.
However, just suggesting that someone else do it won't get the job done.
Someone needs to volunteer to actually do it.

Volunteers welcome :-)

Yours,
Russ Magee %-)

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



Ember.js or Backbone.js for Django?

2011-12-22 Thread Jesramz
Which of these is best suited to work with 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: Compare two tables in a secondary database

2011-12-22 Thread Edvinas Narbutas
Yeah, the ORM didn't work out as i thought for this. I have written
this raw query with a model. Alot less code compared to as before.

class itemSearch(models.Model): typeID =
models.SmallIntegerField(primary_key = True)typeName =
models.CharField(max_length = 200)

item_search_results = itemSearch.objects.raw(
'''SELECT * FROM invTypes WHERE invTypes.typeName LIKE '%s%'
LIMIT 0, 10''', [search_query]
).using(
'DataDump'
)
for name in item_search_results:
results.append(name.typeName)

I get this error. "not enough arguments for format string", which im
guessing the LIKE isnt working because this query works.

item_search_results = itemSearch.objects.raw(
'''SELECT * FROM invTypes LIMIT 0, 10'''
).using(
'DataDump'
)

for name in item_search_results:
results.append(name.typeName)

I have no idea what could be wrong in the query or the model. Any help?
On Fri, Dec 23, 2011 at 1:07 AM, Python_Junkie
 wrote:
> I think you are limiting yourself by excluding sql.
>
> I use the ORM for the admin side of the house and I use sql for all of
> my web based presentations.
>
> SQL will do everything that you want to achieve.
>
> ORM has limitations as you have seen.
>
> On Dec 22, 7:27 am, kr0na  wrote:
>> Im trying to compare two tables in a second database that is a
>> migrated database from mssql. The second database doesn't have any
>> apps for it, it will only be used for queries.
>>
>> This are my models for the two tables.
>> from django.db import models
>>
>> class invGroups(models.Model):
>>         groupID = models.SmallIntegerField(primary_key = True)
>>         categoryID = models.SmallIntegerField()
>>
>>         def __unicode__(self):
>>                 return self.item
>>
>>         class Meta:
>>                 db_table = 'invGroups'
>>
>> class invTypes(models.Model):
>>         typeID = models.SmallIntegerField(primary_key = True)
>>         typeName = models.CharField(max_length = 200)
>>         published = models.SmallIntegerField()
>>         groupID = models.SmallIntegerField()
>>
>>         def __unicode__(self):
>>                 return self.item
>>
>>         class Meta:
>>                 db_table = 'invTypes'
>>
>> And the query so far.
>> item_search_results = invTypes.objects.using(
>>         'DataDump'
>> ).filter(
>>         typeName__icontains = search_query
>> )[0:15]
>>
>> I currently can select from only one database, and the query is what i
>> have so far. I tried to use ForeignKey with no results. Can I do this
>> without using a RAW query? Im trying to achieve this query:
>> SELECT
>> typeName
>> FROM
>> invGroups,
>> invTypes
>> WHERE
>> invTypes.groupID = invGroups.groupID and
>> invGroups.categoryID in (7, 8, 9, 18, 20) and
>> invTypes.typeName like 'query%'
>> ORDER BY
>> invTypes.typeName;
>
> --
> 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: Which IDE should I use for Django?

2011-12-22 Thread Matteius
PyCharm 2.0 has been released and I've been using PyCharm for over a
year now with strong results.  It is great to have an editor that can
correct you and help auto-complete your code.

-Matteius

On Dec 19, 10:42 am, Masklinn  wrote:
> On 2011-12-19, at 16:30 , Andre Terra wrote:
>
>
>
> > What do you mean by embedded Django interpreter? An instance of python
> > running within Aptana?
>
> Django performs a bunch of setup which allow for easy import and manipulation 
> of the objects related to the instance, which is the reason why django has a 
> `shell` management command wrapping the 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.



Re: Weekly discussion/randoms thread..

2011-12-22 Thread Cal Leeming [Simplicity Media Ltd]
I'm thinking that if we keep this a strictly on-list event, it will
encourage people to get involved at any time, simply by replying to the
thread.

We'd pick a day which consistently shows most activity, and someone would
just start the thread off on that day.

Maybe a few 'etiquette' rules for the thread - like keeping replies to
under a certain amount, removing any unnecessary 'filler', limit to either
bullet points or single sentences - to allow for easy quick reading, rather
than a book essay.

I think the most important aspect is to keep this integrated into the list,
and not require the user to break off to another service. - It also means
that there's very little admin involved, and it's easily contributed by
anyone on the list.

@Russ - do you feel this would be a good approach to take??

On Thu, Dec 22, 2011 at 11:14 PM, Russell Keith-Magee <
russ...@keith-magee.com> wrote:

>
>
> On Fri, Dec 23, 2011 at 12:39 AM, Cal Leeming [Simplicity Media Ltd] <
> cal.leem...@simplicitymedialtd.co.uk> wrote:
>
>> Since starting, PythonWeekly seems to have been sending out some quite
>> useful and interesting information..
>>
>> Although it's not directly related to Django, a lot of the information is
>> highly relevant to every day Django use.
>>
>> It also got me thinking, perhaps it would be nice to have a weekly thread
>> on django-users, where users post useful comments/links in easy to read
>> bullet points. - Kinda similar to the thread we had a while back where
>> everyone posted their IDE layouts in a simple 1 line sentence. It wouldn't
>> need to be in any particular format, and there's always something new to
>> learn!
>>
>> ... and a pony! :-)
>
> Seriously -- this is a great idea -- so much so, that you're not the first
> person to suggest it. The most recent attempt (that I'm aware of) was
>
> http://djangoweek.ly/
>
> but that's one in a long line of newsletters. The problem is that these
> things take a lot of time to produce, and it's a pretty thankless task.
>
> So, yes -- absolutely -- a weekly newsletter would be a great idea.
> However, just suggesting that someone else do it won't get the job done.
> Someone needs to volunteer to actually do it.
>
> Volunteers welcome :-)
>
> Yours,
> Russ Magee %-)
>
>  --
> 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.



Generic views parameter 'extra_context' didn't use form class?

2011-12-22 Thread 郁夫
hi, I use a form class in Generic views  'list_detail.object_list' para
'extra_context '


form

> class DevSrcForm(forms.Form):
> f_eqno = forms.CharField(label='编号')
> f_eqclass =
forms.ChoiceField(choices=(),widget=forms.Select(attrs={}),label='分类')
> f_ipaddress = forms.CharField(required=False,label='IP地址')
> f_sdate = forms.DateField(label='开始日期')
> f_edate = forms.DateField(label='结束日期')
> f_model = forms.CharField(label='型号')
> f_empid =
forms.ChoiceField(choices=(),widget=forms.Select(attrs={}),label='用户')
> def __init__(self, *args, **kwargs):
> super(DevForm, self).__init__(*args, **kwargs)
> self.fields['f_eqclass'].choices = [(i.fid,i.fclass) for i in
OaEqclass.objects.all()]
> self.fields['f_empid'].choices = [(i.fid,i.name) for i in
ViewEmpl.objects.all().order_by('name')]
>
>
view
>
>if request.method == "GET":
> # DevSrcForm是一个form类
> SrcForm = DevSrcForm()
>
> return list_detail.object_list(
>  request,
>  queryset =  ViewEqinfo.objects.all(),
>  template_name = 'device/device.html',
>  paginate_by = 20,
>  extra_context = {'srcform': SrcForm}
> )
>
error info
>
> super(type, obj): obj must be an instance or subtype of type
remove 'extra_context' , page normal display.

'extra_context' not use form class?

-- 

西安――深圳――上海
http://szxatjp.blog.163.com/


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



Re: Which IDE should I use for Django?

2011-12-22 Thread Alex Mandel

On 12/20/2011 06:28 AM, Parisson wrote:

On 20/12/2011 08:23, Alex Mandel wrote:

Code completion is subpar, actually one of the worst python editors for
that because you have to pregenerate the lists.



Eric's completion is based on QScintilla and works fast here..
Do you know any completion system which doesn't have to generate any word list ?

G



Yes, SPE, Pydev, Pythonwin etc all bring up autocomplete options without 
the need to pregenerate lists. If you import a lib it actually parses 
the lib to load the autocomplete options. This is fundamentally 
different from how ERIC's system works where you go into the preferences 
and feed it reference files for various libraries (if they exist) to add 
them to the autocomplete options.


Alex

--
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: Compare two tables in a secondary database

2011-12-22 Thread Python_Junkie
Putting django aside for the moment, are you able to take the sql that
you wrote above and write a python script with the sql code above.

I use the pyodbc module to perform all of my sql scripts.

Once you write the successful python sql script, you can import this
working module into a django view.

If this is the direction that you want to go write me back and I can
help you with that.

On Dec 22, 8:33 pm, Edvinas Narbutas  wrote:
> Yeah, the ORM didn't work out as i thought for this. I have written
> this raw query with a model. Alot less code compared to as before.
>
> class itemSearch(models.Model): typeID =
> models.SmallIntegerField(primary_key = True)    typeName =
> models.CharField(max_length = 200)
>
> item_search_results = itemSearch.objects.raw(
>         '''SELECT * FROM invTypes WHERE invTypes.typeName LIKE '%s%'
> LIMIT 0, 10''', [search_query]
> ).using(
>         'DataDump'
> )
> for name in item_search_results:
>         results.append(name.typeName)
>
> I get this error. "not enough arguments for format string", which im
> guessing the LIKE isnt working because this query works.
>
> item_search_results = itemSearch.objects.raw(
>         '''SELECT * FROM invTypes LIMIT 0, 10'''
> ).using(
>         'DataDump'
> )
>
> for name in item_search_results:
>         results.append(name.typeName)
>
> I have no idea what could be wrong in the query or the model. Any help?
> On Fri, Dec 23, 2011 at 1:07 AM, Python_Junkie
>
>
>
>
>
>
>
>  wrote:
> > I think you are limiting yourself by excluding sql.
>
> > I use the ORM for the admin side of the house and I use sql for all of
> > my web based presentations.
>
> > SQL will do everything that you want to achieve.
>
> > ORM has limitations as you have seen.
>
> > On Dec 22, 7:27 am, kr0na  wrote:
> >> Im trying to compare two tables in a second database that is a
> >> migrated database from mssql. The second database doesn't have any
> >> apps for it, it will only be used for queries.
>
> >> This are my models for the two tables.
> >> from django.db import models
>
> >> class invGroups(models.Model):
> >>         groupID = models.SmallIntegerField(primary_key = True)
> >>         categoryID = models.SmallIntegerField()
>
> >>         def __unicode__(self):
> >>                 return self.item
>
> >>         class Meta:
> >>                 db_table = 'invGroups'
>
> >> class invTypes(models.Model):
> >>         typeID = models.SmallIntegerField(primary_key = True)
> >>         typeName = models.CharField(max_length = 200)
> >>         published = models.SmallIntegerField()
> >>         groupID = models.SmallIntegerField()
>
> >>         def __unicode__(self):
> >>                 return self.item
>
> >>         class Meta:
> >>                 db_table = 'invTypes'
>
> >> And the query so far.
> >> item_search_results = invTypes.objects.using(
> >>         'DataDump'
> >> ).filter(
> >>         typeName__icontains = search_query
> >> )[0:15]
>
> >> I currently can select from only one database, and the query is what i
> >> have so far. I tried to use ForeignKey with no results. Can I do this
> >> without using a RAW query? Im trying to achieve this query:
> >> SELECT
> >> typeName
> >> FROM
> >> invGroups,
> >> invTypes
> >> WHERE
> >> invTypes.groupID = invGroups.groupID and
> >> invGroups.categoryID in (7, 8, 9, 18, 20) and
> >> invTypes.typeName like 'query%'
> >> ORDER BY
> >> invTypes.typeName;
>
> > --
> > 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 
> > athttp://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: Jython zxJDBC / Python cx_oracle wrong number or types of arguments when calling to oracle's stored procedure

2011-12-22 Thread Python_Junkie
I presume that the stored procedure has been created.

I use the python module pyodbc.  Google has good documentation how to
set this up.

then after creating the connection you can execute the stored
procedure

4 lines of code will then create the crsr followed by the execution

crsr.execute('stored_procedure')

On Dec 21, 6:49 am, Daniel Roseman  wrote:
> On Wednesday, 21 December 2011 05:41:53 UTC, Akira Kir wrote:
>
> > 
>
> > {stackoverflow xposted}
>
> Answered on SO.
> --
> 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.



Django 1.4 alpha 1 released

2011-12-22 Thread James Bennett
Tonight as part of the 1.4 development process, we've released the
first alpha for Django 1.4. You can read all about it on the blog:

https://www.djangoproject.com/weblog/2011/dec/22/14-alpha-1/

And in the release notes:

https://docs.djangoproject.com/en/dev/releases/1.4-alpha-1/


-- 
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

-- 
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: Which IDE should I use for Django?

2011-12-22 Thread kenneth gonsalves
On Thu, 2011-12-22 at 16:44 +, Cal Leeming [Simplicity Media Ltd]
wrote:
> Personally - I'd recommend Sublime Text 2 - but this is a text editor,
> not really an IDE.

actually the best IDE is the linux desktop - especially if you have 2 or
more monitors.
-- 
regards
Kenneth Gonsalves

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



Running html files in /var/www alongwith Django over Apache

2011-12-22 Thread nipun batra
Hi,I got my Apache Mod_WSGI and Django working following
http://blog.stannard.net.au/2010/12/11/installing-django-with-apache-and-mod_wsgi-on-ubuntu-10-04/with
a twist that my 000-default site has the contents


ServerAdmin webmaster@localhost
 DocumentRoot /home/nipun/webdev/demo/demo


Order allow,deny
Allow from all


WSGIDaemonProcess demo.djangoserver processes=2 threads=15
display-name=%{GROUP}
WSGIProcessGroup demo.djangoserver

WSGIScriptAlias / /home/nipun/webdev/demo/demo/apache/django.wsgi




DocumentRoot /var/www

Options FollowSymLinks
AllowOverride None


Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

Alias /doc/ "/usr/share/doc/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128




So using this configuration i can basically run my Django sites like
http://localhost/meta for instance where meta calls corresponding view

However now when i try to load index.html(which has some javascript and
html code) lying on my /var/www it tries to match that using URL's
specified in urls.py of my Django project which i have configured with
Apache.

How can i modify the settings so that i shall be able to run scripts under
/var/www and also Django sites on localhost

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.