Re: value bound (choice)field

2009-09-14 Thread dimitri pater - serpia

for anyone who is interested, I created a template filter to do this
(see 
http://groups.google.com/group/django-users/browse_thread/thread/74e31c74cfd9469a)

On Tue, Sep 15, 2009 at 12:33 AM, dimitri pater - serpia
 wrote:
> Hello,
>
> I am trying to get a value from a bound field (a choicefield) to a
> template. Obviously form.field.value does not work. Any ideas
> somebody?
>
> thanks in advance,
> dimitri
>



-- 
---
You can't have everything. Where would you put it? -- Steven Wright
---
please visit www.serpia.org

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



Getting data from user via HTML

2009-09-14 Thread Nitin Boladra

Hi Django users,
I am trying to create a simple Django application
wherein I want to run a python function with an argument that is
obtained from text-box whenever I click the button on my web-page. The
problem is passing the value obtained in text-box to the python
function. So as I am new to Django can anybody help me out to resolve
this problem. Thanks in advance.

Regards,
Nitin

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



[OT] [Job] Singapore Company Looking for Django Developer

2009-09-14 Thread Kelvin Quee

Hi Django Users!

** Hiring Web User Interface Developer **
 * Strong in Python, Django and Javascript development
 * Strong in English
 * Loves to Work in a Startup Environment
 * Occasional Traveling to Singapore
 * Competitive Salary

(Feel free to pass this on to someone else)

We are looking for web user interface developers passionate about
using technology to visualise massive amounts of data. These data are
generated from mining hundreds of thousands of webpages on the
Internet. Your work will help our clients monitor and quickly
understand their online reputation.

You will work with an experienced and fun-loving team. You will
assist
in the maintenance of a highly scalable web user interface while
consistently designing, innovating, and implementing new features.

There will be heavy learning and experimenting. Your work will be
seen
and used by thousands of users worldwide.

You will work remotely from your home city. You may be required to
travel to Singapore occasionally. Candidates with demonstrable Django
experience (eg. a Django project showcase) are preferred.
JamiQ is a company based in Singapore. We use a wide variety of open
source technologies and research heavily on natural language
processing. Our products are designed for an international audience
and have a strong go-to-market orientation.

To find out more, visit -
http://blog.jamiq.com/

You can submit your resume in both English, related work
and all questions to - j...@jamiq.com


Kelvin Quee
Co-Founder, Operations
+65 9177 3635
Skype: kelvinquee

--~--~-~--~~~---~--~~
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: Query with left join?

2009-09-14 Thread tom

Hi Daniel,

i don't want to presentate the data. i want to produce graphs with
this data. so it's not a presentation problem. i know that i can use
python to get the data in correct order and style, but it's a huge
amount of data and python would be very slow for that. so it's better
when the database does the work.

On 13 Sep., 19:32, Daniel Roseman  wrote:
> On 2009/9/13, tom  wrote:
>
>
>
>
>
> > I have a model  to save measurement data. Every datarow has a
> > identifier(CharField) and a value(FloatField) and a entry(ForeignKey).
> > For example:
>
> > Entry  Identifier  value
> > 1        s1           100
> > 1        d1           180
> > 1        q5           300
> > 2        z88           10
> > ...
> > ...
>
> > With my query, i want to have as result:
>
> >  entry value value value
> >  1       100   180    300
>
> > So, my query gets every value for a entry in a row.
>
> This is a presentation issue, rather than a query one. You just want
> to get all the values, and group your output by entry id.
>
> So in your view you do:
> values = Value.objects.all().order_by('entry_id')
>
> and in your template:
> {% for value in values %}
> {% ifchanged value.entry_id %}
> {% value.entry_id %}
> {% endifchanged %}
> {% value.value %}
> {% endfor %}
>
> or something along those lines.
> --
> 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
-~--~~~~--~~--~--~---



MultiWidget format_output

2009-09-14 Thread justind

Hello,

I'm trying to use a multiwidget, my looks like this:

class DimensionsWidget(forms.MultiWidget):

def __init__(self, attrs=None):
widgets = (forms.widgets.TextInput(attrs=attrs),
forms.widgets.TextInput(attrs=attrs))
super(DimensionsWidget, self).__init__(widgets, attrs)

def decompress(self, value):
if value:
return value.split(",")
return [None, None]

def format_output(self, rendered_widgets):
rendered_widgets.insert(-1, "Width: ")
rendered_widgets.insert(2, "Height: ")
return u''.join(rendered_widgets)

Everything is working, except format_output is not being called. My
understanding is that the render method on the MultiWidget should call
format_output on the subclass, but its not being called. What am I
doing wrong?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Remote login via XML-RPC or SOAP?

2009-09-14 Thread Rodrigo Cea

I am creating a Django website for a client who won't give me access
to their database or server, but will allow login / account creation
on their server via SOAP or XML-RPC from my server, where the Django-
based website will reside.
I would like to get an idea beforehand about which route, SOAP or XML-
RPC, is easier, more stable, less buggy, more widely used, etc.

The process will be:
a) user inputs new account info on my server (lets call it D for
Django).
b) account is created on client's server (lets call it C for client)
c) C responds with Success or Fail.
d) next morning, user logs in via D
e) C responds with Success or Fail, plus some user info such as name,
age and other info gleaned during step (a).
f) D stores this information to use during the session and logs in
user.

Any help, caveats, libraries or suggestions are much 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
-~--~~~~--~~--~--~---



how to efficiently use many to many relationships with through tables

2009-09-14 Thread Greg Aumann

I am trying to write my first django app and am unclear about good
ways to deal with many to many relationships with through tables. My
app is like a bibliography but with lots of links between entries in
the bibliography. For example, I want to store links to all the
entries cited by other entries. There are thirteen types of relations
between entries that I want to store so I am using a type field in the
through table for that. Some greatly simplified code is below. This
code is working but it seems to me that in the view, i.e. the index
function, that it will hit the database a lot more than is really
necessary. I suspect there are much better ways of handling it if only
I understood django better hence this question to you. I was looking
at annotate but this isn't really aggregation so it doesn't seem like
I can use it. Does any one have any helpful advice?


class Resource(models.Model):
# entry in the bibliograpy or something related to an entry
title = models.CharField(max_length=255)
year = models.IntegerField(null=True, blank=True)
publisher = models.ForeignKey(Publisher, null=True, blank=True)
is_resource = models.BooleanField(default=False)
relations = models.ManyToManyField('self',
through='ResourceRelationship', symmetrical=False)

def __unicode__(self):
return self.title

def get_container(self):
try:
cont = ResourceRelationship.objects.get
(from_resource=self.id,
relationship=ResourceRelationship.IS_PART_OF).to_resource
except ResourceRelationship.DoesNotExist:
cont = None
return cont

class ResourceRelationship(models.Model):
relationship = models.IntegerField(choices=RELATIONSHIP_CHOICES)
from_resource = models.ForeignKey(Resource,
related_name='from_resources')
to_resource = models.ForeignKey(Resource,
related_name='to_resources')
order = models.PositiveSmallIntegerField(default=1)


def index(request):
resource_list = Resource.objects.filter(is_resource=True)
for resource in resource_list:
container = resource.container = resource.get_container()
if container:
resource.year = container.year
resource.publisher = container.publisher
return render_to_response('resources/index.html',
{'resource_list': resource_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
-~--~~~~--~~--~--~---



Re: Running Django on Tornado's HTTP server

2009-09-14 Thread Brian

I have a small Django app under development and was able to get this
running using the github update. My app runs and is very responsive
with Tornado.

Some of my admin site layout is out of whack, but it may be my
settings or my bug.  Formatting and CSS I created on my own looks good
(e.g. graphics and tables created using the Google Visualization API.)
My app is able to go out onto the web, get files downloaded through
Tornado - it feels fast ...

It's terrific to have a Python-based server that could work in both
development and production. (Tornado installs/runs fine on a Netbook
with Ubuntu!)

The real-time / asynchronous capabilities look great. Any way Django
apps can take advantage of that functionality?

Thanks for open sourcing this!

-- Brian

On Sep 13, 4:26 pm, Bret Taylor  wrote:
> I am one of the authors of Tornado (http://www.tornadoweb.org/), the
> web server/framework we built at FriendFeed that we open sourced last
> week (seehttp://bret.appspot.com/entry/tornado-web-server).
>
> The underlying non-blocking HTTP server is fairly high performance, so
> I have been working this weekend to get other frameworks like Django
> and web.py working on Tornado's server so existing projects could
> potentially benefit from the performance. To that end, I just checked
> in change to Tornado that enables you to run any WSGI-compatible
> framework on Tornado's HTTP server. You can find it in a class called
> WSGIContainer in our wsgi.py:
>
> http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>
> You will have to check out Tornado from github to get the change; it
> is not yet included in the tarball distribution.
>
> Here is a template for running a Django app on Tornado's server using
> the module:
>
>     import django.core.handlers.wsgi
>     import os
>     import tornado.httpserver
>     import tornado.ioloop
>     import tornado.wsgi
>
>     def main():
>         os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
>         application = django.core.handlers.wsgi.WSGIHandler()
>         container = tornado.wsgi.WSGIContainer(application)
>         http_server = tornado.httpserver.HTTPServer(container)
>         http_server.listen()
>         tornado.ioloop.IOLoop.instance().start()
>
>     if __name__ == "__main__":
>         main()
>
> I have only done very basic tests using the new module, so if any of
> you are interested and start using Tornado with your Django projects,
> please let us know what bugs you find so we can fix them. Any and all
> feedback is appreciated.
>
> Bret

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



Test tables not all created

2009-09-14 Thread peppergrower

I just started exploring Django's test framework, and it looks like
it'll be fantastic once I get it working.  However, while trying to
run a very simple test (just to figure out how to use the test
features), I noticed that the test database that's being created
doesn't contain all of the tables I would expect (i.e., not all of the
ones in the normal database).  Since some tables are missing, the
tests don't work.

I'm importing the models that normally go in these tables, but they
still aren't showing up.  I've read the documentation here:
http://docs.djangoproject.com/en/dev/topics/testing/ , but didn't see
anything that addresses this: it just blithely states that a test
database will be created.  I'm sure it's just something silly, but
what could I be missing that would lead to missing test tables?

peppergrower

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



value bound (choice)field

2009-09-14 Thread dimitri pater - serpia

Hello,

I am trying to get a value from a bound field (a choicefield) to a
template. Obviously form.field.value does not work. Any ideas
somebody?

thanks in advance,
dimitri

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



Image for amazon EC2

2009-09-14 Thread zweb

Can you please refer me to any good images for Linux, Django 1 or 1.1,
mysql, apache images?

or alternatively any good blog or instruction on how to host a django
based web application on EC2 with mysql backend.
--~--~-~--~~~---~--~~
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: Newbie: How to use object related to dropdown selection in django/javascript spaguetti code?

2009-09-14 Thread Samuel Lerning

Hi again,

Some progress here, but a minor problem remaining.
On selecting a foo, the page is re-rendered with the correct data
related to the selected foo.

However, the selection list (dropdown) always shows the name of the
first foo, instead of showing the name of the selected foo.
And I need it to display the name of the selected foo, after
selection.

Any help will be appreciated.

At the moment, the code looks like it:

--->foo_relatory.html




{% if show_foos_filter %}
  
  Foo: 
  
{% for foo in foos %}
  {{ foo.nome }}
{% endfor %}
  
  
  
{% endif %}





function filter(){
var formOK = false;

{% if show_foos_filter %}
formOK = CheckFoo();
{% endif %}

if (formOK == true) {
submitForm('filters');
}
}



function submitForm(formID){
var f = document.getElementById(formID);
f.submit();
}


function CheckFoo(){
combo = document.getElementById('foos_combo');
document.getElementById("input_foo").value = combo.options
[combo.selectedIndex].value;
return true;
}



>views.py

def foo_relatory(request):
.
.
.
.
selected_foo = Foo.objects.get(id=1)

if request.method == 'POST':
id_selected_foo = request.POST['foos_combo']
selected_foo = Foo.objects.get(id=id_selected_foo)
.
.
.
.

return render_to_response('foo_relatory.html',
  {'title'   : title,
   'show_filter_foos': True,
  },
  context_instance=RequestContext(request))

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



who owns djangocon.blip.tv?

2009-09-14 Thread Carl Karsten

http://djangocon.blip.tv/ has no posts, and no contact info.  Anyone
know who's it is?  seems like a good place to put the djangocon
videos.  http://django.blip.tv/ is taken too, with some odd test vids.
 Maybe http://ponycon.blip.tv/ ?

-- 
Carl K

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



nested list in templates

2009-09-14 Thread xyz69

Hello,

I have "Category" app. I use django-mptt to remember the structure od
the category tree.
I want to show this tree in nested list using generic view
(render_to_template).
I pass a category_list in extra_context and the problem starts when
want to show it.
I try something like this:

# category_list.html

{% for cat in object_list %}
{% if not cat.parent %}
{{cat.name}}
{% if cat.children.all %}
{% include "category_list_helper.html" %}
has children
{% endif %}
{% endif%}
{% endfor %}


# category_list_helper

{% for cat in cat.children.all %}
{{cat.name}}
 {% if cat.children.all %}
   {% include "category_list_helper.html"%}
 {% endif %}

{% endfor %}


So... if there is only one level of recursion, everything is ok,
but when I have subsubcategories, error happens;)

"RuntimeError at /blog/categories/
maximum recursion depth exceeded while calling a Python object"

I also google for solution, and this:
http://www.undefinedfire.com/lab/recursion-django-templates/
looks sensibly.

What do you think?
Have you ever had similar problem?

Pawel

--~--~-~--~~~---~--~~
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: retrieve groups from user object

2009-09-14 Thread Ulysses Almeida

Hi,

  I think 'user.groups' is what I want and it is already implemented (I
think I'm blind for not seeing it before). LDAPBackend does not support it
yet!

  Thanks all.

On Mon, 14 Sep 2009 13:29:46 -0400, Ulysses Almeida
 wrote:
> 
> Hi,
> 
>   I would like to retrieve all groups an user belong.
> 
>   I want to do this 'cos if the user belong to Group1 and GroupAdmin it
> will be able to manage the Group1 which he belongs, but not Group2 (for
> example).
> 
>   ... but I can't figure out how to get user's groups (something link
> user.groups being a list of groups), neither how to implement this idea
> only with permissions infrastructure.
> 
>   I'm using LDAP auth backend
(http://code.djangoproject.com/ticket/11526)
> , but I don't want to attach my code to a specific auth backend.
> 
>   Thanks in advance for any help!
> 
>
-- 
Ulysses Almeida
Analista Judiciário - Análise de Sistemas
Secretaria de Tecnologia da Informação - COINF - TRE-MS
ulysses.alme...@tre-ms.gov.br


--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread Alexandru-Emil Lupu
lol... i have answered to late ...
it seems that after all i have said the same thing as Tiago

Regards

On Mon, Sep 14, 2009 at 11:58 PM, Alexandru-Emil Lupu
wrote:

> i do not know if is database killing or not, but you could try some of
> those
>
> Person.objects.select_related(depth=2).get()
>
>
> or you could make something like
>
> Membership.objects.select_related(depth=1).get()
>
> That will perform a query on the entire membership table and related tables 
> in order to extract the values
> but you could try something like
>
> Membership.objects.distinct('person_id').select_related(depth=1).get()
>
>
> Alecs
>
>
>
>
> On Mon, Sep 14, 2009 at 11:27 PM, W.P. McNeill  wrote:
>
>>
>> Never mind.  Tiago Serafim's reply answered my question for me.
>>
>> Follow on question: say I want to make a 2-dimensional table of the
>> dates when people joined bands.  I'd have code that looks like this.
>>
>> for p in Person.objects.all():
>>for g in Group.objects.all():
>>date = Membership.objects.get(person=p, group=g).join_date
>>...
>>
>> Am I making (person x group) database calls here?  This is impression
>> I get from reading:
>>
>> http://docs.djangoproject.com/en/dev/ref/models/querysets/#id1
>>
>> Is this inefficient?  Is there a way to do this with a single database
>> call?
>>
>>
>> On Sep 14, 11:43 am, "W.P. McNeill"  wrote:
>> > Or maybe another way of asking this, since I don't want to force you
>> > to write Python code just to answer my question...
>> >
>> > If I have the music group model written as shown in the Django
>> > documentation is it possible to write a model API statement that gets
>> > me this information, or would I have to add fields to the model?
>> >
>> > Thanks.
>> >
>> > On Sep 14, 9:46 am, Alexandru-Emil Lupu  wrote:
>> >
>> >
>> >
>> > > basically you would have to make a ManyToMany relation thru a class.
>> In that
>> > > class you make m,n,date field
>> > > After that you just use a query to answer the question: Who (Paul)?
>> joined
>> > > to whom (Beatles), and after that will pop up the ManyToMany date
>> field that
>> > > will answer to question "when".
>> >
>> > > I am preety new in django my self .. and i don't know pretty well how
>> to do
>> > > it...
>> >
>> > > On Mon, Sep 14, 2009 at 6:21 PM, W.P. McNeill 
>> wrote:
>> >
>> > > > I can't figure out how to query the values of fields in a ManyToMany
>> > > > "through" table.
>> >
>> > > > For instance, say I'm working with the Beatles database in the
>> Django
>> > > > documentation (
>> http://docs.djangoproject.com/en/dev/topics/db/models/
>> > > > #extra-fields-on-many-to-many-relationships<
>> http://docs.djangoproject.com/en/dev/topics/db/models/%0A#extra-field..
>> .>).
>> > > >  I want to be able to
>> > > > query the date on which Paul joined the Beatles.  (As opposed to
>> when
>> > > > Ringo joined the Beatles, or when Paul joined Wings.)  Basically I
>> > > > want to treat the Group table as a two-dimensional array, look up:
>> >
>> > > > Group[Beatles][Paul].date_joined
>> >
>> > > > and have it return:
>> >
>> > > > date(1960, 8, 1)
>> >
>> > > > I'd think this would be easy to do, but I've been playing around
>> with
>> > > > the command-line database API and I can't figure it out.  The
>> > > > documentation I've seen describes how to use a Membership field as a
>> > > > filter criteria, but not how to look up the actual value.
>> >
>> > > --
>> > > As programmers create bigger & better idiot proof programs, so the
>> universe
>> > > creates bigger & better idiots!
>> > > I am on web:  http://www.alecslupu.ro/
>> > > I am on twitter:http://twitter.com/alecslupu
>> > > I am on linkedIn:http://www.linkedin.com/in/alecslupu
>> > > Tel: (+4)0748.543.798
>> >>
>>
>
>
> --
> As programmers create bigger & better idiot proof programs, so the universe
> creates bigger & better idiots!
> I am on web:  http://www.alecslupu.ro/
> I am on twitter: http://twitter.com/alecslupu
> I am on linkedIn: http://www.linkedin.com/in/alecslupu
> Tel: (+4)0748.543.798
>
>


-- 
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread Alexandru-Emil Lupu
i do not know if is database killing or not, but you could try some of those

Person.objects.select_related(depth=2).get()


or you could make something like

Membership.objects.select_related(depth=1).get()

That will perform a query on the entire membership table and related
tables in order to extract the values
but you could try something like

Membership.objects.distinct('person_id').select_related(depth=1).get()


Alecs




On Mon, Sep 14, 2009 at 11:27 PM, W.P. McNeill  wrote:

>
> Never mind.  Tiago Serafim's reply answered my question for me.
>
> Follow on question: say I want to make a 2-dimensional table of the
> dates when people joined bands.  I'd have code that looks like this.
>
> for p in Person.objects.all():
>for g in Group.objects.all():
>date = Membership.objects.get(person=p, group=g).join_date
>...
>
> Am I making (person x group) database calls here?  This is impression
> I get from reading:
>
> http://docs.djangoproject.com/en/dev/ref/models/querysets/#id1
>
> Is this inefficient?  Is there a way to do this with a single database
> call?
>
>
> On Sep 14, 11:43 am, "W.P. McNeill"  wrote:
> > Or maybe another way of asking this, since I don't want to force you
> > to write Python code just to answer my question...
> >
> > If I have the music group model written as shown in the Django
> > documentation is it possible to write a model API statement that gets
> > me this information, or would I have to add fields to the model?
> >
> > Thanks.
> >
> > On Sep 14, 9:46 am, Alexandru-Emil Lupu  wrote:
> >
> >
> >
> > > basically you would have to make a ManyToMany relation thru a class. In
> that
> > > class you make m,n,date field
> > > After that you just use a query to answer the question: Who (Paul)?
> joined
> > > to whom (Beatles), and after that will pop up the ManyToMany date field
> that
> > > will answer to question "when".
> >
> > > I am preety new in django my self .. and i don't know pretty well how
> to do
> > > it...
> >
> > > On Mon, Sep 14, 2009 at 6:21 PM, W.P. McNeill 
> wrote:
> >
> > > > I can't figure out how to query the values of fields in a ManyToMany
> > > > "through" table.
> >
> > > > For instance, say I'm working with the Beatles database in the Django
> > > > documentation (
> http://docs.djangoproject.com/en/dev/topics/db/models/
> > > > #extra-fields-on-many-to-many-relationships<
> http://docs.djangoproject.com/en/dev/topics/db/models/%0A#extra-field..
> .>).
> > > >  I want to be able to
> > > > query the date on which Paul joined the Beatles.  (As opposed to when
> > > > Ringo joined the Beatles, or when Paul joined Wings.)  Basically I
> > > > want to treat the Group table as a two-dimensional array, look up:
> >
> > > > Group[Beatles][Paul].date_joined
> >
> > > > and have it return:
> >
> > > > date(1960, 8, 1)
> >
> > > > I'd think this would be easy to do, but I've been playing around with
> > > > the command-line database API and I can't figure it out.  The
> > > > documentation I've seen describes how to use a Membership field as a
> > > > filter criteria, but not how to look up the actual value.
> >
> > > --
> > > As programmers create bigger & better idiot proof programs, so the
> universe
> > > creates bigger & better idiots!
> > > I am on web:  http://www.alecslupu.ro/
> > > I am on twitter:http://twitter.com/alecslupu
> > > I am on linkedIn:http://www.linkedin.com/in/alecslupu
> > > Tel: (+4)0748.543.798
> >
>


-- 
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread Tiago Serafim
Yes, it's inefficient. Yes, there's a way to do what you want:

memberships = Membership.objects.all().select_related('group', 'person')

;-)

On Mon, Sep 14, 2009 at 5:27 PM, W.P. McNeill  wrote:

>
> Is this inefficient?  Is there a way to do this with a single database
> call?
>
>

-- 
Tiago Serafim

--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread W.P. McNeill

Never mind.  Tiago Serafim's reply answered my question for me.

Follow on question: say I want to make a 2-dimensional table of the
dates when people joined bands.  I'd have code that looks like this.

for p in Person.objects.all():
for g in Group.objects.all():
date = Membership.objects.get(person=p, group=g).join_date
...

Am I making (person x group) database calls here?  This is impression
I get from reading:

http://docs.djangoproject.com/en/dev/ref/models/querysets/#id1

Is this inefficient?  Is there a way to do this with a single database
call?


On Sep 14, 11:43 am, "W.P. McNeill"  wrote:
> Or maybe another way of asking this, since I don't want to force you
> to write Python code just to answer my question...
>
> If I have the music group model written as shown in the Django
> documentation is it possible to write a model API statement that gets
> me this information, or would I have to add fields to the model?
>
> Thanks.
>
> On Sep 14, 9:46 am, Alexandru-Emil Lupu  wrote:
>
>
>
> > basically you would have to make a ManyToMany relation thru a class. In that
> > class you make m,n,date field
> > After that you just use a query to answer the question: Who (Paul)? joined
> > to whom (Beatles), and after that will pop up the ManyToMany date field that
> > will answer to question "when".
>
> > I am preety new in django my self .. and i don't know pretty well how to do
> > it...
>
> > On Mon, Sep 14, 2009 at 6:21 PM, W.P. McNeill  wrote:
>
> > > I can't figure out how to query the values of fields in a ManyToMany
> > > "through" table.
>
> > > For instance, say I'm working with the Beatles database in the Django
> > > documentation (http://docs.djangoproject.com/en/dev/topics/db/models/
> > > #extra-fields-on-many-to-many-relationships).
> > >  I want to be able to
> > > query the date on which Paul joined the Beatles.  (As opposed to when
> > > Ringo joined the Beatles, or when Paul joined Wings.)  Basically I
> > > want to treat the Group table as a two-dimensional array, look up:
>
> > > Group[Beatles][Paul].date_joined
>
> > > and have it return:
>
> > > date(1960, 8, 1)
>
> > > I'd think this would be easy to do, but I've been playing around with
> > > the command-line database API and I can't figure it out.  The
> > > documentation I've seen describes how to use a Membership field as a
> > > filter criteria, but not how to look up the actual value.
>
> > --
> > As programmers create bigger & better idiot proof programs, so the universe
> > creates bigger & better idiots!
> > I am on web:  http://www.alecslupu.ro/
> > I am on twitter:http://twitter.com/alecslupu
> > I am on linkedIn:http://www.linkedin.com/in/alecslupu
> > Tel: (+4)0748.543.798
--~--~-~--~~~---~--~~
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: inlineformset_factory and changing data set in form

2009-09-14 Thread dimitri pater - serpia

formfield_callback argument was the solution to my problem

On Mon, Sep 14, 2009 at 4:18 PM, dimitri pater - serpia
 wrote:
> Hello,
>
> Suppose we have two models:
>
> CH_AUTH = ((u'J', u'John'),(u'P', u'Peter'),(u'M', u'Marc'),)
>
> class Publisher(models.Model):
>    name = models.CharField(max_length=100)
>
> class Book(models.Model):
>    publisher = models.ForeignKey(Publisher)
>    author = models.CharField(max_length=1, choices=CH_AUTH)
>    title = models.CharField(max_length=100)
>
> in a view:
> publ = Publisher.object.get(pk=publisher_id)
> BooksInlineFormSet = inlineformset_factory(Publisher, Book, extra=1)
> formset = BooksInlineFormSet(instance=publ)
>
> formset returns the saved formset(s) and an empty form
> ie formset.forms[1]['author'] returns a html  with all authors.
> but what if I want to exclude 'Marc' from the author selection?
>
> I have been looking at the BaseInlineFormSet but got stuck.
>
> Any clues? Your help is appreciated!
>
> thank you,
> Dimitri
>



-- 
---
You can't have everything. Where would you put it? -- Steven Wright
---
please visit www.serpia.org

--~--~-~--~~~---~--~~
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: inlineformset_factory and changing data set in form

2009-09-14 Thread V

On szept. 14, 16:18, dimitri pater - serpia 
wrote:
> Hello,
>
> Suppose we have two models:
>
> CH_AUTH = ((u'J', u'John'),(u'P', u'Peter'),(u'M', u'Marc'),)
>
> class Publisher(models.Model):
>     name = models.CharField(max_length=100)
>
> class Book(models.Model):
>     publisher = models.ForeignKey(Publisher)    
>     author = models.CharField(max_length=1, choices=CH_AUTH)
>     title = models.CharField(max_length=100)
>
> in a view:
> publ = Publisher.object.get(pk=publisher_id)
> BooksInlineFormSet = inlineformset_factory(Publisher, Book, extra=1)
> formset = BooksInlineFormSet(instance=publ)
>
> formset returns the saved formset(s) and an empty form
> ie formset.forms[1]['author'] returns a html  with all authors.
> but what if I want to exclude 'Marc' from the author selection?
>
> I have been looking at the BaseInlineFormSet but got stuck.
>
> Any clues? Your help is appreciated!
>
> thank you,
> Dimitri

as formset.forms[i] is a ModelForm object you can modify it as usual

I would say
formset.forms[i].fields['author'].queryset = 
should 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: How to make Form and ModelForm choise fields to pick first entry in queryset by default?

2009-09-14 Thread V

it's just a wild guess, but what about the initial property?
http://docs.djangoproject.com/en/dev/ref/forms/fields/#initial

On szept. 14, 16:36, Dmitry Gladkov  wrote:
> By default Django make select options like this:
> -
> admin
> Testuser
>
> How to enforce Django to show it like this:
> admin
> Testuser
>
> I've managed to do so playing with form properties in view but that
> looked ugly (unfortunately I've lost the code example but you can
> trust me:))
--~--~-~--~~~---~--~~
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: Running Django on Tornado's HTTP server

2009-09-14 Thread Ismail Dhorat

Interesting, i would like to see how tornado stacks up to Lighttpd?

Regards,
Ismail

On Mon, Sep 14, 2009 at 7:29 PM, Antoni Aloy  wrote:
>
> 2009/9/13 Antoni Aloy :
>> 2009/9/13 Bret Taylor :
>>>
>>> I am one of the authors of Tornado (http://www.tornadoweb.org/), the
>>> web server/framework we built at FriendFeed that we open sourced last
>>> week (see http://bret.appspot.com/entry/tornado-web-server).
>>>
>>> The underlying non-blocking HTTP server is fairly high performance, so
>>> I have been working this weekend to get other frameworks like Django
>>> and web.py working on Tornado's server so existing projects could
>>> potentially benefit from the performance. To that end, I just checked
>>> in change to Tornado that enables you to run any WSGI-compatible
>>> framework on Tornado's HTTP server. You can find it in a class called
>>> WSGIContainer in our wsgi.py:
>>>
>>> http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>>>
>>> You will have to check out Tornado from github to get the change; it
>>> is not yet included in the tarball distribution.
>>>
>>> Here is a template for running a Django app on Tornado's server using
>>> the module:
>>>
>>>    import django.core.handlers.wsgi
>>>    import os
>>>    import tornado.httpserver
>>>    import tornado.ioloop
>>>    import tornado.wsgi
>>>
>>>    def main():
>>>        os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
>>>        application = django.core.handlers.wsgi.WSGIHandler()
>>>        container = tornado.wsgi.WSGIContainer(application)
>>>        http_server = tornado.httpserver.HTTPServer(container)
>>>        http_server.listen()
>>>        tornado.ioloop.IOLoop.instance().start()
>>>
>>>    if __name__ == "__main__":
>>>        main()
>>>
>>>
>>> I have only done very basic tests using the new module, so if any of
>>> you are interested and start using Tornado with your Django projects,
>>> please let us know what bugs you find so we can fix them. Any and all
>>> feedback is appreciated.
>>>
>>
>> We're acually using Cherrypy, so it would be quite easy to test and
>> check the performance. We'll post any issues we found.
>>
>>
> Just few numbers:
>
> ab -c 10 -t 60 http://localhost:8088/
> Executing Django with Cherrypy with 3 threads on a PPC Computer 2 CPU 2 GHz
>
> With Tornado WSGI:
> ab -c 10 -t 60 http://localhost:/
> This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
> Licensed to The Apache Software Foundation, http://www.apache.org/
>
> Benchmarking localhost (be patient)
> Completed 5000 requests
> Completed 1 requests
> Completed 15000 requests
> Completed 2 requests
> Completed 25000 requests
> Finished 25022 requests
>
>
> Server Software:        TornadoServer/0.1
> Server Hostname:        localhost
> Server Port:            
>
> Document Path:          /
> Document Length:        266 bytes
>
> Concurrency Level:      10
> Time taken for tests:   60.019 seconds
> Complete requests:      25022
> Failed requests:        0
> Write errors:           0
> Total transferred:      9333206 bytes
> HTML transferred:       6655852 bytes
> Requests per second:    416.90 [#/sec] (mean)
> Time per request:       23.987 [ms] (mean)
> Time per request:       2.399 [ms] (mean, across all concurrent requests)
> Transfer rate:          151.86 [Kbytes/sec] received
>
> Connection Times (ms)
>              min  mean[+/-sd] median   max
> Connect:        0    0   0.1      0       6
> Processing:     3   24   1.9     24      68
> Waiting:        0   24   1.9     23      68
> Total:          7   24   1.9     24      68
>
> Percentage of the requests served within a certain time (ms)
>  50%     24
>  66%     24
>  75%     24
>  80%     24
>  90%     25
>  95%     26
>  98%     27
>  99%     28
>  100%     68 (longest request)
>
>
> Using CherryPy with 3 threads (the best configuration for my computer
> in my tests)
>
>
> ab -c 10 -t 60 http://localhost:8088/
> This is ApacheBench, Version 2.3 <$Revision: 655654 $>
> Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
> Licensed to The Apache Software Foundation, http://www.apache.org/
>
> Benchmarking localhost (be patient)
> Completed 5000 requests
> Completed 1 requests
> Completed 15000 requests
> Completed 2 requests
> Finished 21500 requests
>
>
> Server Software:        CherryPy/3.0.3
> Server Hostname:        localhost
> Server Port:            8088
>
> Document Path:          /
> Document Length:        266 bytes
>
> Concurrency Level:      10
> Time taken for tests:   60.001 seconds
> Complete requests:      21500
> Failed requests:        0
> Write errors:           0
> Total transferred:      8299000 bytes
> HTML transferred:       5719000 bytes
> Requests per second:    358.33 [#/sec] (mean)
> Time per request:       27.907 [ms] (mean)
> Time per request:       2.791 [ms] (mean, across all concurrent requests)
> Transfer rate:          1

Memory usage - Django + SQLITE

2009-09-14 Thread Ismail Dhorat

Hi Guys,

My current setup for Django is as follows:

Ubuntu, with Lighttpd and running django via FCGI using TCP in
threaded mode. I a simple site, that uses SQLITE as the DB engine.

Though i have noticed that as the DB grows, the memory usage for that
particular process keeps increasing, is there any way around this to
ensure that the the memory usage stays low while the DB gets larger?
Or do you have to constantly remove records and keep the DB small?

--~--~-~--~~~---~--~~
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 ForeignKey to_field vs. db_column

2009-09-14 Thread Daniel Roseman

On Sep 14, 7:19 pm, Artur Ergashev  wrote:
> I'm working on some models for a legacy database structure, and am
> having a road_block with Foreign Keys and non-conventional names.
>
> As I understand it, if in my model I have something like:
>
> something = ForeignKey(something)
>
> then django will look for the something_id field in my table when
> looking for the relationship. However, if my table has
> anotherthing_id, I would have to explicitly define that name. The
> documentation has me believe that I would do:
>
> something = ForeignKey(something, to_field='anotherthing_id')
>
> however it doesn't seem to work this well, Django (particularly the
> admin) appears to want to find something_id. Here's the concrete case
> in my code:
>
> # site table
> # site_id (PK)
> # ...
>
> # core.Site
> class Site(models.Model):
>     id = models.IntegerField(primary_key=True, db_column='site_id')
>
> # member.User
> class User(models.Model):
>     #I already have a attribute in this model called site, so I can't
> just do site = ... as it wouldn't be descriptive enough even if I
> wouldn't have a conflict
>     last_login_site_id = models.ForeignKey('core.Site',
> to_field='site_id', related_name='site_last_login_users')
>
> The error I get:
>
> Caught an exception while rendering: (1054, "Unknown column
> 'user.last_login_site_id_id' in 'field list'")
>
> However when I change the User model to:
>
> class User(models.Model):
>     #I already have a attribute in this model called site, so I can't
> just do site = ... and it isn't descriptive anyway...
>     last_login_site_id = models.ForeignKey('core.Site',
> db_column='site_id', related_name='site_last_login_users')
>
> everything seems to work fine. This is confusing to me since I thought
> to_field was the attribute I needed, and db_column isn't documented as
> a keyword argument for ForeignKey (I assume it's inherited somehow or
> undocumented).
>
> Am I doing something horribly wrong? Or did I just misunderstand the
> model docs?
>
> Thanks!

Yes, you've misunderstood. to_field is the column in the related table
which your foreignkey is pointing to. So, for example, if your Site
table had a column site_name, and you wanted the value of your FK to
be taken from that field rather than the primary key for some reason,
you would set to_field to 'site_name'. It doesn't change the name of
the underlying field in the current model.

db_column is documented under the list of attributes which are common
to all fields, here:
http://docs.djangoproject.com/en/dev/ref/models/fields/#common-model-field-options
--
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: Context object not completely rendering

2009-09-14 Thread Peter Coles

Your code looks ok, but something is obviously wrong, you'll need to
debug this to figure out what's going wrong.

Here are some quick ideas of how to go about debugging it—if at any
point something looks or works contrary to what you'd expect then try
to figure out why that's happening and you'll probably solve this
problem:

1. in your view after you declare vars, add in something like: "raise
Exception(vars)" (with DEBUG=True in your settings file) to see what
your user object is and make sure that "vars" looks ok
2. in your template - move the {{ section }} outside of the
{% if %} statement and see if it shows
3. you can put some static text next to the variable that you know
should show up on your rendered page to make sure that it's getting
rendered by the template, like: "!TEST{{ section }}TEST!"
4. look at the html source to make sure your css or js isn't hiding
stuff or doing weird things
5. make sure that your parent template "gen_temp.html" actually has a
block called "content"
6. if nothing is working, maybe even just try (as a sanity check)
rendering a template that contains nothing but "{{ section }}"

It's probably something like a typo somewhere, but you'll have to
debug this yourself. Good luck!

--
Peter

On Sep 14, 1:40 pm, Dan06  wrote:
> Hi,
>
> Below is a function I created in my views.py file and its accompanying
> template file. For some reason, the second Name-Value Pair i.e.
> 'section':'General Info' does not render in the respective template
> file. Anyone know what is wrong? Thanks.
>
> def lookup(request, first_name, last_name):
>         user = Registrations.objects.get(last_name = last_name, first_name =
> first_name)
>         vars = { 'user' : user, 'section': 'General Info' }
>         return render_to_response('lookup.html', vars)
>
> # lookup.html template file
> {% extends "gen_temp.html" %}
>
> {% block title %}Lookup Search{% endblock %}
>
> {% block content %}
>         {% if user %}
>                 {{ section }}
>                 Your lookup search was for: {{ user.first_name }}
> {{ user.last_name }}
>                 {{ user.first_name }} can be reached at: {{ user.email 
> }}
>         {% endif %}
> {% endblock %}
>
> -Dan
--~--~-~--~~~---~--~~
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: urls.py

2009-09-14 Thread Ramanathan


I changed it to (r'^activate/(.+)/$','proj.register.views.activate')
like Mark said and things worked out.

I had been for hours looking at it. Finally got it .Thank you all.


Regards,
Ramanathan M
--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread W.P. McNeill

Or maybe another way of asking this, since I don't want to force you
to write Python code just to answer my question...

If I have the music group model written as shown in the Django
documentation is it possible to write a model API statement that gets
me this information, or would I have to add fields to the model?

Thanks.

On Sep 14, 9:46 am, Alexandru-Emil Lupu  wrote:
> basically you would have to make a ManyToMany relation thru a class. In that
> class you make m,n,date field
> After that you just use a query to answer the question: Who (Paul)? joined
> to whom (Beatles), and after that will pop up the ManyToMany date field that
> will answer to question "when".
>
> I am preety new in django my self .. and i don't know pretty well how to do
> it...
>
>
>
>
>
> On Mon, Sep 14, 2009 at 6:21 PM, W.P. McNeill  wrote:
>
> > I can't figure out how to query the values of fields in a ManyToMany
> > "through" table.
>
> > For instance, say I'm working with the Beatles database in the Django
> > documentation (http://docs.djangoproject.com/en/dev/topics/db/models/
> > #extra-fields-on-many-to-many-relationships).
> >  I want to be able to
> > query the date on which Paul joined the Beatles.  (As opposed to when
> > Ringo joined the Beatles, or when Paul joined Wings.)  Basically I
> > want to treat the Group table as a two-dimensional array, look up:
>
> > Group[Beatles][Paul].date_joined
>
> > and have it return:
>
> > date(1960, 8, 1)
>
> > I'd think this would be easy to do, but I've been playing around with
> > the command-line database API and I can't figure it out.  The
> > documentation I've seen describes how to use a Membership field as a
> > filter criteria, but not how to look up the actual value.
>
> --
> As programmers create bigger & better idiot proof programs, so the universe
> creates bigger & better idiots!
> I am on web:  http://www.alecslupu.ro/
> I am on twitter:http://twitter.com/alecslupu
> I am on linkedIn:http://www.linkedin.com/in/alecslupu
> Tel: (+4)0748.543.798
--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread Tiago Serafim
You should query Membership like you do with any other model.

paul = Person.objects.get(...)
beatles = Group.objects.get(...)

membership = Membership.objects.get(person=paul, group=beatles)
print membership.join_date

--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread W.P. McNeill

I'm afraid I didn't follow that.  Do you have some simple Python
examples?

On Sep 14, 9:46 am, Alexandru-Emil Lupu  wrote:
> basically you would have to make a ManyToMany relation thru a class. In that
> class you make m,n,date field
> After that you just use a query to answer the question: Who (Paul)? joined
> to whom (Beatles), and after that will pop up the ManyToMany date field that
> will answer to question "when".
>
> I am preety new in django my self .. and i don't know pretty well how to do
> it...
>
>
>
>
>
> On Mon, Sep 14, 2009 at 6:21 PM, W.P. McNeill  wrote:
>
> > I can't figure out how to query the values of fields in a ManyToMany
> > "through" table.
>
> > For instance, say I'm working with the Beatles database in the Django
> > documentation (http://docs.djangoproject.com/en/dev/topics/db/models/
> > #extra-fields-on-many-to-many-relationships).
> >  I want to be able to
> > query the date on which Paul joined the Beatles.  (As opposed to when
> > Ringo joined the Beatles, or when Paul joined Wings.)  Basically I
> > want to treat the Group table as a two-dimensional array, look up:
>
> > Group[Beatles][Paul].date_joined
>
> > and have it return:
>
> > date(1960, 8, 1)
>
> > I'd think this would be easy to do, but I've been playing around with
> > the command-line database API and I can't figure it out.  The
> > documentation I've seen describes how to use a Membership field as a
> > filter criteria, but not how to look up the actual value.
>
> --
> As programmers create bigger & better idiot proof programs, so the universe
> creates bigger & better idiots!
> I am on web:  http://www.alecslupu.ro/
> I am on twitter:http://twitter.com/alecslupu
> I am on linkedIn:http://www.linkedin.com/in/alecslupu
> Tel: (+4)0748.543.798
--~--~-~--~~~---~--~~
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 ForeignKey to_field vs. db_column

2009-09-14 Thread Artur Ergashev

I'm working on some models for a legacy database structure, and am
having a road_block with Foreign Keys and non-conventional names.

As I understand it, if in my model I have something like:

something = ForeignKey(something)

then django will look for the something_id field in my table when
looking for the relationship. However, if my table has
anotherthing_id, I would have to explicitly define that name. The
documentation has me believe that I would do:

something = ForeignKey(something, to_field='anotherthing_id')

however it doesn't seem to work this well, Django (particularly the
admin) appears to want to find something_id. Here's the concrete case
in my code:

# site table
# site_id (PK)
# ...

# core.Site
class Site(models.Model):
id = models.IntegerField(primary_key=True, db_column='site_id')

# member.User
class User(models.Model):
#I already have a attribute in this model called site, so I can't
just do site = ... as it wouldn't be descriptive enough even if I
wouldn't have a conflict
last_login_site_id = models.ForeignKey('core.Site',
to_field='site_id', related_name='site_last_login_users')

The error I get:

Caught an exception while rendering: (1054, "Unknown column
'user.last_login_site_id_id' in 'field list'")

However when I change the User model to:

class User(models.Model):
#I already have a attribute in this model called site, so I can't
just do site = ... and it isn't descriptive anyway...
last_login_site_id = models.ForeignKey('core.Site',
db_column='site_id', related_name='site_last_login_users')

everything seems to work fine. This is confusing to me since I thought
to_field was the attribute I needed, and db_column isn't documented as
a keyword argument for ForeignKey (I assume it's inherited somehow or
undocumented).

Am I doing something horribly wrong? Or did I just misunderstand the
model docs?

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



Context object not completely rendering

2009-09-14 Thread Dan06

Hi,

Below is a function I created in my views.py file and its accompanying
template file. For some reason, the second Name-Value Pair i.e.
'section':'General Info' does not render in the respective template
file. Anyone know what is wrong? Thanks.

def lookup(request, first_name, last_name):
user = Registrations.objects.get(last_name = last_name, first_name =
first_name)
vars = { 'user' : user, 'section': 'General Info' }
return render_to_response('lookup.html', vars)

# lookup.html template file
{% extends "gen_temp.html" %}

{% block title %}Lookup Search{% endblock %}

{% block content %}
{% if user %}
{{ section }}
Your lookup search was for: {{ user.first_name }}
{{ user.last_name }}
{{ user.first_name }} can be reached at: {{ user.email }}
{% endif %}
{% endblock %}


-Dan
--~--~-~--~~~---~--~~
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: Running Django on Tornado's HTTP server

2009-09-14 Thread Antoni Aloy

2009/9/13 Antoni Aloy :
> 2009/9/13 Bret Taylor :
>>
>> I am one of the authors of Tornado (http://www.tornadoweb.org/), the
>> web server/framework we built at FriendFeed that we open sourced last
>> week (see http://bret.appspot.com/entry/tornado-web-server).
>>
>> The underlying non-blocking HTTP server is fairly high performance, so
>> I have been working this weekend to get other frameworks like Django
>> and web.py working on Tornado's server so existing projects could
>> potentially benefit from the performance. To that end, I just checked
>> in change to Tornado that enables you to run any WSGI-compatible
>> framework on Tornado's HTTP server. You can find it in a class called
>> WSGIContainer in our wsgi.py:
>>
>> http://github.com/facebook/tornado/blob/master/tornado/wsgi.py#L188
>>
>> You will have to check out Tornado from github to get the change; it
>> is not yet included in the tarball distribution.
>>
>> Here is a template for running a Django app on Tornado's server using
>> the module:
>>
>>    import django.core.handlers.wsgi
>>    import os
>>    import tornado.httpserver
>>    import tornado.ioloop
>>    import tornado.wsgi
>>
>>    def main():
>>        os.environ["DJANGO_SETTINGS_MODULE"] = 'myapp.settings'
>>        application = django.core.handlers.wsgi.WSGIHandler()
>>        container = tornado.wsgi.WSGIContainer(application)
>>        http_server = tornado.httpserver.HTTPServer(container)
>>        http_server.listen()
>>        tornado.ioloop.IOLoop.instance().start()
>>
>>    if __name__ == "__main__":
>>        main()
>>
>>
>> I have only done very basic tests using the new module, so if any of
>> you are interested and start using Tornado with your Django projects,
>> please let us know what bugs you find so we can fix them. Any and all
>> feedback is appreciated.
>>
>
> We're acually using Cherrypy, so it would be quite easy to test and
> check the performance. We'll post any issues we found.
>
>
Just few numbers:

ab -c 10 -t 60 http://localhost:8088/
Executing Django with Cherrypy with 3 threads on a PPC Computer 2 CPU 2 GHz

With Tornado WSGI:
ab -c 10 -t 60 http://localhost:/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 1 requests
Completed 15000 requests
Completed 2 requests
Completed 25000 requests
Finished 25022 requests


Server Software:TornadoServer/0.1
Server Hostname:localhost
Server Port:

Document Path:  /
Document Length:266 bytes

Concurrency Level:  10
Time taken for tests:   60.019 seconds
Complete requests:  25022
Failed requests:0
Write errors:   0
Total transferred:  9333206 bytes
HTML transferred:   6655852 bytes
Requests per second:416.90 [#/sec] (mean)
Time per request:   23.987 [ms] (mean)
Time per request:   2.399 [ms] (mean, across all concurrent requests)
Transfer rate:  151.86 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00   0.1  0   6
Processing: 3   24   1.9 24  68
Waiting:0   24   1.9 23  68
Total:  7   24   1.9 24  68

Percentage of the requests served within a certain time (ms)
  50% 24
  66% 24
  75% 24
  80% 24
  90% 25
  95% 26
  98% 27
  99% 28
 100% 68 (longest request)


Using CherryPy with 3 threads (the best configuration for my computer
in my tests)


ab -c 10 -t 60 http://localhost:8088/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking localhost (be patient)
Completed 5000 requests
Completed 1 requests
Completed 15000 requests
Completed 2 requests
Finished 21500 requests


Server Software:CherryPy/3.0.3
Server Hostname:localhost
Server Port:8088

Document Path:  /
Document Length:266 bytes

Concurrency Level:  10
Time taken for tests:   60.001 seconds
Complete requests:  21500
Failed requests:0
Write errors:   0
Total transferred:  8299000 bytes
HTML transferred:   5719000 bytes
Requests per second:358.33 [#/sec] (mean)
Time per request:   27.907 [ms] (mean)
Time per request:   2.791 [ms] (mean, across all concurrent requests)
Transfer rate:  135.07 [Kbytes/sec] received

Connection Times (ms)
  min  mean[+/-sd] median   max
Connect:00  20.5  02999
Processing: 3   28  10.7 26 413
Waiting:3   26  10.3 24 412
Total:  3   28  23.1 263031

Percentage of the requests served within a certain time (ms)
  50% 26
  66% 

retrieve groups from user object

2009-09-14 Thread Ulysses Almeida

Hi,

  I would like to retrieve all groups an user belong.

  I want to do this 'cos if the user belong to Group1 and GroupAdmin it
will be able to manage the Group1 which he belongs, but not Group2 (for
example).

  ... but I can't figure out how to get user's groups (something link
user.groups being a list of groups), neither how to implement this idea
only with permissions infrastructure.

  I'm using LDAP auth backend (http://code.djangoproject.com/ticket/11526)
, but I don't want to attach my code to a specific auth backend.

  Thanks in advance for any help!

-- 
Ulysses Almeida
Analista Judiciário - Análise de Sistemas
Secretaria de Tecnologia da Informação - COINF - TRE-MS
ulysses.alme...@tre-ms.gov.br


--~--~-~--~~~---~--~~
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: Removing line breaks in a template

2009-09-14 Thread Bill Freeman

1. Realize that no all line boundaries are "\r\n'.

2. You might try passing in "\r\n" in a template variable in case the
filter argument handling isn't processing the backslashes:
render...(...{...newline:"\r\n",...}) in the view, or in the extra
context in the urls.py if you're using generic views, and then {{
text|cut:newline }}

3. If 2 works on some but not all newlines (see 1) you could pass two
template variables, cr and lf, and do {{ text|cut:cr|cut:nl }}.

4. If you're not using generic views, you can always strip the line
boundaries in the view:  text=text.replace("\r\n","")

5. You can always write a custom filter.

6. You probably actually want to replace the line boundary with a
space, rather than cut it, since otherwise you may run words together.

Bill

On Thu, Sep 10, 2009 at 2:47 PM, EricR86  wrote:
>
> Hello,
>
> I was wondering if it was at all possible to remove line breaks from a
> text passed in from a template variable. Ideally I'd like to do
> something like: {{ text|cut:"\r\n" }} , but that doesn't seem to work.
> I've tried googling and searching on the mailing list with no results.
>
> Thanks for your time in advance,
>
> - Eric
> >
>

--~--~-~--~~~---~--~~
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: Deploying with Apache: confused by odd PythonPath requirement

2009-09-14 Thread Mark (Nosrednakram)

Hello Dan,

CAUTION: I don't think the is the standard way of doing this but I
have found it to make my code portable and easy to implement.  Your
mileage may very but I have started removing the project name from all
of my code and for this configuration to work you would need to also.

I use the following on apache2 server where /opt/django/bancgi-prod is
the project directory and then I remove the project name from
ROOT_URLCONF in setting so it's equal = 'urls'.  Then in all
applications I import from the app and don't use project name ever.
This is important because my code is now portable.  Project name
doesn't matter except to the starting web server and the applications
can simple be used in any project without having to modify the project
name in any of the code.  I believe that by including project name in
your code you're making it hard to port and it isn't required by the
built in server or by Apache and probably not by anything else but I
don't know.  Again this works for me anyway :) but your mileage may
very.


  ServerName bancgi-prod.western.edu
  ServerAlias bancgi-prod

  
PythonPath "['/opt/django/bancgi-prod'] + sys.path"
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
SetEnv PYTHON_EGG_CACHE "/tmp"
PythonOption django.root /bancgi-prod
PythonDebug Off
Options FollowSymLinks
  


Hope this helps,
Mark


On Sep 13, 4:39 pm, Graham Dumpleton 
wrote:
> On Sep 14, 7:31 am, Dan06  wrote:
>
> > I've 'successfully' deployed django in a development environment on
> > Apache2. While, I've got it to work, I'm
> > thoroughly confused by the PythonPath setting needed for it to work.
>
> > I don't understand why I need to give the directory that contains the
> > django 'project' AND the directory that contains the django
> > 'application' (see PythonPath below), since the directory that
> > contains the django 'project' also contains the django
> > 'application' (see directory structure below).
>
> > Anyone know why I need to specify both 'project' and 'application'
> > directories?
>
> Because you haven't prefixed all your imports or module path
> references in urls.py with the name of the site.
>
> Graham
>
> > PythonPath "['/var/django_projects/', '/var/django_projects/test/'] +
> > sys.path"
>
> > Directory structure:
>
> > var/
> > | django_projects/ <--- General directory for all django work/projects
> > | | test/ <--- Django project directory created by: django-admin.py
> > startproject test
> > | | | test_app1/ <--- Django app directory created by: python
> > manage.py startapp test_app1
--~--~-~--~~~---~--~~
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: When did Paul join the Beatles?

2009-09-14 Thread Alexandru-Emil Lupu
basically you would have to make a ManyToMany relation thru a class. In that
class you make m,n,date field
After that you just use a query to answer the question: Who (Paul)? joined
to whom (Beatles), and after that will pop up the ManyToMany date field that
will answer to question "when".

I am preety new in django my self .. and i don't know pretty well how to do
it...


On Mon, Sep 14, 2009 at 6:21 PM, W.P. McNeill  wrote:

>
> I can't figure out how to query the values of fields in a ManyToMany
> "through" table.
>
> For instance, say I'm working with the Beatles database in the Django
> documentation (http://docs.djangoproject.com/en/dev/topics/db/models/
> #extra-fields-on-many-to-many-relationships).
>  I want to be able to
> query the date on which Paul joined the Beatles.  (As opposed to when
> Ringo joined the Beatles, or when Paul joined Wings.)  Basically I
> want to treat the Group table as a two-dimensional array, look up:
>
> Group[Beatles][Paul].date_joined
>
> and have it return:
>
> date(1960, 8, 1)
>
> I'd think this would be easy to do, but I've been playing around with
> the command-line database API and I can't figure it out.  The
> documentation I've seen describes how to use a Membership field as a
> filter criteria, but not how to look up the actual value.
> >
>


-- 
As programmers create bigger & better idiot proof programs, so the universe
creates bigger & better idiots!
I am on web:  http://www.alecslupu.ro/
I am on twitter: http://twitter.com/alecslupu
I am on linkedIn: http://www.linkedin.com/in/alecslupu
Tel: (+4)0748.543.798

--~--~-~--~~~---~--~~
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: download file

2009-09-14 Thread J. Cliff Dyer

On Mon, 2009-09-14 at 07:57 -0700, luca72 wrote:
> Hello i have try with cherrypy but i get this error:
> 
> def scarico(request, id):
> from cherrypy.lib.static import serve_file
> fil_da_scar = F_d.objects.get(pk=id)
> nome_file = fil_da_scar.nome_fil
> return serve_file('/home/luca111/Desktop/Luca/Webframework/
> off_bert/disegni/'+nome_file+'.pdf','application/x-download',
> 'attachment')
> 
> Traceback (most recent call last):
> 
>   File "/usr/local/lib/python2.6/site-packages/django/core/servers/
> basehttp.py", line 278, in run
> self.result = application(self.environ, self.start_response)
> 
>   File "/usr/local/lib/python2.6/site-packages/django/core/servers/
> basehttp.py", line 636, in __call__
> return self.application(environ, start_response)
> 
>   File "/usr/local/lib/python2.6/site-packages/django/core/handlers/
> wsgi.py", line 245, in __call__
> response = middleware_method(request, response)
> 
>   File "/usr/local/lib/python2.6/site-packages/django/middleware/
> common.py", line 83, in process_response
> if response.status_code == 404:
> 
> AttributeError: 'generator' object has no attribute 'status_code'
> 
> What is wrong?
> 
> Regards
> 
> Luca
> 

Well, assuming that scarico is getting called as "middleware_method
within the code, I'd have to say your problem is that cherrypy's
serve_file returns a generator object of some sort, rather than a django
HttpResponse object.  This is not surprising, as cherrypy has no reason
to interoperate properly with django.  What you need to do is either
catch the generator returned by serve_file, and adapt it to an
HttpResponse.  

Something like.


def cherrypy_to_HttpResponse(generator):
#???
return HttpResponse(*args, **kwargs)

def scarico(request, id):
# same as before
served_file = serve_file('/home/luca111/Desktop/Luca/Webframework/' 
   + 'off_bert/disegni/'+nome_file+'.pdf','application/x-download',
   'attachment')
return cherrypy_to_HttpResponse(served_file)

Or figure out a way to do it directly in django.

I'm not sure exactly what you're trying to do, but if you just return
the content of the file with an appropriate Content-type set in your
response headers, I think it will work fine.

Cheers,
Cliff



--~--~-~--~~~---~--~~
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: urls.py

2009-09-14 Thread Mark (Nosrednakram)



On Sep 14, 8:52 am, Ramanathan  wrote:
> I tried it.. but still it is not working.
>
> I am using django version 1.1.

If your view takes a parameter you need to give it a name and I
generally prepend a distinct identifier to my url so that django knows
what's going on.

(r'^activate/(?P.+)/$','proj.register.views.activate')

Which assumes your view has defined  something like

def activate(request, my_string):

I'm not sure what your true desired result is but i would try
something like the following.

(r'^media/(?P.*)$', 'django.views.static.serve',
  {'document_root': '/home/ramanathan/media'}),

This will require you to prepend media to your URL for media
requests.   This way django know the /media/path passed as to the
static server where path can be anything.

Hope this helps,
Mark

--~--~-~--~~~---~--~~
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: Development and deployment wit Git

2009-09-14 Thread Tiago Serafim
I recommend http://repositoryhosting.com/ . I needed the support a couple of
times and they were *very* responsive. The service is great and the price is
very fair.

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



Subclassing Field to Define Default Widgets

2009-09-14 Thread Mark (Nosrednakram)

Hello Django Community,

Let me explain what I'm doing:

When using ModelForm to generate forms I frequently added the same
widget/parameters to fields.  I love the flexability to be able to do
this but find it very repetitive if I'm adding the same widget and/or
options to a field on several forms.  To avoid this situation I have
subclassed fields and assigned them widgets with standard options.

The question:

Other than requiring my custom fields/widgets be available to my
applications what are the other reasons this is a good/bad practice?
The simplest example is for a password field.  By default its a
CharField and I want to assign the PasswordInput widget and  set
render_value=False).  So rather than assign the widget at the form
level I'd prefer to set it at the model level with something like.

class PasswordField(models.CharField):
"""
PasswordField

This allows be to subclass a CharField and sets it up to use the
password
widget.
"""

def formfield(self, *args, **kwargs):
kwargs['widget'] = PasswordInput(render_value=False)
return super(PasswordField, self).formfield(**kwargs)

I prefer this to setting the widget in the form because I use auto
generated forms with a simple management tool.  Checking to see if a
custom form exists is easy enough to do but for almost all cases this
seems to be more DRY to me.  Another example is for HTMLField with a
custom widget that subclasses TextField.  I use a RTEditor for
HTMLField and use them in a lot of places but in reality it's a
TextField with a custom widget.  Should I be doing this in the forms
instead of the models?  Is this a poor way to design things?  Is
creating default presentation behaviors for fields bad and does it
violate MTV?

Thanks for Feedback,
Mark

--~--~-~--~~~---~--~~
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: urls.py

2009-09-14 Thread Ramanathan

I tried it.. but still it is not working.

I am using django version 1.1.

--~--~-~--~~~---~--~~
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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Joshua Russo
You might want to check this out as a more up to date intro:
http://docs.djangoproject.com/en/dev/intro/tutorial01/#intro-tutorial01

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



When did Paul join the Beatles?

2009-09-14 Thread W.P. McNeill

I can't figure out how to query the values of fields in a ManyToMany
"through" table.

For instance, say I'm working with the Beatles database in the Django
documentation (http://docs.djangoproject.com/en/dev/topics/db/models/
#extra-fields-on-many-to-many-relationships).  I want to be able to
query the date on which Paul joined the Beatles.  (As opposed to when
Ringo joined the Beatles, or when Paul joined Wings.)  Basically I
want to treat the Group table as a two-dimensional array, look up:

Group[Beatles][Paul].date_joined

and have it return:

date(1960, 8, 1)

I'd think this would be easy to do, but I've been playing around with
the command-line database API and I can't figure it out.  The
documentation I've seen describes how to use a Membership field as a
filter criteria, but not how to look up the actual value.
--~--~-~--~~~---~--~~
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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Joshua Russo
On Mon, Sep 14, 2009 at 1:38 PM, Randy Barlow wrote:

>
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
>
> about2flip declared:
> >   File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
> > def_str_(self):
> >   ^
> > SyntaxError: invalid syntax
>
> Looks like you are missing a space between def and __str__(self).
> Should be:
>
> def __str__(self):
>
> - --
> Randy Barlow
> Software Developer
> The American Research Institute
> http://americanri.com
> 919.228.4971


Oh ya I missed that bit. Double the underscores before and after too.

--~--~-~--~~~---~--~~
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: Saving Oracle Connection across requests

2009-09-14 Thread Rafael Ferreira
If you are on 11g you can try to use this:
http://www.oracle.com/technology/tech/oci/pdf/oracledrcp11g.pdf

otherwise you can look for something like mysqlproxy for oracle (if such
thing exist).

The real question here tho is why do you care so much about reusing
connections? I can tell you that connection pooling is not all that is
cracked up to be.

- raf

On Mon, Sep 14, 2009 at 6:18 AM, lfrodrigues  wrote:

>
> Hello,
>
> I'm not sure this is possible but I would to save a oracle connection
> across several requests (like I do with a normal object)
>
> I would like to:
>
> if 'object' in request.session:
>  do stuff
> else:
>  import cx_Oracle
>  conn = cx_Oracle.connect(constring)
>  request.session['object'] = conn
>  do stuff
>
> Since this doesn't work I thought about a global variable on
> settings.py but that only works on de dev server. Apache uses multiple
> processes so the global variable has different values depending of the
> process.
>
> Any ideas how to keep a persistent connection across requests?
>
> 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: download file

2009-09-14 Thread luca72

Hello i have try with cherrypy but i get this error:

def scarico(request, id):
from cherrypy.lib.static import serve_file
fil_da_scar = F_d.objects.get(pk=id)
nome_file = fil_da_scar.nome_fil
return serve_file('/home/luca111/Desktop/Luca/Webframework/
off_bert/disegni/'+nome_file+'.pdf','application/x-download',
'attachment')

Traceback (most recent call last):

  File "/usr/local/lib/python2.6/site-packages/django/core/servers/
basehttp.py", line 278, in run
self.result = application(self.environ, self.start_response)

  File "/usr/local/lib/python2.6/site-packages/django/core/servers/
basehttp.py", line 636, in __call__
return self.application(environ, start_response)

  File "/usr/local/lib/python2.6/site-packages/django/core/handlers/
wsgi.py", line 245, in __call__
response = middleware_method(request, response)

  File "/usr/local/lib/python2.6/site-packages/django/middleware/
common.py", line 83, in process_response
if response.status_code == 404:

AttributeError: 'generator' object has no attribute 'status_code'

What is wrong?

Regards

Luca


On 2 Set, 15:19, Andrew McGregor  wrote:
> > Hello can you tell me where i can find example how to download file
> > with django
>
> CURL?
>
> http://pycurl.sourceforge.net/
--~--~-~--~~~---~--~~
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: no such table ERROR

2009-09-14 Thread Bill Freeman

Make DATABASE_NAME an absolute path.

On Mon, Sep 14, 2009 at 12:11 AM, AIM  wrote:
>
> HI,
>
> When I browse to
> http://127.0.0.1:8000/mysite/Start/
>
> I get the following error:
>
> OperationalError at /mysite/Start/
>
> no such table: wiki_page
>
> Request Method:         GET
> Request URL:    http://127.0.0.1:8000/mysite/Start/
> Exception Type:         OperationalError
> Exception Value:
>
> no such table: wiki_page (ERROR HERE)
>
> My traceback is located at the following.
> http://dpaste.com/93287/
>
> I have ALREADY done the following in the EXACT order.
>
> --mysite/urls.py
> (r'^mysite/(?P)','mysite.wiki.views.view_page' ),
>
> --mysite/settings.py
>
> DATABASE_ENGINE = 'sqlite3'
> DATABASE_NAME = 'wiki.db'
>
> INSTALLED_APPS = (
>    #'django.contrib.auth', DELETED
>    'django.contrib.contenttypes',
>    'django.contrib.sessions',
>    'django.contrib.sites',
>    'django_extensions',
>    'mysite.wiki',
> )
>
>
> --created these three tables in wiki.db
> mysite>python manage.py syncdb
>
> Creating table django_content_type
> Creating table django_session
> Creating table django_site
>
> --creates a wiki folder containing models.py and views.py
> mysite>python manage.py startapp wiki
>
> --mysite/wiki/models.py created a model
> from django.db import models
>
> class Page(models.Model):
>        name = models.CharField(max_length="20",primary_key=True)
>        content = models.TextField(blank=True)
>
> mysite>python manage.py syncdb
> Creating table wiki_page
>
>
> --wiki/views.py
> from mysite.wiki.models import Page
> from django.shortcuts import render_to_response
>
> def view_page(request, page_name):
>  try:
>    page = Page.objects.get(pk=page_name)
>  except Page.DoesNotExist:
>    return render_to_response("create.html",{"page_name" : page_name})
>
> --mysite/create.html (NEVER MADE IT THIS FAR)
> 
>  
>     {{page_name}} - Create
>  
>  
>     {{page_name}} 
>  
> 
>
>
> Then, I reboot my wsgi web server.
>
> Last  I browse to
> http://127.0.0.1:8000/mysite/Start/
>
> And, again last I get the following error:
>
> OperationalError at /mysite/Start/
>
> no such table: wiki_page
>
> Request Method:         GET
> Request URL:    http://127.0.0.1:8000/mysite/Start/
> Exception Type:         OperationalError
> Exception Value:
>
> no such table: wiki_page
>
> My traceback is located at the following.
> http://dpaste.com/93287/
>
>
> Any ideas?
>
> Thanks.
> Andre
>
>
>
> >
>

--~--~-~--~~~---~--~~
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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Joshua Russo
On Mon, Sep 14, 2009 at 1:38 PM, Joshua Russo wrote:

> On Mon, Sep 14, 2009 at 1:27 PM, about2flip  wrote:
>
>>
>> Hi:
>>
>> I am using learn django in 24 hours and I am following this example on
>> models.
>>
>> from django.db import models
>>
>> class Person(models.Model):
>>name = models.CharField('name', maxlength=200)
>>email = models.EmailField('Email', blank=True)
>>headshots = models.ImageField(upload_to='img', blank=True)
>>text = models.TextField('Desc', maxlength=500, blank=True)
>>def_str_(self):
>>return '%s' % (self.name)
>>
>> I keep getting an error when I use the command>>>python manage.py
>> syncdb (see below)
>>
>>
>> E:\djproj\ifriends>python manage.py syncdb
>> C:\Python26\lib\site-packages\MySQLdb\__init__.py:34:
>> DeprecationWarning: the se
>> ts module is deprecated
>>  from sets import ImmutableSet
>> Traceback (most recent call last):
>>  File "manage.py", line 11, in 
>>execute_manager(settings)
>>  File "C:\Python26\lib\site-packages\django\core\management
>> \__init__.py", line
>> 362, in execute_manager
>>utility.execute()
>>  File "C:\Python26\lib\site-packages\django\core\management
>> \__init__.py", line
>> 303, in execute
>>self.fetch_command(subcommand).run_from_argv(self.argv)
>>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
>> line 195,
>>  in run_from_argv
>>self.execute(*args, **options.__dict__)
>>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
>> line 221,
>>  in execute
>>self.validate()
>>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
>> line 249,
>>  in validate
>>num_errors = get_validation_errors(s, app)
>>  File "C:\Python26\lib\site-packages\django\core\management
>> \validation.py", lin
>> e 28, in get_validation_errors
>>for (app_name, error) in get_app_errors().items():
>>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
>> line 131, in
>>  get_app_errors
>>self._populate()
>>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
>> line 58, in
>> _populate
>>self.load_app(app_name, True)
>>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
>> line 74, in
>> load_app
>>models = import_module('.models', app_name)
>>  File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
>> 35, in im
>> port_module
>>__import__(name)
>>  File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
>>def_str_(self):
>>  ^
>> SyntaxError: invalid syntax
>>
>> E:\djproj\ifriends>
>>
>> Its telling me it is line 8, but I double check 5x already and it is
>> the same as the book. The book does not have an errata, so I am not
>> sure if the syntaxt is correct because I am a Freshman learning
>> django.
>>
>> thanks too all that reply with help.
>
>
> Put a space between 'def' and '_str_' and it should work. Tho you want to
> use _unicode_ instead of _str_ in django. All string output is handled as
> unicode.
>

And to perform the unicode out correctly the string in the body of your
method needs a u decoration infront of the string to indicate unicode.

return u'%s' % (self.name)

--~--~-~--~~~---~--~~
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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Randy Barlow

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

about2flip declared:
>   File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
> def_str_(self):
>   ^
> SyntaxError: invalid syntax

Looks like you are missing a space between def and __str__(self).
Should be:

def __str__(self):

- --
Randy Barlow
Software Developer
The American Research Institute
http://americanri.com
919.228.4971
-BEGIN PGP SIGNATURE-
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkquVXQACgkQw3vjPfF7QfWv0wCgpOOEuw8YRPIM9zElRgS/HG99
p7gAnRcYX4JRp/GvN/Tl658QemjYxYm6
=BAKR
-END PGP SIGNATURE-

--~--~-~--~~~---~--~~
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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Joshua Russo
On Mon, Sep 14, 2009 at 1:27 PM, about2flip  wrote:

>
> Hi:
>
> I am using learn django in 24 hours and I am following this example on
> models.
>
> from django.db import models
>
> class Person(models.Model):
>name = models.CharField('name', maxlength=200)
>email = models.EmailField('Email', blank=True)
>headshots = models.ImageField(upload_to='img', blank=True)
>text = models.TextField('Desc', maxlength=500, blank=True)
>def_str_(self):
>return '%s' % (self.name)
>
> I keep getting an error when I use the command>>>python manage.py
> syncdb (see below)
>
>
> E:\djproj\ifriends>python manage.py syncdb
> C:\Python26\lib\site-packages\MySQLdb\__init__.py:34:
> DeprecationWarning: the se
> ts module is deprecated
>  from sets import ImmutableSet
> Traceback (most recent call last):
>  File "manage.py", line 11, in 
>execute_manager(settings)
>  File "C:\Python26\lib\site-packages\django\core\management
> \__init__.py", line
> 362, in execute_manager
>utility.execute()
>  File "C:\Python26\lib\site-packages\django\core\management
> \__init__.py", line
> 303, in execute
>self.fetch_command(subcommand).run_from_argv(self.argv)
>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 195,
>  in run_from_argv
>self.execute(*args, **options.__dict__)
>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 221,
>  in execute
>self.validate()
>  File "C:\Python26\lib\site-packages\django\core\management\base.py",
> line 249,
>  in validate
>num_errors = get_validation_errors(s, app)
>  File "C:\Python26\lib\site-packages\django\core\management
> \validation.py", lin
> e 28, in get_validation_errors
>for (app_name, error) in get_app_errors().items():
>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 131, in
>  get_app_errors
>self._populate()
>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 58, in
> _populate
>self.load_app(app_name, True)
>  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
> line 74, in
> load_app
>models = import_module('.models', app_name)
>  File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
> 35, in im
> port_module
>__import__(name)
>  File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
>def_str_(self):
>  ^
> SyntaxError: invalid syntax
>
> E:\djproj\ifriends>
>
> Its telling me it is line 8, but I double check 5x already and it is
> the same as the book. The book does not have an errata, so I am not
> sure if the syntaxt is correct because I am a Freshman learning
> django.
>
> thanks too all that reply with help.


Put a space between 'def' and '_str_' and it should work. Tho you want to
use _unicode_ instead of _str_ in django. All string output is handled as
unicode.

--~--~-~--~~~---~--~~
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: python manage.py syncdb error (L@@K)

2009-09-14 Thread Daniel Roseman

On Sep 14, 3:27 pm, about2flip  wrote:
> Hi:
>
> I am using learn django in 24 hours and I am following this example on
> models.

>   File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
>     def_str_(self):
>                   ^
> SyntaxError: invalid syntax
>
> E:\djproj\ifriends>
>
> Its telling me it is line 8, but I double check 5x already and it is
> the same as the book. The book does not have an errata, so I am not
> sure if the syntaxt is correct because I am a Freshman learning
> django.
>
> thanks too all that reply with help.

You haven't checked very closely any one of those five times. You have
made three - count them - typos in that one line.

Firstly, there should be a space between 'def' and '_'.
Secondly, there should be *two* underscores before 'str'.
Thirdly, there should be two underscores *after* 'str' as well.

Fourthly, not a typo, but this book seems to be extremely out of date.
In all versions of Django more recent than 0.96 - itself more than 2
years old - you should use __unicode__ rather than __str__. Once
you've fixed the current error, you'll find that you'll get an error
on every line you've put 'maxlength' - again in all recent versions of
Django this should be 'max_length'. And this isn't to mention anything
that references the admin, which I absolutely guarantee will not work.

My advice: throw that book away and get a more recent one. But first,
read a basic introduction to programming, then a basic introduction to
Python.
--
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
-~--~~~~--~~--~--~---



How to make Form and ModelForm choise fields to pick first entry in queryset by default?

2009-09-14 Thread Dmitry Gladkov

By default Django make select options like this:
-
admin
Testuser

How to enforce Django to show it like this:
admin
Testuser

I've managed to do so playing with form properties in view but that
looked ugly (unfortunately I've lost the code example but you can
trust me:))
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



python manage.py syncdb error (L@@K)

2009-09-14 Thread about2flip

Hi:

I am using learn django in 24 hours and I am following this example on
models.

from django.db import models

class Person(models.Model):
name = models.CharField('name', maxlength=200)
email = models.EmailField('Email', blank=True)
headshots = models.ImageField(upload_to='img', blank=True)
text = models.TextField('Desc', maxlength=500, blank=True)
def_str_(self):
return '%s' % (self.name)

I keep getting an error when I use the command>>>python manage.py
syncdb (see below)


E:\djproj\ifriends>python manage.py syncdb
C:\Python26\lib\site-packages\MySQLdb\__init__.py:34:
DeprecationWarning: the se
ts module is deprecated
  from sets import ImmutableSet
Traceback (most recent call last):
  File "manage.py", line 11, in 
execute_manager(settings)
  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
362, in execute_manager
utility.execute()
  File "C:\Python26\lib\site-packages\django\core\management
\__init__.py", line
303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 195,
 in run_from_argv
self.execute(*args, **options.__dict__)
  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 221,
 in execute
self.validate()
  File "C:\Python26\lib\site-packages\django\core\management\base.py",
line 249,
 in validate
num_errors = get_validation_errors(s, app)
  File "C:\Python26\lib\site-packages\django\core\management
\validation.py", lin
e 28, in get_validation_errors
for (app_name, error) in get_app_errors().items():
  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
line 131, in
 get_app_errors
self._populate()
  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
line 58, in
_populate
self.load_app(app_name, True)
  File "C:\Python26\lib\site-packages\django\db\models\loading.py",
line 74, in
load_app
models = import_module('.models', app_name)
  File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
35, in im
port_module
__import__(name)
  File "E:\djproj\ifriends\..\ifriends\People\models.py", line 8
def_str_(self):
  ^
SyntaxError: invalid syntax

E:\djproj\ifriends>

Its telling me it is line 8, but I double check 5x already and it is
the same as the book. The book does not have an errata, so I am not
sure if the syntaxt is correct because I am a Freshman learning
django.

thanks too all that reply with help.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



inlineformset_factory and changing data set in form

2009-09-14 Thread dimitri pater - serpia

Hello,

Suppose we have two models:

CH_AUTH = ((u'J', u'John'),(u'P', u'Peter'),(u'M', u'Marc'),)

class Publisher(models.Model):
name = models.CharField(max_length=100)

class Book(models.Model):
publisher = models.ForeignKey(Publisher)
author = models.CharField(max_length=1, choices=CH_AUTH)
title = models.CharField(max_length=100)

in a view:
publ = Publisher.object.get(pk=publisher_id)
BooksInlineFormSet = inlineformset_factory(Publisher, Book, extra=1)
formset = BooksInlineFormSet(instance=publ)

formset returns the saved formset(s) and an empty form
ie formset.forms[1]['author'] returns a html  with all authors.
but what if I want to exclude 'Marc' from the author selection?

I have been looking at the BaseInlineFormSet but got stuck.

Any clues? Your help is appreciated!

thank you,
Dimitri

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



Re: SyntaxError: unexpected character after line continuation character

2009-09-14 Thread about2flip

That worked, thank you very much!

On Sep 14, 4:23 am, Tim Chase  wrote:
> >   File "C:\djproj\mysite\..\mysite\views.py", line 1
>
> >     {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss
> > \fcharset0 Arial;}}
>
> > ^
> > SyntaxError: unexpected character after line continuation character
>
> Looks like your views.py file was saved in RTF format instead of
> plain-text.  Re-save it in plain-text as .py and it should at
> least take care of this error.
>
> -tim
--~--~-~--~~~---~--~~
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: Newbie: How to use object related to dropdown selection in django/javascript spaguetti code?

2009-09-14 Thread Samuel Lerning

Hi,

Thank you so much Serafim!
I think this is the right direction. And that was a nice tip. :)

However, now, everytime I select a different foo from the list, a
blank page with a number (that I think is the id from the foo object)
is rendered.

At the moment, the view code has the following structure:

def foo_relatory(request):

   <>

   if request.method == 'POST':
foos_combo = request.POST['foos_combo']
return HttpResponse(foos_combo)

else:
return render_to_response('foo_relatory.html',
 {'title'   : title,
  'show_filter_foos': True,
 },
 context_instance=RequestContext(request))


Well, I'll be working to understand and fix this.
However, if anyone have some sugestions... I'll be happy to hear  :)

TIA,

Samuel.


On Sep 13, 9:31 pm, Tiago Serafim  wrote:
> Hi,
>
> First you should have an attribute "name" on your select. It's needed to
> pass the value when the form is submitted.
>
> If your select's name is "foos_combo", then your code you'll look like this:
>
> def foo_relatory(request):
>
>     if request.method == 'POST':
>         foos_combo = request.POST['foos_combo']
>         return HttpResponse(foos_combo)
>
>     else:
>         return render_to_response('foo_relatory.html',
>                          {'title'       : title,
>                           'show_filter_foos': True,
>                          },
>                          context_instance=RequestContext(request))
>
> HTH,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Development and deployment wit Git

2009-09-14 Thread Adam N

Orschiro,

You should definitely use a service like GitHub.com unless you have a
good reason not to.

They have all the rough edges worked out and you get a great web
interface for everything.  In addition, sharing becomes much easier if
you're working with other GitHub projects.  If/When you ever want to
leave them, you can just take your repository and move to your own
server, or elsewhere.

-Adam

On Sep 13, 12:55 pm, orschiro  wrote:
> Hello guys,
>
> I'm a single developer but since a VCS like Git has some really nice
> features, like the history, I want to use it for my webprojects I'm
> building up with Django.
>
> But there are still some points I don't understand.
>
> How do I have to set up Git?
>
> Where do I start the repository - on my local machine or on the
> server?
>
> I think it makes sense to have it on the local machine as I'm
> developing only for myself, but how do I get the project with its
> changes on my server?
>
> Very confusing. Thank you in advance. :)
>
> orschiro
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



admin interface, nginx and fawps

2009-09-14 Thread Sven Richter
Hi all,
i am running a django project with fapws (
http://github.com/william-os4y/fapws3) as server managed through nginx as
webserver (nginx just forwards to the running fapws instance).
Fapws deploys the django project as wsgi app.

Now i have a weird problem, i am using the admin interface very often and
everytime i logout and try to relog into the interface i have to restart the
fapws instance.
If i dont restart it i get the following error:
1. 502 Bad Gateway message from nginx and
2. if i return to the login screen it shows me that my browser wont accept
cookies and that i should enable them.

Before i ran the project as scgi application managed by cherokee (another
small webserver) and everything worked without problems.

Any ideas?


Greetings and thanks in advance
Sven

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



Saving Oracle Connection across requests

2009-09-14 Thread lfrodrigues

Hello,

I'm not sure this is possible but I would to save a oracle connection
across several requests (like I do with a normal object)

I would like to:

if 'object' in request.session:
 do stuff
else:
 import cx_Oracle
 conn = cx_Oracle.connect(constring)
 request.session['object'] = conn
 do stuff

Since this doesn't work I thought about a global variable on
settings.py but that only works on de dev server. Apache uses multiple
processes so the global variable has different values depending of the
process.

Any ideas how to keep a persistent connection across requests?

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: readonly forms

2009-09-14 Thread Jeff Green
It would be nice to get something like this into django. I have used
something similar for my readonly fields.

On Mon, Sep 14, 2009 at 6:14 AM, Thomas Guettler  wrote:

>
> hi,
>
> I develop intranet apps with a lot of forms. Sometimes I need
> to render them as readonly. I use snippet 1682 (see below) to make
> widgets readonly.
>
> This way you can use the same code for viewing and editing a form.
>
> Are more django user using something like this? If yes, it would
> be nice to get this in to django (or contrib).
>
> [1]
> http://www.djangosnippets.org/snippets/1682/
>
> --
> Thomas Guettler, http://www.thomas-guettler.de/
> E-Mail: guettli (*) thomas-guettler + de
>
> >
>

--~--~-~--~~~---~--~~
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: render a table

2009-09-14 Thread Tiago Serafim
Hi,

What you want is usually done using cycle:
http://docs.djangoproject.com/en/dev/ref/templates/builtins/#cycle



On Mon, Sep 14, 2009 at 9:57 AM, luca72  wrote:

>
> hello i need to render a table where i need to separate a odd colum to
> even column
>
> my wrong idea
> 
>
>  
> File Name
> Size 
>  
>
>  {% for m in tutti %}
>{% if {{m.id}} even %}
>
>{% else %}
>
>{% endif %}
>  {{m.nome_fil}}
>  {{m.lungh}}
>
>  {% endfor %}
>  
>
> can you help me to write it
>
> Thanks Luca
> >
>


-- 
Tiago Serafim

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



render a table

2009-09-14 Thread luca72

hello i need to render a table where i need to separate a odd colum to
even column

my wrong idea


  
 File Name
 Size 
  

  {% for m in tutti %}
{% if {{m.id}} even %}

{% else %}

{% endif %}
  {{m.nome_fil}}
  {{m.lungh}}

  {% endfor %}
  

can you help me to write it

Thanks Luca
--~--~-~--~~~---~--~~
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: PyFacebook and python-twitter

2009-09-14 Thread Rodrigo Cea

Most of the time, if you don't know how / can't install them, you can
simply drop a library into your Django project directory and it will
just work.

On Sep 13, 1:36 pm, Chris Babcock  wrote:
> On Sun, 13 Sep 2009 10:21:41 -0600
>
> Adam Olsen  wrote:
> > On Sun, Sep 13, 2009 at 9:54 AM, simba  wrote:
>
> > > I am looking for hosting that supports both of the above library. i
> > > have no idea on how to have these two libraries on shared hosting.
> > > Please Help!!
>
> > I've got python-twitter installed on my webfaction account.  I'm sure
> > it would be no trouble at all to install PyFacebook as well.
>
> Right, those are just libraries that provide API access over the
> existing HTTP connection. If python hosting is enabled then there will
> be no problems with those specific libraries. Asking customer service
> about support for such will only confuse them because it's an
> application level that's completely irrelevant to their service.
>
> Chris Babcock
>
>  signature.asc
> < 1KViewDownload
--~--~-~--~~~---~--~~
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: newbye question

2009-09-14 Thread Doug Blank
On Mon, Sep 14, 2009 at 7:17 AM, Nicola Manica wrote:

> Hi, I'm a student that try to learn geodjango.
> I have the following code in one view:
> ...
> for t_path in path.the_geom:
>   print t_path.json
>   print t_path.wkt
>   print t_path.kml
> ...
>
> path.the_geom is a multilinestring.
> The output that I obtain is
> ...
> { "type": "LineString", "coordinates": [ [ 11.128620, 46.056345 ], [
> 11.128456, 46.056653 ], [ 11.128398, 46.056771 ] ] }
> LINESTRING (11.12862023 46.056345100015, 11.12845566
> 46.05665337, 11.12839815 46.05677077)
> 11.1286202,46.0563451,0 11.1284556,46.0566533,0
> 11.1283982,46.056771,0
> 
>
> json is correct and also wkt.
> But kml? Is it correct? Why some points have coordinates equal to zero?
> Thank for your help
>

Looks like x,y,z coordinates if I were guessing. If you had elevation data,
maybe it wouldn't be zeros.

-dsb


> Nicola
>
>
>
>
>
> >
>

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



newbye question

2009-09-14 Thread Nicola Manica
Hi, I'm a student that try to learn geodjango.
I have the following code in one view:
...
for t_path in path.the_geom:
  print t_path.json
  print t_path.wkt
  print t_path.kml
...

path.the_geom is a multilinestring.
The output that I obtain is
...
{ "type": "LineString", "coordinates": [ [ 11.128620, 46.056345 ], [
11.128456, 46.056653 ], [ 11.128398, 46.056771 ] ] }
LINESTRING (11.12862023 46.056345100015, 11.12845566
46.05665337, 11.12839815 46.05677077)
11.1286202,46.0563451,0 11.1284556,46.0566533,0
11.1283982,46.056771,0


json is correct and also wkt.
But kml? Is it correct? Why some points have coordinates equal to zero?
Thank for your help
Nicola

--~--~-~--~~~---~--~~
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 and model field translations

2009-09-14 Thread andreas schmid

hi list,

i have to develop a multilingual site and it works well on a single
language now... but i have to do it for 3 languages translating some
fields of the models.

can you give me some tips for good available apps?

my usecase is very simple. if a model has fields

* title
* description
* body

i need to translate  description and body, title (==slug) will remain
the same. the fact is that only one language should be required, the
others are optional and if a visitor looks at a content thats not
translated in the current language it should output a link to the
canonical language.

what is actually the best app to achieve that?

--~--~-~--~~~---~--~~
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: Zip multiple files into a zipped folder for download?

2009-09-14 Thread DjangoRocks

To Dj Gilcrease:
hi, the link which u have sent me expired.

May i know if you can repaste the code again if it is not too much
trouble for u?

Best Regards,
Eugene

On Sep 4, 11:11 pm, Dj Gilcrease  wrote:
> Here is how I do ithttp://dpaste.com/89530/
>
> I am using a View class that I wrote to make my life easier so it wont
> directly translate to a standard view function but it should give you
> enough details to get you started
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: SyntaxError: unexpected character after line continuation character

2009-09-14 Thread Ajit jena
Hello,

 In url.py module

Try this

urlpatterns = patterns('',

(r'^$', '..views.hello'),

)

 instead of

from mysite.views import hello

urlpatterns = patterns('',
   ('^hello/$', hello),
)

I hope this will fix ur issue.


Thanks,
 Ajit

On Mon, Sep 14, 2009 at 1:04 PM, about2flip  wrote:

>
> I am learning from djangobook.com using the 2edition online ver. I am
> doing my first view
>
> from django.http import HttpResponse
>
> def hello(request):
>return HttpResponse("Hello world")
> --
> and this is my urls.py file:
>
> from django.conf.urls.defaults import *
> from mysite.views import hello
>
> urlpatterns = patterns('',
>('^hello/$', hello),
>
> )
>
> 
>
> sorry for the long error post but when I run this views.py on both my
> desktop and laptop OS windows XP SP2 & 3, I get this error:
>
> Traceback (most recent call last):
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 279, in run
>self.result = application(self.environ, self.start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\servers
> \basehttp.py", line 651, in __call__
>return self.application(environ, start_response)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
> line 241, in __call__
>response = self.get_response(request)
>
>  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
> line 73, in get_response
>response = middleware_method(request)
>
>  File "C:\Python26\lib\site-packages\django\middleware\common.py",
> line 56, in process_request
>if (not _is_valid_path(request.path_info) and
>
>  File "C:\Python26\lib\site-packages\django\middleware\common.py",
> line 142, in _is_valid_path
>urlresolvers.resolve(path)
>
>  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
> line 294, in resolve
>return get_resolver(urlconf).resolve(path)
>
>  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
> line 216, in resolve
>for pattern in self.url_patterns:
>
>  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
> line 245, in _get_url_patterns
>patterns = getattr(self.urlconf_module, "urlpatterns",
> self.urlconf_module)
>
>  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
> line 240, in _get_urlconf_module
>self._urlconf_module = import_module(self.urlconf_name)
>
>  File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
> 35, in import_module
>__import__(name)
>
>  File "C:\djproj\mysite\..\mysite\urls.py", line 2, in 
>from mysite.views import hello
>
>  File "C:\djproj\mysite\..\mysite\views.py", line 1
>
>{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss
> \fcharset0 Arial;}}
>
> ^
> SyntaxError: unexpected character after line continuation character
>
>
> I uninstalled and reinstalled my python and django. I am following
> every detail of the tutorial. I don't understand why I keep getting
> this error.
>
> I appreciate your help.
> >
>

--~--~-~--~~~---~--~~
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: get current URL

2009-09-14 Thread Peter Bengtsson

Perhaps it's this you're looking for:
current_url = request.build_absolute_uri()

On 14 Sep, 01:12, Shuge Lee  wrote:
> How to get current URL ?
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



readonly forms

2009-09-14 Thread Thomas Guettler

hi,

I develop intranet apps with a lot of forms. Sometimes I need
to render them as readonly. I use snippet 1682 (see below) to make
widgets readonly.

This way you can use the same code for viewing and editing a form.

Are more django user using something like this? If yes, it would
be nice to get this in to django (or contrib).

[1]
http://www.djangosnippets.org/snippets/1682/

-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

--~--~-~--~~~---~--~~
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-admin.py the system cannot execute the specified program

2009-09-14 Thread Peter Bengtsson

about2flip
You have to go through the python tutorial I'm afraid.
Python files must be written in plain text so you have to use
something like Notepad.

On 14 Sep, 08:50, about2flip  wrote:
> Thanks for reply. No I get:
> SyntaxError: unexpected character after line continuation character
>
> I am running it from my command prompt:>>python hello.py
>
> Is that correct?
>
> On Sep 13, 10:29 pm, Karen Tracey  wrote:
>
> > On Sun, Sep 13, 2009 at 3:09 PM, about2flip  wrote:
>
> > > I am learning django, and I am having doubts if it is worth it. I am
> > > trying to startproject and I keep getting the system cannot execute
> > > the specified program error at my command prompt. I would type:
>
> > > django-admin.py startproject name
>
> > > and then I get the error. I am using python 2.6, django 1.1 on XP SP2
> > > machine.
>
> > > Thanks for your help on what to do to fix this issue
>
> > "Cannot execute the specified program" generally means the system can't find
> > some DLL needed for the program.  Django doesn't have any DLLs, so I suspect
> > your python installation may be the cause of the problem.  Can you run any
> > python program?  For example if you create a hello.py file with contents:
>
> > print 'hello'
>
> > Can you run it?
>
> > Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: filter on entries from a certain user

2009-09-14 Thread Peter Bengtsson



On 14 Sep, 09:24, Peter Newman 
wrote:
> Ok i am a bit further. The above only works with Google's
> authentication. However I want to use Django authentication. Is there
> a way to add the current user to the model during creation of the
> entity? There must be something similar as auro_current_user_add you
> would think?
>
There isn't. The current logged in user is available from the request
which is something you only have in views.
The models is just about mapping SQL to python classes.

> On Sep 13, 4:55 pm, Peter Bengtsson  wrote:
>
> > I dont know what db.UserProperty() is but my guess is that that's
> > something related to the model.
> > Your form doesn't understand that so it defaults to None.
> > If you omit the field owner from the form, perhaps the form won't
> > attempt to fiddle with this and then the model is allowed to do it's
> > magic.
> > Something like this:
>
> > class ContactForm(forms.ModelForm):
> >     class Meta:
> >         model = Contact
> >         exclude = ('owner',)
>
> > On Sep 13, 9:06 am, Peter Newman 
> > wrote:
>
> > > Guys -
>
> > > I have
> > > class Contact(db.Model):
> > >     person = db.ReferenceProperty(Person)
> > >     contact_date = db.DateTimeProperty(auto_now_add=True)
> > >     remarks = db.TextProperty()
> > >     owner = db.UserProperty(auto_current_user_add=True)
>
> > > and a simple form
> > > class ContactForm(forms.ModelForm):
> > >     class Meta:
> > >         model = Contact
>
> > > but when i add a record owner remains None??? what am i doing wrong?
--~--~-~--~~~---~--~~
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: Date Field in ModelForm

2009-09-14 Thread Jianjun

Thanks, It solve my question also. It's ok in Django 1.02, but after I
migrate to 1.1, I meet the issue.

On Sep 14, 1:43 am, Daniel Roseman  wrote:
> On Sep 9, 12:07 pm, mettwoch  wrote:
>
> > Here is the definition of the field:
>
> >     date_due       = models.DateField(auto_now_add=True)
>
> I'd guess that the problem is the auto_now_add. When that's set, the
> field is not editable (because the date can only be set at creation).
> So the field is by default excluded from the form - but you've
> explicitly stated you want that field showing, hence the error.
>
> So there is probably a bug, but the bug is that it should raise an
> explicit exception when you try and add a non-editable field to a
> form.
> --
> 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: Does Django use prepared statement when generating SQL for postgresql?

2009-09-14 Thread Luca Ferroni

Continuation wrote:
> If not, is there a way to do it?

+ 1

Some time ago, when I searched for them I found a snippet or some 
testing code.
Now I can't find it anymore.

I am going to develop something that would make the user able to use 
prepared statement,
but obviously I'd like to know if someone has already done something to 
use as a starting point.

TIA
fero

-- 
Potranno toglierci la vita, ma non ci toglieranno mai ... la LIBERTA' !!
Luca Ferroni http://pdp.linux.it/~fero
PDP FSUG http://pdp.linux.it


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



Re: filter on entries from a certain user

2009-09-14 Thread Peter Newman

Ok i am a bit further. The above only works with Google's
authentication. However I want to use Django authentication. Is there
a way to add the current user to the model during creation of the
entity? There must be something similar as auro_current_user_add you
would think?

On Sep 13, 4:55 pm, Peter Bengtsson  wrote:
> I dont know what db.UserProperty() is but my guess is that that's
> something related to the model.
> Your form doesn't understand that so it defaults to None.
> If you omit the field owner from the form, perhaps the form won't
> attempt to fiddle with this and then the model is allowed to do it's
> magic.
> Something like this:
>
> class ContactForm(forms.ModelForm):
>     class Meta:
>         model = Contact
>         exclude = ('owner',)
>
> On Sep 13, 9:06 am, Peter Newman 
> wrote:
>
>
>
> > Guys -
>
> > I have
> > class Contact(db.Model):
> >     person = db.ReferenceProperty(Person)
> >     contact_date = db.DateTimeProperty(auto_now_add=True)
> >     remarks = db.TextProperty()
> >     owner = db.UserProperty(auto_current_user_add=True)
>
> > and a simple form
> > class ContactForm(forms.ModelForm):
> >     class Meta:
> >         model = Contact
>
> > but when i add a record owner remains None??? what am i doing wrong?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: SyntaxError: unexpected character after line continuation character

2009-09-14 Thread Tim Chase

>   File "C:\djproj\mysite\..\mysite\views.py", line 1
> 
> {\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss
> \fcharset0 Arial;}}
> 
> ^
> SyntaxError: unexpected character after line continuation character


Looks like your views.py file was saved in RTF format instead of 
plain-text.  Re-save it in plain-text as .py and it should at 
least take care of this error.

-tim



--~--~-~--~~~---~--~~
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-admin.py the system cannot execute the specified program

2009-09-14 Thread about2flip

Thanks for reply. No I get:
SyntaxError: unexpected character after line continuation character

I am running it from my command prompt:>>python hello.py

Is that correct?



On Sep 13, 10:29 pm, Karen Tracey  wrote:
> On Sun, Sep 13, 2009 at 3:09 PM, about2flip  wrote:
>
> > I am learning django, and I am having doubts if it is worth it. I am
> > trying to startproject and I keep getting the system cannot execute
> > the specified program error at my command prompt. I would type:
>
> > django-admin.py startproject name
>
> > and then I get the error. I am using python 2.6, django 1.1 on XP SP2
> > machine.
>
> > Thanks for your help on what to do to fix this issue
>
> "Cannot execute the specified program" generally means the system can't find
> some DLL needed for the program.  Django doesn't have any DLLs, so I suspect
> your python installation may be the cause of the problem.  Can you run any
> python program?  For example if you create a hello.py file with contents:
>
> print 'hello'
>
> Can you run it?
>
> Karen
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



SyntaxError: unexpected character after line continuation character

2009-09-14 Thread about2flip

I am learning from djangobook.com using the 2edition online ver. I am
doing my first view

from django.http import HttpResponse

def hello(request):
return HttpResponse("Hello world")
--
and this is my urls.py file:

from django.conf.urls.defaults import *
from mysite.views import hello

urlpatterns = patterns('',
('^hello/$', hello),

)



sorry for the long error post but when I run this views.py on both my
desktop and laptop OS windows XP SP2 & 3, I get this error:

Traceback (most recent call last):

  File "C:\Python26\lib\site-packages\django\core\servers
\basehttp.py", line 279, in run
self.result = application(self.environ, self.start_response)

  File "C:\Python26\lib\site-packages\django\core\servers
\basehttp.py", line 651, in __call__
return self.application(environ, start_response)

  File "C:\Python26\lib\site-packages\django\core\handlers\wsgi.py",
line 241, in __call__
response = self.get_response(request)

  File "C:\Python26\lib\site-packages\django\core\handlers\base.py",
line 73, in get_response
response = middleware_method(request)

  File "C:\Python26\lib\site-packages\django\middleware\common.py",
line 56, in process_request
if (not _is_valid_path(request.path_info) and

  File "C:\Python26\lib\site-packages\django\middleware\common.py",
line 142, in _is_valid_path
urlresolvers.resolve(path)

  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
line 294, in resolve
return get_resolver(urlconf).resolve(path)

  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
line 216, in resolve
for pattern in self.url_patterns:

  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
line 245, in _get_url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns",
self.urlconf_module)

  File "C:\Python26\lib\site-packages\django\core\urlresolvers.py",
line 240, in _get_urlconf_module
self._urlconf_module = import_module(self.urlconf_name)

  File "C:\Python26\lib\site-packages\django\utils\importlib.py", line
35, in import_module
__import__(name)

  File "C:\djproj\mysite\..\mysite\urls.py", line 2, in 
from mysite.views import hello

  File "C:\djproj\mysite\..\mysite\views.py", line 1

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss
\fcharset0 Arial;}}

^
SyntaxError: unexpected character after line continuation character


I uninstalled and reinstalled my python and django. I am following
every detail of the tutorial. I don't understand why I keep getting
this error.

I appreciate your help.
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---