please see

2008-05-16 Thread @lirez@

please click here

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



Re: Get just one object id at the time in view assignment issue.

2008-05-16 Thread Jorge Romo

I feel I'm getting close to an answer... I hope you guys can help me
out...

I get this TypeError: Records() takes exactly 3 non-keyword arguments
(2 given)

def Records (request, UserName, Name):
gamer = Artist.objects.get(UserName=UserName)
record = Record.objects.get(Name=Name)
tags = Tag.objects.get_for_object(record)
try:
records = artist.record_set.all()
except Record.DoesNotExist:
records = None
   ...

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



Re: In qryset refactor did output of following change?

2008-05-16 Thread ydjango

adding to it.
earlier I could do unassigned_contacts.count()
now I get error  "Cannot add count col with multiple cols in 'select'"


On May 16, 8:15 pm, ydjango <[EMAIL PROTECTED]> wrote:
> In qryset refactor branch would the output of following changed?
>
> unassigned_contacts =  Contacts.values('id','last_name',
> 'first_name').filter(group__exact=my_group).exclude(pk__in=assignedparts)
>
> where assignedpart=[] and then loaded before the the above statement
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



ability to show intermediate results before final response

2008-05-16 Thread RaviKondamuru

Hi,
How do i make my django app to show intermediate results/ steps before
showing the final response. My script inherently takes a lot of time.
I was wondering if there is a way to engage the user by showing
partial intermediate results before showing the final response.
thanks,
Ravi.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



In qryset refactor did output of following change?

2008-05-16 Thread ydjango


In qryset refactor branch would the output of following changed?

unassigned_contacts =  Contacts.values('id','last_name',
'first_name').filter(group__exact=my_group).exclude(pk__in=assignedparts)

where assignedpart=[] and then loaded before the the above statement


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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread ydjango

Hahahaha, thats good friday night humor. I look forward to reading
your upcoming book. Hopefully it has the same humor.

On point 7) what about a navy seal who want to retire and start a
software business, how do I design a selection system to avoid those.
I do not want future competitor snooping around my code.
I would have preferred Himalaya, But it is between india and china.
Cannot trust those guys either. They are taking away all our jobs and
now code too. No way.


thanks
Ashish

On May 16, 11:11 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, May 16, 2008 at 11:52 AM, ydjango <[EMAIL PROTECTED]> wrote:
> > I do not want to make it easy for some one who breaks in , either a
> > outsider or may be an rougue hosting provider employee or contractor,
> > to easily get access to all the information - data and code.
>
> Again: if this is your worry, you have bigger problems. Allow me to
> suggest an alternate method:
>
> (satire begins here, for the humor-impaired)
>
> 1. Physically obtain the server upon which the code is stored. Write
> random data to the relevant sectors of the hard drive seven times
> over, then write zeroes to it seven times over, then write random data
> again.
>
> 2. Physically destroy the hard drive. Sledgehammers are good for this.
>
> 3. Place the shards of the hard drive into a vat of highly caustic acid.
>
> 4. Once the shards have dissolved, burn the resulting acidic liquid.
> Be sure to capture the smoke.
>
> 5. Cool the smoke until it turns back to ash. Mix the ash into the
> center of a reinforced concrete slab, at least 27 cubic feet in
> volume.
>
> 6. If you have access to sufficient technology, launch the concrete
> slab into space, on a course to collide with the Sun or (better) with
> any singularity which happens to be nearby. The singularity is best
> because -- even though it may not guarantee destruction of the
> information -- the subjective time to observe the rocket crossing the
> event horizon, from the frame of reference of a person some distance
> from it, will be effectively infinite, causing most attackers to give
> up.
>
> 7. If you do not have access to sufficient technology, have the
> concrete slab stored in a nuclear-hardened bunker, with no Internet
> connection, in a room using biometric identification keyed to
> yourself, and with the whole complex guarded 24/7 by US Navy SEALs.
> Maintain this watch until the technology available to complete step
> (6) becomes available to you.
>
> Once you've completed this process, your application code will be
> safe, for a reasonable value of "safe".
>
> (satire ends here)
>
> Or you could just find a host who properly sets up file permissions so
> that random people can't access your application code. Unless you own
> and personally supervise all of the following you will be susceptible
> to rogue employees: the server, the rack in which it's located and the
> datacenter in which the rack is found. Many people do not find that
> the perceived security gains of doing so outweigh the financial and
> maintenance drawbacks. YMMV.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: dúvida

2008-05-16 Thread HILAL AY
*

ı 'm  to kid someone, kid, joke.
*

17 Mayıs 2008 Cumartesi 05:47 tarihinde HILAL AY <[EMAIL PROTECTED]>
yazmış:

> siz neden aranızda ispanyolca konuşuyorsunuz bakalım ha?
>
> 2008/4/30 Andrews Medina <[EMAIL PROTECTED]>:
>
>
>> On Wed, Apr 30, 2008 at 8:01 AM, pauloleandro <[EMAIL PROTECTED]>
>> wrote:
>> >
>> >  Bom dia, queria saber se o Django só aceita a linguagem Python, se é
>> >  um framework desenvolido somente para esta linguagem??
>> >
>>
>> Sim. O Django foi desenvolvido em Python e só é possível utilizar ele
>> com Python.
>>
>> []'s
>> --
>> Andrews Medina
>> www.andrewsmedina.com
>>
>> >>
>>
>

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



Re: dúvida

2008-05-16 Thread HILAL AY
siz neden aranızda ispanyolca konuşuyorsunuz bakalım ha?

2008/4/30 Andrews Medina <[EMAIL PROTECTED]>:

>
> On Wed, Apr 30, 2008 at 8:01 AM, pauloleandro <[EMAIL PROTECTED]>
> wrote:
> >
> >  Bom dia, queria saber se o Django só aceita a linguagem Python, se é
> >  um framework desenvolido somente para esta linguagem??
> >
>
> Sim. O Django foi desenvolvido em Python e só é possível utilizar ele
> com Python.
>
> []'s
> --
> Andrews Medina
> www.andrewsmedina.com
>
> >
>

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



How to use a string in filter()

2008-05-16 Thread M.Ganesh

Hi All,

I am back with another query

I have this (generic) view function

--8><
def object_list(request, object, filter_string = None):
if filter_string:
object_list = object.objects.filter(filter_string)
else:
object_list = object.objects.all()
   
return render_to_response(object.__name__ + '_list.html',
  {object.__name__ + '_list': object_list},
  RequestContext(request))
--8><

Now this function works when I don't pass on the filter_string, and I 
get the entire object list. But when I pass on a value for filter_string 
(say 'entity=2') I get this error :

'unicode' object has no attribute 'get_sql'


How do I pass strings to filter_string and get a filtered object list?

Thanks in advance

Ganesh


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



django-tagging: How to generate a TagField input form in a template?

2008-05-16 Thread [EMAIL PROTECTED]

This question is related to the django-tagging application.

I've added a TagField to my model, and it is working properly from the
admin interface.  However, I'd like to create a simple tag input field
in my templates so users can add tags for a particular model.  I don't
want to create a form for the entire model, just the tagging.  Has
anyone had experience with this?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread Steven Armstrong

James Bennett wrote on 05/16/08 20:11:
> On Fri, May 16, 2008 at 11:52 AM, ydjango <[EMAIL PROTECTED]> wrote:
>> I do not want to make it easy for some one who breaks in , either a
>> outsider or may be an rougue hosting provider employee or contractor,
>> to easily get access to all the information - data and code.
> 
> Again: if this is your worry, you have bigger problems. Allow me to
> suggest an alternate method:
> 
> (satire begins here, for the humor-impaired)
> 
> 1. Physically obtain the server upon which the code is stored. Write
> random data to the relevant sectors of the hard drive seven times
> over, then write zeroes to it seven times over, then write random data
> again.
> 
> 2. Physically destroy the hard drive. Sledgehammers are good for this.
> 
> 3. Place the shards of the hard drive into a vat of highly caustic acid.
> 
> 4. Once the shards have dissolved, burn the resulting acidic liquid.
> Be sure to capture the smoke.
> 
> 5. Cool the smoke until it turns back to ash. Mix the ash into the
> center of a reinforced concrete slab, at least 27 cubic feet in
> volume.
> 
> 6. If you have access to sufficient technology, launch the concrete
> slab into space, on a course to collide with the Sun or (better) with
> any singularity which happens to be nearby. The singularity is best
> because -- even though it may not guarantee destruction of the
> information -- the subjective time to observe the rocket crossing the
> event horizon, from the frame of reference of a person some distance
> from it, will be effectively infinite, causing most attackers to give
> up.
> 
> 7. If you do not have access to sufficient technology, have the
> concrete slab stored in a nuclear-hardened bunker, with no Internet
> connection, in a room using biometric identification keyed to
> yourself, and with the whole complex guarded 24/7 by US Navy SEALs.
> Maintain this watch until the technology available to complete step
> (6) becomes available to you.
> 
> Once you've completed this process, your application code will be
> safe, for a reasonable value of "safe".
> 
> (satire ends here)
> 
> Or you could just find a host who properly sets up file permissions so
> that random people can't access your application code. Unless you own
> and personally supervise all of the following you will be susceptible
> to rogue employees: the server, the rack in which it's located and the
> datacenter in which the rack is found. Many people do not find that
> the perceived security gains of doing so outweigh the financial and
> maintenance drawbacks. YMMV.
> 
> 

James, your the man :-)

I would have suggested:
Book a trip to the himalaya (well maybe after china has stopped being a 
PITA). March all the way to the top (make sure no CIA satellites are 
watching you). Dig a deep hole, say 100 foot deep, then barry your code 
in the hole. Then fill it up (again, check that those evil nasty 
satellites aren't watching), and go back home with the good feeling that 
  your code, that nobody else on this planet could have written in such 
an elegant, perfect way will never be found and used by anybody.

;-)

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



Re: Reference to the url of the current page in a template

2008-05-16 Thread M.Ganesh

Scott Moonen wrote:
> Ganesh,
>
> First ensure that your TEMPLATE_CONTEXT_PROCESSORS contains:
>
> TEMPLATE_CONTEXT_PROCESSORS = (
>   . . .
> 'django.core.context_processors.request',
>   . . .
> )
>
> Then you can use the variable {{ request.path }} in your templates, 
> assuming that the URLs are all on the same host.  If not, you'll need 
> to use something like {{ request.META.HTTP_HOST }}://{{ request.path }}.
>
>   -- Scott
>
>
> On Fri, May 16, 2008 at 12:58 PM, M.Ganesh <[EMAIL PROTECTED] 
> > wrote:
>
>
> Hi,
>
> I don't know how to clearly explain what I want to know. Let me
> try once
> again...
>
> I have a small controlpanel page which I include in all my other
> pages.
> This control panel page has got a link to 'login' page. Users are
> allowed to view the pages without login, but they have to login if
> they
> want to make any changes to the data. So if somebody realises he wants
> to change the data he is currently viewing, he will click the login
> link. Now I want him to be brought back to the page he was viewing
> before logging in. The trouble is because the 'login' link is in a
> template which will get included to a arbitrary page. In other words :
>
> #my controlpane.html
>
> {% if user.is_anonymous %}
>Welcome 
>   Please login
>login
> {% else %}
>blah blah
> {% endif %}
>
>
> Regards Ganesh
>
Hi Alex and Scott,
That worked like a charm. Thanks a ton.

My next task is to use this path to redirect. I'll get back if need more 
help

Regards Ganesh


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



Re: Django and Linux distros

2008-05-16 Thread Steven Armstrong

JonSidnell wrote on 05/16/08 12:24:
> Hi everyone
> 
> I'm suddenly struck by the notion that I would like to be dev'ing
> Django on Linux of some flavour rather than Windows.
> 
> It's been a wee while since I stuck my toes in the Linux waters, so I
> was wondering if anyone here has any recommendations for a dev machine
> setup? Due to the django host I've signed with, I'm largely stuck with
> MySQL, and don't mind using the manage.py dev server while actually
> developing. Everything else is up for grabs in my mind - distro,
> editor, desktop manager skin, whatever! Although I'm unlikely to man
> up to something like emacs or vi for code editing...
> 
> What works for you?
> 
> Cheers
> Jon

I've you're a linux noob go with {k,u}buntu. If you're a hardcore *nix 
lover go with slackware. If you're a developer go with gentoo linux, as 
then, all the fancy libs you need to do your work are just an emerge away :)


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



Re: Django and Linux distros

2008-05-16 Thread JonSidnell

Thanks for the feedback everyone!

The deed is done and I've got myself set up with Ubuntu Desktop, MySQL
all working with Django, and gedit customised a la
http://grigio.org/pimp_my_gedit_was_textmate_linux to act a bit more
like Textmate. I'm liking it so far :)

Cheers
Jon

On May 16, 11:24 am, JonSidnell <[EMAIL PROTECTED]> wrote:
> Hi everyone
>
> I'm suddenly struck by the notion that I would like to be dev'ing
> Django on Linux of some flavour rather than Windows.
>
> It's been a wee while since I stuck my toes in the Linux waters, so I
> was wondering if anyone here has any recommendations for a dev machine
> setup? Due to the django host I've signed with, I'm largely stuck with
> MySQL, and don't mind using the manage.py dev server while actually
> developing. Everything else is up for grabs in my mind - distro,
> editor, desktop manager skin, whatever! Although I'm unlikely to man
> up to something like emacs or vi for code editing...
>
> What works for you?
>
> Cheers
> Jon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Sorting a dict by value for template rendering

2008-05-16 Thread Peter Rowell

Variations on this come up all the time. Note that arrays can be
sorted.
So, create an array of tuples containing the key and the value.
Then you can sort the array anyway you please.

In the view:
# create the array of tuples
ordered_dict = [(key, val) for key,val in my_original_dict.items()]

 # sort by key
ordered_dict.sort(lambda a,b: cmp(a[0], b[0]))
or
 # sort by value
ordered_dict.sort(lambda a,b: cmp(a[1], b[1]))

# if values are objects, you can do
ordered_dict.sort(lambda a,b: cmp(a[1].some_attr, b[1].some_attr))

In the template:

{% for item in ordered_dict %}
  Key: {{item.0}}  Value: {{item.1}}
{% for %}

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



Re: displaying/editing multiple records at once

2008-05-16 Thread Jonathan Buchanan

ken wrote:
> One thing I've wanted for a long time is a way to enter and view
> financial information for stocks I follow. However, this typically
> involves working with a table (in the graphical sense) of data,
> wherein each piece of data in the table is modeled as a single SQL
> record. Frameworks such as Django seem to concentrate on working with
> single records at once, and I'm wondering how I would go about putting
> up a grid of cells such that the user could enter data into the cells,
> submit the page, and have the various multiple records represented by
> each cell updated. It's that last bit I wonder about. The HTML and so
> forth are not the problem, the problem is simply one of figuring out
> how to have Django allow input fields that represent multiple records.
> 
> Feel free to refer me to sections of the django book, I realize I'll
> be doing a lot of work on my own and I'm not looking for a full
> answer, just a place to get started.
> 
> Thanks,
> Ken

http://www.djangoproject.com/documentation/newforms/#prefixes-for-forms

http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/

Regards,
Jonathan

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



displaying/editing multiple records at once

2008-05-16 Thread ken

One thing I've wanted for a long time is a way to enter and view
financial information for stocks I follow. However, this typically
involves working with a table (in the graphical sense) of data,
wherein each piece of data in the table is modeled as a single SQL
record. Frameworks such as Django seem to concentrate on working with
single records at once, and I'm wondering how I would go about putting
up a grid of cells such that the user could enter data into the cells,
submit the page, and have the various multiple records represented by
each cell updated. It's that last bit I wonder about. The HTML and so
forth are not the problem, the problem is simply one of figuring out
how to have Django allow input fields that represent multiple records.

Feel free to refer me to sections of the django book, I realize I'll
be doing a lot of work on my own and I'm not looking for a full
answer, just a place to get started.

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



Re: Filtering by group

2008-05-16 Thread Alex

Alright, I think it works now with this:

queryset = Quote.objects.select_related(slug)

Much simpler than what I was trying...

On May 16, 3:55 pm, Alex <[EMAIL PROTECTED]> wrote:
> I'm not sure if this is any closer, but maybe it is:
>
> queryset = Quote.objects.filter(source in
> series.tvepisode_set.select_related()),
>
> There's something wrong with the "source in" part, though...
>
> On May 16, 3:39 pm, Alex <[EMAIL PROTECTED]> wrote:
>
> > I'm playing around with a TV quotes database and I'm trying to get all
> > quotes from one TV series. My problem is that the quotes are directly
> > tied to an episode of a TV series, not the series itself. How can I
> > easily get a queryset that represents all quotes from that series?
>
> > Here's a snippet from my models.py (removing irrelevant info):
>
> > class Source(models.Model):
> >     name = models.CharField(max_length=50)
> >     slug = models.SlugField(max_length=20)
>
> > class Quote(models.Model):
> >     quote = models.TextField(max_length=500)
> >     authors = models.ManyToManyField(Author)
> >     source = models.ForeignKey(Source)
>
> > class TVSeries(models.Model):
> >     name = models.CharField(max_length=50)
> >     slug = models.SlugField(max_length=20, editable=False)
>
> > class TVEpisode(Source):
> >     series = models.ForeignKey(TVSeries)
> >     episodenum = models.IntegerField()
>
> > In my view, I'm thinking of something like the following, which
> > obviously doesn't work:
>
> > queryset =
> > Quote.objects.filter(source=TVEpisode.objects.filter(TVSeries.objects.filter(authors__slug__iexact=slug)))
>
> > Is there an easy way to filter by groups like this?
>
> > Thanks,
> > Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Filtering by group

2008-05-16 Thread Alex

I'm not sure if this is any closer, but maybe it is:

queryset = Quote.objects.filter(source in
series.tvepisode_set.select_related()),

There's something wrong with the "source in" part, though...

On May 16, 3:39 pm, Alex <[EMAIL PROTECTED]> wrote:
> I'm playing around with a TV quotes database and I'm trying to get all
> quotes from one TV series. My problem is that the quotes are directly
> tied to an episode of a TV series, not the series itself. How can I
> easily get a queryset that represents all quotes from that series?
>
> Here's a snippet from my models.py (removing irrelevant info):
>
> class Source(models.Model):
>     name = models.CharField(max_length=50)
>     slug = models.SlugField(max_length=20)
>
> class Quote(models.Model):
>     quote = models.TextField(max_length=500)
>     authors = models.ManyToManyField(Author)
>     source = models.ForeignKey(Source)
>
> class TVSeries(models.Model):
>     name = models.CharField(max_length=50)
>     slug = models.SlugField(max_length=20, editable=False)
>
> class TVEpisode(Source):
>     series = models.ForeignKey(TVSeries)
>     episodenum = models.IntegerField()
>
> In my view, I'm thinking of something like the following, which
> obviously doesn't work:
>
> queryset =
> Quote.objects.filter(source=TVEpisode.objects.filter(TVSeries.objects.filter(authors__slug__iexact=slug)))
>
> Is there an easy way to filter by groups like this?
>
> Thanks,
> Alex
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with abstract model class

2008-05-16 Thread Legioneer

It looks that this is not the case. The problem seems to be more
general. When I add abstract=True to ANY model I receive the same
error. Example:

class OrderItem(models.Model):
num = models.IntegerField(default=1)
timestamp = models.DateTimeField(auto_now=True)

class Meta:
abstract = True

On 16 май, 18:25, Julien <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I think it should be %(class)s, not %s(class)s    (take out the first
> 's')
>
> Julien
>
> On May 16, 11:33 pm, Legioneer <[EMAIL PROTECTED]> wrote:
>
> > Hi All,
>
> > Got a problem when trying to define an abstract class. Below there is
> > an examle:
>
> > class PaymentData(models.Model):
> >     owner = models.ForeignKey(Customer,
> > related_name="%s(class)s_related" )
>
> >     class Meta:
> >         abstract = True
>
> > When running 'python manage.py validate' receive an error:
>
> > 
> > ...
> >  File "/usr/lib/python2.3/site-packages/django/db/models/base.py",
> > line 89, in add_to_class
> >     value.contribute_to_class(cls, name)
> >   File "/usr/lib/python2.3/site-packages/django/db/models/options.py",
> > line 70, in contribute_to_class
> >     raise TypeError, "'class Meta' got invalid attribute(s): %s" %
> > ','.join(meta_attrs.keys())
> > TypeError: 'class Meta' got invalid attribute(s): abstract
>
> > What can be the problem?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Sorting a dict by value for template rendering

2008-05-16 Thread bfrederi

I have a dict that looks similar to this:
{'com': 'communication', 'tel': 'telephone', 'cel': 'cellphone',
'fax': 'fax machine',}

And I want to sort it by value, and render it in a template. I was
able to do it, but in a very hacked way. Can anyone show me a better
way to do it than my solution.

Here is the template tag (the dict I want to sort is
vocab_dict[vocabulary] on line 13):
http://dpaste.com/hold/50603/
Here is the template (the dict has been converted into a sorted list
of dicts and iterated through on lines 6-11):
http://dpaste.com/hold/50604/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Filtering by group

2008-05-16 Thread Alex

I'm playing around with a TV quotes database and I'm trying to get all
quotes from one TV series. My problem is that the quotes are directly
tied to an episode of a TV series, not the series itself. How can I
easily get a queryset that represents all quotes from that series?

Here's a snippet from my models.py (removing irrelevant info):

class Source(models.Model):
name = models.CharField(max_length=50)
slug = models.SlugField(max_length=20)

class Quote(models.Model):
quote = models.TextField(max_length=500)
authors = models.ManyToManyField(Author)
source = models.ForeignKey(Source)

class TVSeries(models.Model):
name = models.CharField(max_length=50)
slug = models.SlugField(max_length=20, editable=False)

class TVEpisode(Source):
series = models.ForeignKey(TVSeries)
episodenum = models.IntegerField()

In my view, I'm thinking of something like the following, which
obviously doesn't work:

queryset =
Quote.objects.filter(source=TVEpisode.objects.filter(TVSeries.objects.filter(authors__slug__iexact=slug)))

Is there an easy way to filter by groups like this?

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



Re: How to add an object with relations to other objects

2008-05-16 Thread Richard Dahl
For the first question, the db-api doc should provide this and more
information, as I am not sure I completely understand, but here goes
(assuming the following models):

class B(models.Model):
attribute = char()...

class A(models.Model):
attribute = char()...
bs = m2m(B)

in your view to get all of the B(s) related to a given A

a = A.objects.get(pk=1)
b = a.bs.all()

if you want to get all of the Bs that are related to 'any' A:
b = B.objects.filter(a__isnull = False)

for question 2, I am not sure what you mean, if you mean can you create a B
without relating it to an A? sure, a related A is not required by B.  If you
do not want to require a B for A just set 'blank=True, null=True' in the M2M
field definition in A.

Not sure if this helps, your original post was somewhat confusing, if you
post relevant snippets from your models you may get more intelligent
responses than my intellectual meanderings.
-richard



On 5/16/08, jabbercat <[EMAIL PROTECTED]> wrote:
>
>
> Hello,
>
> it's my frist time I'm using this Group.
>
> My Problems:
> I have a class A and a class B with a one(A)-to-many(B) relationship
> between them.
>
> My first question: Is there an efficient way to get in a template all
> instances of B, which are related to an instance of A, when i only
> knew an instance of A? Something like a special attribute, or
> something like that?
>
> My second question: I want to use form_for_model(), because of my
> database-driver design. But how can I add an instance of B so that the
> relation to an instance of A is also saved, without specify the
> foreign key id of A explicitly?
>
> I hope you understand what I meen.
> >
>

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



Re: Specifying schema name w/ syncdb

2008-05-16 Thread Jeff Gentry

> I'm using PostgreSQL - one question I had was that when I run syncdb,
> the tables that are created are under the default 'public' schema.  
> Is there a way to specify syncdb to create these tables under another
> schema name?

Er, sorry about that.  If I created the schema first, syncdb stuck my
tables there.


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



Re: Image upload not working in newforms admin?

2008-05-16 Thread Brandon Taylor

I finally got it to work, but I can't explain why. I followed this
tutorial: 
http://paul.annesley.cc/articles/2007/11/19/django-and-python-imaging-library-pil-on-leopard

One minute it wasn't working, the next it was. I've done this
installation on a few computers, Win XP and Mac OS X 10.4.10/11
(Intel) without a hitch before. I'm not sure what could have been
different on this current Powerbook running 10.4.11. I still can't get
PIL to compile on an older Powerbok G4. It always fails with
"gcc...exited with status 1" or something along those lines.

One thing I noticed about the imageField is that it doesn't overwrite
an existing file of the same name - it appends an underscore to the
end of the file. I would be nice if it would check to see if the file
name is the same and overwrite it, or not re-upload the image if
you're just changing other attributes of the model.

On May 16, 2:18 pm, mw <[EMAIL PROTECTED]> wrote:
> I'm having nothing but tons of trouble right now with the image field
> upload.  I don't know what the problem is for sure, yet, but yeah I
> think that I'm willing to say that the ImageField isn't as easy to get
> working as it should be :-/
>
> I think my problem may be OS X related and having to do with OS X's
> Apache and mod_python being 64 bit while my PIL is something else, but
> I need to verify that PIL is, in fact, 32 bit still.
>
> On May 16, 1:06 pm, Brandon Taylor <[EMAIL PROTECTED]> wrote:
>
> > Hi everyone,
>
> > I can't get the newforms admin to upload images. I have PIL and JPEG
> > support installed. My selftest on PIL reports that JPEG is supported,
> > along with PNG, but when I try to upload, I get:
>
> > Upload a valid image. The file you uploaded was either not an image or
> > a corrupted.
>
> > I can confirm that it *is* a JPEG, and it was working before I
> > switched to newforms-admin :)
>
> > Thoughts? Anyone experiencing something similar? I'm sure its a
> > problem with PIL and no Django, but have no clue as to where to start
> > to debug this.
>
> > TIA,
> > Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



How to add an object with relations to other objects

2008-05-16 Thread jabbercat

Hello,

it's my frist time I'm using this Group.

My Problems:
I have a class A and a class B with a one(A)-to-many(B) relationship
between them.

My first question: Is there an efficient way to get in a template all
instances of B, which are related to an instance of A, when i only
knew an instance of A? Something like a special attribute, or
something like that?

My second question: I want to use form_for_model(), because of my
database-driver design. But how can I add an instance of B so that the
relation to an instance of A is also saved, without specify the
foreign key id of A explicitly?

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



Re: accessing dictionary elements in opening tag of django template for loop

2008-05-16 Thread John

Thanks, John.  Your second suggestion (that I find a way to modify the
Document class) put me on the right track.  I eventually found this
article:
http://blog.arbingersys.com/2008/04/google-app-engine-better-many-to-many.html
which worked for my problem.

On May 14, 7:17 pm, "John Lenton" <[EMAIL PROTECTED]> wrote:
> On Wed, May 14, 2008 at 6:33 PM,John<[EMAIL PROTECTED]> wrote:
>
> > I'm having trouble accessing dictionary elements within a nested for
> > loop.  here are some code snippets:
>
> > [...]
>
> > # so far so good, but then I try to iterate over the documents and
> > their associated tags in a template
> > # here is the template with the html stripped out for readability
> > {% for document in documents %}
> >  {{ document.content }}
> >  {% for doctag in tag_dict[document.uid] %} {{ doctag.tagid }} {%
> > endfor % }
> > {% endfor %}
>
> > # document.content is fine, but when I try to access tag_dict within
> > the template's for loop, it complains:
> > TemplateSyntaxError: Could not parse the remainder: [document.uid]
>
> right, templates are not python :) you can't do that, and it's on
> purpose: that kind of fiddling around with the model is best done in
> the view, not in the template.
>
> So... instead of doing e.g.
>
> documents = Document.objects.all()
> tag_dict = {}
> for document in documents:
> tag_dict[document.uid] = DocumentTag.objects.filter(docid=document.uid)
>
> and passing those two into the template, you could do something along
> the lines of
>
> documents = [dict(object=document,
>   tags=DocumentTag.objects.filter(docid=document.uid))
>  for document in Document.objects.all()]
>
> and then in the template, you do
>
> {% for document in documents %}
>   {{ document.object.content }}
>   {% for doctag in document.tags %} {{ doctag.tagid }} {% endfor %}
> {% endfor %}
>
> this is assuming there is some reason for you not to modify the
> Document class to give it the appropriate methods or attributes to
> access the related DocumentTag directly; if you could do that, life
> would be much easier :)
>
> --JohnLenton ([EMAIL PROTECTED]) -- Random fortune:
> The trouble with a lot of self-made men is that they worship their creator.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Bind MultiValueField?

2008-05-16 Thread brightnesslevels

Hello,

I'm playing with MultiValueField which I want to be a part of a bound
form.
However, I can't push any value in it.

When I use CharField instead, everything is okay and the value is
displayed in charfield.
However, when I replace charfield with my MultiValueField, nothing is
rendered and when I check what value does the widget get in the render
method, and I see [None, None, None].

Here's how my Field and Widget look like:

class GuidedDateWidget(forms.MultiWidget):
  def __init__(self, attrs=None):
widgets = (
  forms.TextInput(attrs={'size':'2'}),
  forms.TextInput(attrs={'size':'2'}),
  forms.TextInput(attrs={'size':'4'})
)

super(GuidedDateWidget, self).__init__(widgets, attrs)

  def format_output(self, widgets):
return u"D %sM %sY %s" % tuple(widgets)

  def decompress(self, value):
if value:
  return [value, 0, 0]
return [None, None, None]


class GuidedDateField(forms.MultiValueField):

  widget = GuidedDateWidget

  def __init__(self, *args, **kwargs):

fields = (
  #forms.IntegerField(min_value=1, max_value=31, required=True),
  forms.IntegerField(required=True),
  forms.IntegerField(min_value=1, max_value=12, required=True),
  forms.IntegerField(min_value=1900, required=True)
)
super(GuidedDateField, self).__init__(fields, *args, **kwargs)

  def compress(self, data_list):
print("DEBUG: data list")
print data_list
if data_list:
  try:
return datetime.datetime(*map(lambda x:int(x), data_list))
  except ValueError:
raise forms.ValidationError(ERROR_INVALID)
return None

What should I do so the widget and field receive correct data to
render?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Updated to latest trunk root page (/) stopped working

2008-05-16 Thread Josh

So I ran an svn up on my Django install because I'm running into some
issues that QuerysetRefactor should have fixed, and after doing so the
root page of my site stopped working. Everything else appears to be
working fine, just not /.

In my browser it gives me a 502 Proxy Error (which is odd, because I'm
not aware that I'm using a proxy...). So I telnetted in to see what it
would give me and got this:

Shub-Niggurath:~ josho$ telnet bostonchefs.webfactional.com 80
Trying 75.125.175.50...
Connected to bostonchefs.webfactional.com.
Escape character is '^]'.
GET
Site not configured
Connection closed by foreign host.

The appropriate line of my urls.py is here:
# Root
(r'^/?$', 'myproject.views.index'),

Does anyone have any idea what might be causing this? It seems odd
that only that URL would stop working while the others are fine.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Caching: Memcached vs locmem

2008-05-16 Thread Brian

Can someone run down the differences between using Memcached vs
locmem?

The docs indicate Memcached is "the best" solution, but seems
considerably harder to setup. Just curious what the trade-offs are.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Image upload not working in newforms admin?

2008-05-16 Thread mw

I'm having nothing but tons of trouble right now with the image field
upload.  I don't know what the problem is for sure, yet, but yeah I
think that I'm willing to say that the ImageField isn't as easy to get
working as it should be :-/

I think my problem may be OS X related and having to do with OS X's
Apache and mod_python being 64 bit while my PIL is something else, but
I need to verify that PIL is, in fact, 32 bit still.



On May 16, 1:06 pm, Brandon Taylor <[EMAIL PROTECTED]> wrote:
> Hi everyone,
>
> I can't get the newforms admin to upload images. I have PIL and JPEG
> support installed. My selftest on PIL reports that JPEG is supported,
> along with PNG, but when I try to upload, I get:
>
> Upload a valid image. The file you uploaded was either not an image or
> a corrupted.
>
> I can confirm that it *is* a JPEG, and it was working before I
> switched to newforms-admin :)
>
> Thoughts? Anyone experiencing something similar? I'm sure its a
> problem with PIL and no Django, but have no clue as to where to start
> to debug this.
>
> TIA,
> Brandon
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



إلغاء اشتراك

2008-05-16 Thread mutib utibi


نرجو إلغاء الاشتراك بالرسائل
شكراً
_
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Uploading files to subdirectories

2008-05-16 Thread Mike Hjorleifsson

what happens in your example if sally has a holiday.rtf ?


On May 16, 3:00 am, James McGill <[EMAIL PROTECTED]> wrote:
> Hi All,
> I'm new to Django and I'm not sure how best to achieve the following:
>
> Users may upload files - each uploaded file is tied to a user in the
> database using a ForeignKey.
>
> In order to prevent pain to the underlying O/S I don't want to put all
> these files in to a single directory. I could separate the files by
> upload time as mentioned in the Django documentation, but it would be
> nicer to have all the files uploaded by a single user under a single
> subdirectory.
>
> Example:
> Greg uploads "holiday.rtf", it is saved as /media/uploads/greg/
> holiday.rtf
> Sally uploads "family.rtf", it is saved as /media/uploads/sally/
> family.rtf
>
> My current model:
>
> class FileModel(models.Model):
> user = models.ForeignKey(User)
> file = models.FileField(upload_to = 'uploads/'
>
> I am saving the file using FileModel_Instance.save_file_file('path',
> file_contents). Adding extra folders to the path (i.e. path = greg/
> holiday.rtf) doesn't work - I assume this is a security restriction.
>
> I am using the SVN version of Django. Any help would be appreciated.
>
> Regards,
> James
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Add column to generated ManyToMany table and access from admin

2008-05-16 Thread Peter Bailey

Thanks Richard, I'll give it a go.

Cheers


On May 16, 2:44 pm, "Richard Dahl" <[EMAIL PROTECTED]> wrote:
> I do not think that admin currently supports this, but I could be wrong. but
> here are two ways to accomplish it.
>
>  class Item(models.Model):
>name = models.CharField(max_length=30)
>
> class ItemOrder(models.Model):
> item = models.FK(Item)
> order = models.int()
>
> def __unicode__(self): return ('%s - %s'
> %(self.item.__unicode__(), self.order))
>
> class Page(models.Model):
>survey = models.ForeignKey(Survey)
>item = models.M2M(ItemOrder)
>order = models.IntegerField() #Page Order
>file_name = models.CharField(max_length=50)
>
> You can also add a 'unique_together' constraint to your meta class in
> ItemOrder, if helpful.
> hth,
> -richard
>
> On 5/16/08, Peter Bailey <[EMAIL PROTECTED]> wrote:
>
>
>
> > I am pretty new to Django, and am building a web generating app. I am
> > hoping to get a lot of functionality out of the admin. So far that is
> > working great. I do have 2 classes in my models that have a many to
> > many relationship. The code is generated nicely and everything works
> > correctly.
> > The classes represent web pages and generic items that go on pages
> > such as radios, dropdowns, etc.
>
> > However, I would really like to add a column to the join table,
> > "order", so I can use the admin of my Page class to add Items and
> > define their order on that particular page. Is there a way to do this?
> > I have searched around and found lots of discussions, but no solid
> > answers. Sorry if this is a dumb question, but I admit I am a noob.
> > Here is a code snippet:
>
> > # will use this for subclassing into our item subtypes
> > class Item(models.Model):
> >name = models.CharField(max_length=30)
>
> >def __unicode__(self):
> >return self.name
>
> > class Page(models.Model):
> >"""Page information for survey pages - surveys will contain one or
> > more of these"""
> >survey = models.ForeignKey(Survey)
> >items = models.ManyToManyField(Item)
> >order = models.IntegerField()   # this is for page ordering - not
> > item ordering
> >file_name = models.CharField(max_length=50)
>
> >def __unicode__(self):
> >return self.file_name
>
> >class Admin:
> >pass
>
> > class RadioBoxType(Item):
> >"""A Radio Button object with its specific attributes"""
> > ...
>
> > So, if I could somehow add an order column to the generated
> > gen_pageitem table and edit it from the admin for the page, I would be
> > set. I'm also not using the new admin branch which I just noticed a
> > couple of days ago. Any advice on if I should switch now or later
> > would be most welcome. I don't mind using newer code, but I am unsure
> > of the timelines for that branch to move into the trunk etc. Don't
> > want to waste time learning code that will be obsolete, but do have
> > some deadlines to meet (of course).
>
> > Advice or pointers greatly appreciated,
>
> > Peter
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Add column to generated ManyToMany table and access from admin

2008-05-16 Thread Richard Dahl
I do not think that admin currently supports this, but I could be wrong. but
here are two ways to accomplish it.

 class Item(models.Model):
   name = models.CharField(max_length=30)

class ItemOrder(models.Model):
item = models.FK(Item)
order = models.int()

def __unicode__(self): return ('%s - %s'
%(self.item.__unicode__(), self.order))

class Page(models.Model):
   survey = models.ForeignKey(Survey)
   item = models.M2M(ItemOrder)
   order = models.IntegerField() #Page Order
   file_name = models.CharField(max_length=50)


You can also add a 'unique_together' constraint to your meta class in
ItemOrder, if helpful.
hth,
-richard

On 5/16/08, Peter Bailey <[EMAIL PROTECTED]> wrote:

>
> I am pretty new to Django, and am building a web generating app. I am
> hoping to get a lot of functionality out of the admin. So far that is
> working great. I do have 2 classes in my models that have a many to
> many relationship. The code is generated nicely and everything works
> correctly.
> The classes represent web pages and generic items that go on pages
> such as radios, dropdowns, etc.
>
> However, I would really like to add a column to the join table,
> "order", so I can use the admin of my Page class to add Items and
> define their order on that particular page. Is there a way to do this?
> I have searched around and found lots of discussions, but no solid
> answers. Sorry if this is a dumb question, but I admit I am a noob.
> Here is a code snippet:
>
> # will use this for subclassing into our item subtypes
> class Item(models.Model):
>name = models.CharField(max_length=30)
>
>def __unicode__(self):
>return self.name
>
> class Page(models.Model):
>"""Page information for survey pages - surveys will contain one or
> more of these"""
>survey = models.ForeignKey(Survey)
>items = models.ManyToManyField(Item)
>order = models.IntegerField()   # this is for page ordering - not
> item ordering
>file_name = models.CharField(max_length=50)
>
>def __unicode__(self):
>return self.file_name
>
>class Admin:
>pass
>
> class RadioBoxType(Item):
>"""A Radio Button object with its specific attributes"""
> ...
>
> So, if I could somehow add an order column to the generated
> gen_pageitem table and edit it from the admin for the page, I would be
> set. I'm also not using the new admin branch which I just noticed a
> couple of days ago. Any advice on if I should switch now or later
> would be most welcome. I don't mind using newer code, but I am unsure
> of the timelines for that branch to move into the trunk etc. Don't
> want to waste time learning code that will be obsolete, but do have
> some deadlines to meet (of course).
>
> Advice or pointers greatly appreciated,
>
> Peter
>
>
> >
>

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



Specifying schema name w/ syncdb

2008-05-16 Thread Jeff Gentry

Hi there ...

I'm using PostgreSQL - one question I had was that when I run syncdb, the
tables that are created are under the default 'public' schema.  Is there a
way to specify syncdb to create these tables under another schema 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: symmetrical associations

2008-05-16 Thread James Tauber


On May 14, 2008, at 5:53 PM, Russell Keith-Magee wrote:
> Hi James,
>
> It sounds like you might be looking for ticket #6095 [1]. This lets
> you define an intermediate model to use for m2m relations. This allows
> you to put attributes on the arc, query over the arc attributes, and
> be symmetrical (or not).

As long as the arc model can be defined without modifying the node  
model.

For example, in one use case, I'd like the nodes to be able to be  
django.contrib.auth Users.

To make it more concrete, here is what I am currently doing in one app  
to retrieve friendship relationships between django.contrib.auth Users:

class FriendshipManager(models.Manager):

 def friends_for_user(self, user):
 friends = []
 for friendship in self.filter(user_1=user):
 friends.append({"friend": friendship.user_2,  
"friendship": friendship})
 for friendship in self.filter(user_2=user):
 friends.append({"friend": friendship.user_1,  
"friendship": friendship})
 return friends

class Friendship(models.Model):
 user_1 = models.ForeignKey(User, related_name="friends_1")
 user_2 = models.ForeignKey(User, related_name="friends_2")

 objects = FriendshipManager()


There could, of course, be extra fields on Friendship, but in the  
above case there aren't and so it's just a normal symmetrical M2M  
relationships except the User model is used unmodified.

James

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



Add column to generated ManyToMany table and access from admin

2008-05-16 Thread Peter Bailey

I am pretty new to Django, and am building a web generating app. I am
hoping to get a lot of functionality out of the admin. So far that is
working great. I do have 2 classes in my models that have a many to
many relationship. The code is generated nicely and everything works
correctly.
The classes represent web pages and generic items that go on pages
such as radios, dropdowns, etc.

However, I would really like to add a column to the join table,
"order", so I can use the admin of my Page class to add Items and
define their order on that particular page. Is there a way to do this?
I have searched around and found lots of discussions, but no solid
answers. Sorry if this is a dumb question, but I admit I am a noob.
Here is a code snippet:

# will use this for subclassing into our item subtypes
class Item(models.Model):
name = models.CharField(max_length=30)

def __unicode__(self):
return self.name

class Page(models.Model):
"""Page information for survey pages - surveys will contain one or
more of these"""
survey = models.ForeignKey(Survey)
items = models.ManyToManyField(Item)
order = models.IntegerField()   # this is for page ordering - not
item ordering
file_name = models.CharField(max_length=50)

def __unicode__(self):
return self.file_name

class Admin:
pass

class RadioBoxType(Item):
"""A Radio Button object with its specific attributes"""
...

So, if I could somehow add an order column to the generated
gen_pageitem table and edit it from the admin for the page, I would be
set. I'm also not using the new admin branch which I just noticed a
couple of days ago. Any advice on if I should switch now or later
would be most welcome. I don't mind using newer code, but I am unsure
of the timelines for that branch to move into the trunk etc. Don't
want to waste time learning code that will be obsolete, but do have
some deadlines to meet (of course).

Advice or pointers greatly appreciated,

Peter


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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread James Bennett

On Fri, May 16, 2008 at 11:52 AM, ydjango <[EMAIL PROTECTED]> wrote:
> I do not want to make it easy for some one who breaks in , either a
> outsider or may be an rougue hosting provider employee or contractor,
> to easily get access to all the information - data and code.

Again: if this is your worry, you have bigger problems. Allow me to
suggest an alternate method:

(satire begins here, for the humor-impaired)

1. Physically obtain the server upon which the code is stored. Write
random data to the relevant sectors of the hard drive seven times
over, then write zeroes to it seven times over, then write random data
again.

2. Physically destroy the hard drive. Sledgehammers are good for this.

3. Place the shards of the hard drive into a vat of highly caustic acid.

4. Once the shards have dissolved, burn the resulting acidic liquid.
Be sure to capture the smoke.

5. Cool the smoke until it turns back to ash. Mix the ash into the
center of a reinforced concrete slab, at least 27 cubic feet in
volume.

6. If you have access to sufficient technology, launch the concrete
slab into space, on a course to collide with the Sun or (better) with
any singularity which happens to be nearby. The singularity is best
because -- even though it may not guarantee destruction of the
information -- the subjective time to observe the rocket crossing the
event horizon, from the frame of reference of a person some distance
from it, will be effectively infinite, causing most attackers to give
up.

7. If you do not have access to sufficient technology, have the
concrete slab stored in a nuclear-hardened bunker, with no Internet
connection, in a room using biometric identification keyed to
yourself, and with the whole complex guarded 24/7 by US Navy SEALs.
Maintain this watch until the technology available to complete step
(6) becomes available to you.

Once you've completed this process, your application code will be
safe, for a reasonable value of "safe".

(satire ends here)

Or you could just find a host who properly sets up file permissions so
that random people can't access your application code. Unless you own
and personally supervise all of the following you will be susceptible
to rogue employees: the server, the rack in which it's located and the
datacenter in which the rack is found. Many people do not find that
the perceived security gains of doing so outweigh the financial and
maintenance drawbacks. YMMV.


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

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



Image upload not working in newforms admin?

2008-05-16 Thread Brandon Taylor

Hi everyone,

I can't get the newforms admin to upload images. I have PIL and JPEG
support installed. My selftest on PIL reports that JPEG is supported,
along with PNG, but when I try to upload, I get:

Upload a valid image. The file you uploaded was either not an image or
a corrupted.

I can confirm that it *is* a JPEG, and it was working before I
switched to newforms-admin :)

Thoughts? Anyone experiencing something similar? I'm sure its a
problem with PIL and no Django, but have no clue as to where to start
to debug this.

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



Re: MySQL Boolean vs. PostgresQL Boolean

2008-05-16 Thread Szaijan

Thanks Karen.

Actually, the behavior here is worst case, from my perspective, in
that Ture/False values will update an instance, but will not be saved
and no exception is thrown.  When I try to update the model with a
True/False value, it simply fails to update without giving any
indication of an error.

So, on my Slicehost installation (MySQL based):

m = Model.object.get(id=id)
print m.BooleanField // Prints 0, if the value is False
m.BooleanField = True
m.save()
print m.BooleanField // Prints True
m = Model.object.get(id=id)
print m.BooleanField // Still prints 0.  The instance was
updated, but did not save.  No error.
m.BooleanField = 1
m.save()
print m.BooleanField // Prints 1
m = Model.object.get(id=id)
print m.BooleanField // Now prints 1.  Saved correctly.

I have to alter my code so 0 and 1 are submitted to get updates to
save correctly.  I am not pulling anything through SQL, only directly
through the Django models.  This sounds like a bug to me, but I want
to be sure there's not some MySQL boolean setting that I might be
missing in my settings.py, or even in my MySQL setup files.


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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread jonknee

On May 16, 12:52 pm, ydjango <[EMAIL PROTECTED]> wrote:
> I do not want to make it easy for some one who breaks in , either a
> outsider or may be an rougue hosting provider employee or contractor,
> to easily get access to all the information - data and code.
>

Your best bet is to ensure that doesn't happen--secure passwords and
limiting server access to your IP address is a good start. But if
someone gets into your server they will be able to access your code.
It doesn't matter if it's .py or .pyc--if it can be executed it can be
deconstructed by a motivated attacker. This isn't the fault of Python,
it's the same in other languages. You can obfuscate your code, but
it's still security through obscurity.

> Also, I read somewhere that google does not use python for its  core
> busines applications. It uses it as glue langauage and for internal
> operations automation mostly. Just a random thought.

This isn't because of security, it's because of speed. There are
plenty of public facing services using Python, including Groups and
Code. Google does a ton in Java (like Gmail) and that's really easy to
decompile. Google protects access to its code and as such a .py file
is just as secure as anything else.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reference to the url of the current page in a template

2008-05-16 Thread Scott Moonen
Ganesh,

First ensure that your TEMPLATE_CONTEXT_PROCESSORS contains:

TEMPLATE_CONTEXT_PROCESSORS = (
  . . .
'django.core.context_processors.request',
  . . .
)

Then you can use the variable {{ request.path }} in your templates, assuming
that the URLs are all on the same host.  If not, you'll need to use
something like {{ request.META.HTTP_HOST }}://{{ request.path }}.

  -- Scott


On Fri, May 16, 2008 at 12:58 PM, M.Ganesh <[EMAIL PROTECTED]> wrote:

>
> Hi,
>
> I don't know how to clearly explain what I want to know. Let me try once
> again...
>
> I have a small controlpanel page which I include in all my other pages.
> This control panel page has got a link to 'login' page. Users are
> allowed to view the pages without login, but they have to login if they
> want to make any changes to the data. So if somebody realises he wants
> to change the data he is currently viewing, he will click the login
> link. Now I want him to be brought back to the page he was viewing
> before logging in. The trouble is because the 'login' link is in a
> template which will get included to a arbitrary page. In other words :
>
> #my controlpane.html
>
> {% if user.is_anonymous %}
>Welcome 
>   Please login
>login
> {% else %}
>blah blah
> {% endif %}
>
>
> Regards Ganesh
>
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Reference to the url of the current page in a template

2008-05-16 Thread Alex Koshelev

If you have `django.core.context_processors.request` context processor
enabled and you use RequestContext so the `{{request.path}}` will
return current path. Or you can simple pass `request.path` variable to
the template context manually.

On May 16, 8:58 pm, "M.Ganesh" <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I don't know how to clearly explain what I want to know. Let me try once
> again...
>
> I have a small controlpanel page which I include in all my other pages.
> This control panel page has got a link to 'login' page. Users are
> allowed to view the pages without login, but they have to login if they
> want to make any changes to the data. So if somebody realises he wants
> to change the data he is currently viewing, he will click the login
> link. Now I want him to be brought back to the page he was viewing
> before logging in. The trouble is because the 'login' link is in a
> template which will get included to a arbitrary page. In other words :
>
> #my controlpane.html
>
> {% if user.is_anonymous %}
> Welcome 
>Please login
> login
> {% else %}
> blah blah
> {% endif %}
>
> Regards Ganesh
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Reference to the url of the current page in a template

2008-05-16 Thread M.Ganesh

Hi,

I don't know how to clearly explain what I want to know. Let me try once 
again...

I have a small controlpanel page which I include in all my other pages. 
This control panel page has got a link to 'login' page. Users are 
allowed to view the pages without login, but they have to login if they 
want to make any changes to the data. So if somebody realises he wants 
to change the data he is currently viewing, he will click the login 
link. Now I want him to be brought back to the page he was viewing 
before logging in. The trouble is because the 'login' link is in a 
template which will get included to a arbitrary page. In other words :

#my controlpane.html

{% if user.is_anonymous %}
Welcome 
   Please login
login
{% else %}
blah blah
{% endif %}


Regards Ganesh


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



Re: Keeping track of which user did what

2008-05-16 Thread Richard Dahl
This can be done with the threadlocals middleware:
http://code.djangoproject.com/wiki/CookBookThreadlocalsAndUser



On 5/16/08, Chris Farley <[EMAIL PROTECTED]> wrote:
>
>
> Django has that nice "auto_add=True" property you can set on a model's
> field. I have two fields in my models called "created_at" and
> "updated_at" that keeps track of each model instance's creation/
> modification date. It's incredibly easy.
>
> I also want to keep track of which user created/updated each instance.
> Right now, I'm doing this from my views -- I just get the user from
> the request object and manually populate my "created_by" and
> "updated_by" fields. This definitely violates the DRY principle... I
> would love to move this code into my model code (by maybe overriding
> the save method), but I don't think I have access to the request
> object in my models.
>
> Any suggestions? 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread ydjango

I do not want to make it easy for some one who breaks in , either a
outsider or may be an rougue hosting provider employee or contractor,
to easily get access to all the information - data and code.

I would have thought by this time easy solutions for this issue would
have been found.

I know I am a bit paranoid when it comes to security, probably becuase
of my background in financial industry.

I also do understand at some point you need to trust some one and that
a hosting provider will not do such a thing as stealing your code.
and likelyhood of such a break-in happening is very rare.  ( I have no
ssn or credit card info, so why would anyone bother to break in.)

Also, I read somewhere that google does not use python for its  core
busines applications. It uses it as glue langauage and for internal
operations automation mostly. Just a random thought.

thanks
Ashish

On May 16, 8:42 am, jonknee <[EMAIL PROTECTED]> wrote:
> On May 16, 6:02 am, ydjango <[EMAIL PROTECTED]> wrote:
>
> > I have propriety commercial code and some formula/ algo
> > implementations which I do not want to expose.
> > Hence I do not want to upload .py source files
>
> Expose to whom? Your files (even on shared hosting) are still just
> your files. If you believe your host is going to snoop in your account
> and steal your algorithm and sell it to your competitors, you
> definitely need a new host.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Get just one object id at the time in view assignment issue.

2008-05-16 Thread Jorge Romo

Hello guys!

I have another little (i'm sure it is) problem (i have like 3 days
trying to resolve it by myself but i just gave up lol), i'm using
django-tagging so I can tag some records, the problem here is that i
don't know how to take one object, take its id and then keep the
cycle. this is what i got so far:

def Records (request, UserName):
artists = Artist.objects.get(UserName=UserName)
try:
records = artist.record_set.all()
except Record.DoesNotExist:
records = None
record_id = # Missing code here i guess
record_tags = Record.objects.get(id=record_id)
RecordTags = Tag.objects.get_for_object(record_tags)

I mean, if i put a Int en record_id i can get the tags but just for
that one and i dont want that:

 {% if tags %}
   Tags: | {% for tags in tags %}{{ tags.name }} | {% endfor %}

   {% else %}
 no tags {{ id }}
   {% endif %}

I hope you can help me out!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Problem with : Updating multiple objects at once

2008-05-16 Thread mwebs

Hello,

I want to do something like this:

UPDATE news SET sequence = sequence-1 WHERE sequence > 5

With the database-api I tried the following:

News.objects.filter(sequence__gt =  msequence).update(sequence =
sequence-1)

But thats not possible, beacause the assignment parameter sequence-1
must be a variable and not a reference to a column-value.

Is there any possibility to solve this problem without iterating over
all results with News.objects.filter(sequence__gt =  msequence) and
setting the new sequence manually in each iteration?

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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread jonknee

On May 16, 6:02 am, ydjango <[EMAIL PROTECTED]> wrote:
> I have propriety commercial code and some formula/ algo
> implementations which I do not want to expose.
> Hence I do not want to upload .py source files


Expose to whom? Your files (even on shared hosting) are still just
your files. If you believe your host is going to snoop in your account
and steal your algorithm and sell it to your competitors, you
definitely need a new host.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting 'instance' in ModelForms

2008-05-16 Thread Nathaniel Whiteinge

On May 16, 6:27 am, Greg Taylor <[EMAIL PROTECTED]> wrote:
> class Form_SKU(ModelForm):
> """
> The form for updating SKUs.
> """
> selected = self.instance.colors

``self`` isn't in scope here, try the code below (and it wouldn't hurt
to read-up on Python OOP).

class Form_SKU(ModelForm):
def __init__(self, *args, **kwargs):
super(Form_SKU, self).__init__(*args, **kwargs)
if self.instance:
selected = self.instance.colors
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom SQL problem

2008-05-16 Thread enri57ar

I'm stupid, thanks.

>>> cursor.fetchone()
(1L,)
>>> cursor.fetchall()
((3L,),)

On May 16, 12:01 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On Fri, May 16, 2008 at 10:45 AM, enri57ar <[EMAIL PROTECTED]> wrote:
>
> > I can't execute custom SQL.  'Cursor' object has no attribute
> > 'fechone',  and 'fechall'
> > I have a model named 'Labels' with db_name = 'labels'.
>
> You're missing a 't' in fetchone() and fetchall().
>
> Karen
>
>
>
> > mysql> SELECT id FROM labels;
> > ++
> > | id |
> > ++
> > |  1 |
> > |  3 |
> > ++
> > 2 rows in set (0.00 sec)
>
> > 
>
> > >>> django.get_version()
> > u'0.97-pre-SVN-7523'
>
> > >>> Labels.objects.count()
> > 2L
> > >>> from django.db import connection
> > >>> cursor = connection.cursor()
> > >>> cursor.execute("SELECT id FROM labels;")
> > 2L
>
> > >>> row = cursor.fechone()
> > Traceback (most recent call last):
> >  File "", line 1, in 
> >  File "C:\Python25\lib\site-packages\django\db\backends\util.py",
> > line 42, in _
> > _getattr__
> >    return getattr(self.cursor, attr)
> > AttributeError: 'Cursor' object has no attribute 'fechone'
>
> > >>> row = cursor.fechall()
> > Traceback (most recent call last):
> >  File "", line 1, in 
> >  File "C:\Python25\lib\site-packages\django\db\backends\util.py",
> > line 42, in _
> > _getattr__
> >    return getattr(self.cursor, attr)
> > AttributeError: 'Cursor' object has no attribute 'fechall'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Getting 'instance' in ModelForms

2008-05-16 Thread Greg Taylor

To elaborate, I can't do a self.instance, as it errors saying "self is
not defined". For example:

color_field =
forms.ModelMultipleChoiceField(queryset=self.instance.colors)

I need to find the difference of two lists on a model to form the
queryset in my application.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom SQL problem

2008-05-16 Thread Tim Chase

> I can't execute custom SQL.  'Cursor' object has no attribute
> 'fechone',  and 'fechall'

Try "fetchone" and "fetchall" (with the letter "t")

However, for your use-case, you may prefer to simply use the 
.values() method of a recordset:

   Labels.objects.values("id")

as described at

http://www.djangoproject.com/documentation/db-api/#values-fields

-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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: custom SQL problem

2008-05-16 Thread Karen Tracey
On Fri, May 16, 2008 at 10:45 AM, enri57ar <[EMAIL PROTECTED]> wrote:

>
> I can't execute custom SQL.  'Cursor' object has no attribute
> 'fechone',  and 'fechall'
> I have a model named 'Labels' with db_name = 'labels'.
>

You're missing a 't' in fetchone() and fetchall().

Karen


>
>
> mysql> SELECT id FROM labels;
> ++
> | id |
> ++
> |  1 |
> |  3 |
> ++
> 2 rows in set (0.00 sec)
>
> 
>
> >>> django.get_version()
> u'0.97-pre-SVN-7523'
> >>>
> >>> Labels.objects.count()
> 2L
> >>> from django.db import connection
> >>> cursor = connection.cursor()
> >>> cursor.execute("SELECT id FROM labels;")
> 2L
> >>>
> >>>
> >>> row = cursor.fechone()
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "C:\Python25\lib\site-packages\django\db\backends\util.py",
> line 42, in _
> _getattr__
>return getattr(self.cursor, attr)
> AttributeError: 'Cursor' object has no attribute 'fechone'
> >>>
> >>>
> >>> row = cursor.fechall()
> Traceback (most recent call last):
>  File "", line 1, in 
>  File "C:\Python25\lib\site-packages\django\db\backends\util.py",
> line 42, in _
> _getattr__
>return getattr(self.cursor, attr)
> AttributeError: 'Cursor' object has no attribute 'fechall'
> >
>

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



custom SQL problem

2008-05-16 Thread enri57ar

I can't execute custom SQL.  'Cursor' object has no attribute
'fechone',  and 'fechall'
I have a model named 'Labels' with db_name = 'labels'.


mysql> SELECT id FROM labels;
++
| id |
++
|  1 |
|  3 |
++
2 rows in set (0.00 sec)



>>> django.get_version()
u'0.97-pre-SVN-7523'
>>>
>>> Labels.objects.count()
2L
>>> from django.db import connection
>>> cursor = connection.cursor()
>>> cursor.execute("SELECT id FROM labels;")
2L
>>>
>>>
>>> row = cursor.fechone()
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\site-packages\django\db\backends\util.py",
line 42, in _
_getattr__
return getattr(self.cursor, attr)
AttributeError: 'Cursor' object has no attribute 'fechone'
>>>
>>>
>>> row = cursor.fechall()
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python25\lib\site-packages\django\db\backends\util.py",
line 42, in _
_getattr__
return getattr(self.cursor, attr)
AttributeError: 'Cursor' object has no attribute 'fechall'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: partially edit an object

2008-05-16 Thread Robin Becker

koenb wrote:
sted a snippet on
> djangosnippets with my DisplayModelForm [1].
> Basically, it allows you to reuse your form definitions, but turn them
> into a "display_only" mode. You can do all fields or just a few.
> ..
I've passed this to my colleague who will no doubt digest in due time; thanks.
-- 
Robin Becker

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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread Julien

I would see at least two things to keep your files secure on a shared
hosting service: make sure permissions are set correctly (e.g. don't
give any right to "others" to your home directory), and use a complex
password for your account (using numbers, a mix or lowercased and
uppercased characters, et no word from the dictionary).
Following that kind of basic precautions I'd put all my trust in hosts
like webfaction.

On May 17, 12:16 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, May 16, 2008 at 9:15 AM, ydjango <[EMAIL PROTECTED]> wrote:
> > Yes, that was another thing on my mind, how to encrypt password in
> > settings.py
>
> You don't. I think either you misunderstand how shared hosting works,
> or you have an extremely bad host.
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Problem with abstract model class

2008-05-16 Thread Julien

Hi,

I think it should be %(class)s, not %s(class)s(take out the first
's')

Julien

On May 16, 11:33 pm, Legioneer <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> Got a problem when trying to define an abstract class. Below there is
> an examle:
>
> class PaymentData(models.Model):
> owner = models.ForeignKey(Customer,
> related_name="%s(class)s_related" )
>
> class Meta:
> abstract = True
>
> When running 'python manage.py validate' receive an error:
>
> 
> ...
>  File "/usr/lib/python2.3/site-packages/django/db/models/base.py",
> line 89, in add_to_class
> value.contribute_to_class(cls, name)
>   File "/usr/lib/python2.3/site-packages/django/db/models/options.py",
> line 70, in contribute_to_class
> raise TypeError, "'class Meta' got invalid attribute(s): %s" %
> ','.join(meta_attrs.keys())
> TypeError: 'class Meta' got invalid attribute(s): abstract
>
> What can be the problem?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread James Bennett

On Fri, May 16, 2008 at 9:15 AM, ydjango <[EMAIL PROTECTED]> wrote:
> Yes, that was another thing on my mind, how to encrypt password in
> settings.py

You don't. I think either you misunderstand how shared hosting works,
or you have an extremely bad host.


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

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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread ydjango

Yes, that was another thing on my mind, how to encrypt password in
settings.py


On May 16, 3:20 am, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On Fri, May 16, 2008 at 5:02 AM, ydjango <[EMAIL PROTECTED]> wrote:
> > I have propriety commercial code and some formula/ algo
> > implementations which I do not want to expose.
> > Hence I do not want to upload .py source files
>
> If your host's setup would allow other users to view this code, you
> have much larger and much more dangerous security problems to worry
> about (since, for example, that would mean they could also see
> sensitive passwords in configuration files).
>
> --
> "Bureaucrat Conrad, you are technically correct -- the best kind of correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Linux distros

2008-05-16 Thread Javier Rivera

> What works for you?

Ubuntu + Eric4 as ide + Mysql.

Javier.

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



Problem with abstract model class

2008-05-16 Thread Legioneer

Hi All,

Got a problem when trying to define an abstract class. Below there is
an examle:

class PaymentData(models.Model):
owner = models.ForeignKey(Customer,
related_name="%s(class)s_related" )

class Meta:
abstract = True

When running 'python manage.py validate' receive an error:


...
 File "/usr/lib/python2.3/site-packages/django/db/models/base.py",
line 89, in add_to_class
value.contribute_to_class(cls, name)
  File "/usr/lib/python2.3/site-packages/django/db/models/options.py",
line 70, in contribute_to_class
raise TypeError, "'class Meta' got invalid attribute(s): %s" %
','.join(meta_attrs.keys())
TypeError: 'class Meta' got invalid attribute(s): abstract

What can be the problem?


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



Re: partially edit an object

2008-05-16 Thread koenb

Robin,

I don't know if this is a 'right' way, but I posted a snippet on
djangosnippets with my DisplayModelForm [1].
Basically, it allows you to reuse your form definitions, but turn them
into a "display_only" mode. You can do all fields or just a few.
I use it to display objects to users, with an edit button, which shows
the same object, but this time in the normal ModelForm way. The
advantage is that the layout is more or less the same for the user,
and for me that I can reuse my form definitions and my templates for
both.
I have put this inside a bunch of custom crud views, because I needed
this same pattern for a lot of objects.
Obviously, using the newforms machinery to just display an object is
not exactly efficient, but for me that is not an issue.

Hope this helps,

Koen

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

On 15 mei, 15:37, Robin Becker <[EMAIL PROTECTED]> wrote:
> I have a colleague who wishes to restrict the editability of fields 
> dynamically.
> I can see how this arises by considering a Person object. The supervisor role
> might be allowed to edit more than the individual concerned.
>
> We looked in vain for an 'easy' way to do this using old forms, newforms,
> generic views etc etc, but eventually started writing our own views to do 
> this.
>
> Sure I could probably start trying to grok the inner horrors of update_object
> and minulators etc etc, but that seems really overkill for such a simple
> requirement.
>
> I expected to be able to pass in a list of fields that were to be left alone 
> or
> something as easy. Is there no easy way to do these simple extensions; if not
> what's the 'right' way to do this in the various contexts?
> --
> Robin Becker
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Linux distros

2008-05-16 Thread Matic Žgur

I'm using Ubuntu, vim, sqlite3, svn and Django development server.

Matic Žgur

On Fri, May 16, 2008 at 2:59 PM, Almir Karic <[EMAIL PROTECTED]> wrote:
>
> On Fri, May 16, 2008 at 12:24 PM, JonSidnell <[EMAIL PROTECTED]> wrote:
>> What works for you?
>
> debian & vim, tho i'm considering switching to openbsd as my primary OS.
>
>
> --
> For far too long, power has been concentrated in the hands of "root"
> and his "wheel" oligarchy. We have instituted a dictatorship of the
> users. All system administration functions will be handled by the
> People's Committee for Democratically Organizing the System (PC-DOS).
>
> >
>

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



Re: Django and Linux distros

2008-05-16 Thread Valts Mazurs
Ubuntu for desktop.
FreeBSD and OpenBSD for production server.

Regards,
Valts.

On Fri, May 16, 2008 at 3:59 PM, Almir Karic <[EMAIL PROTECTED]> wrote:

>
> On Fri, May 16, 2008 at 12:24 PM, JonSidnell <[EMAIL PROTECTED]> wrote:
> > What works for you?
>
> debian & vim, tho i'm considering switching to openbsd as my primary OS.
>
>
> --
> For far too long, power has been concentrated in the hands of "root"
> and his "wheel" oligarchy. We have instituted a dictatorship of the
> users. All system administration functions will be handled by the
> People's Committee for Democratically Organizing the System (PC-DOS).
>
> >
>

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



Re: Django and Linux distros

2008-05-16 Thread Almir Karic

On Fri, May 16, 2008 at 12:24 PM, JonSidnell <[EMAIL PROTECTED]> wrote:
> What works for you?

debian & vim, tho i'm considering switching to openbsd as my primary OS.


-- 
For far too long, power has been concentrated in the hands of "root"
and his "wheel" oligarchy. We have instituted a dictatorship of the
users. All system administration functions will be handled by the
People's Committee for Democratically Organizing the System (PC-DOS).

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



Re: This field is required. NO!

2008-05-16 Thread Kenneth Gonsalves


On 16-May-08, at 5:48 PM, Andre Meyer wrote:

> still need to figure out why ;-)

by default, django treats all fields as not null and not blank.  
Usually, the 'null' part is enforced at the database level and the  
'blank' part at django level. So for fields like CharFields, saying  
null is allowed is not the same as saying blank is allowed.

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Getting 'instance' in ModelForms

2008-05-16 Thread Greg Taylor

Is there a way to get the value of the 'instance' keyword argument
from within a Form sub-classed by ModelForm? For example:

class CS_SKU(models.Model):
colors = models.ManyToManyField(Color, blank=True, null=True)
color_field = forms.ModelMultipleChoiceField(queryset=colors)

class Form_SKU(ModelForm):
"""
The form for updating SKUs.
"""
selected = self.instance.colors

def some_test_view():
   Form_SKU(instance=)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Linux distros

2008-05-16 Thread Kevin Monceaux

Jon,

On Fri, 16 May 2008, JonSidnell wrote:

> I'm suddenly struck by the notion that I would like to be dev'ing
> Django on Linux of some flavour rather than Windows.

Congratulations!!!

> It's been a wee while since I stuck my toes in the Linux waters, so I 
> was wondering if anyone here has any recommendations for a dev machine 
> setup?

My personal distro preference is Debian.

> Due to the django host I've signed with, I'm largely stuck with MySQL, 
> and don't mind using the manage.py dev server while actually developing.

I have both PostgreSQL and MySQL on my Debian box.

> Everything else is up for grabs in my mind - distro, editor, desktop 
> manager skin, whatever! Although I'm unlikely to man up to something 
> like emacs or vi for code editing...

If you don't like vi and/or emacs you probably don't want to ask me about 
desktop managers or editors.  I use vim for editing and Ion for desktop 
management.  I have also used emacs off and on in the past.



Kevin
http://www.RawFedDogs.net
http://www.WacoAgilityGroup.org
Bruceville, TX

Si hoc legere scis nimium eruditionis habes.
Longum iter est per praecepta, breve et efficax per exempla!!!


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



Re: This field is required. NO!

2008-05-16 Thread Andre Meyer
oh dear, this seems to be a well-known thing.

thanks so much for this, it works!

still need to figure out why ;-)

thanks to you all
André


On Fri, May 16, 2008 at 1:10 PM, Ben Ford <[EMAIL PROTECTED]> wrote:

>
> Andre,
>
> You also need blank=True here:
> pn = models.CharField('Publication number', max_length=20, null=True)
>
>
> That will fix you :-)
> Ben
>
>
> Andre Meyer wrote:
> > hi all
> >
> > now, this is driving me crazy. this problem persists even after
> > switching from 0.96.1 to the newforms-admin branch.
> >
> > after declaring a model class with an attribute that may be null (pn)
> > the admin site still tells me to fill in that field, because "This
> > field is required.", but it isn't.
> >
> > i have registered the model class to the admin site without any custom
> > options.
> >
> > recreated the database file (sqlite) after switching to the na branch.
> >
> > checked in SQLite Manager that the pn field may indeed be null.
> >
> > new Dossier instances can be created and saved in the shell without
> > the pn attribute, but when viewing the instance on the admin page and
> > pressing Save, the error appears.
> >
> > what is the matter?
> >
> > thanks for your suggestions
> > cheers
> > André
> >
> >
> > code:
> >
> > /model.py
> > /
> > class Dossier(models.Model):
> > an = models.CharField('Dossier number', max_length=10,
> > primary_key=True)
> > pn = models.CharField('Publication number', max_length=20, null=True)
> >
> > def __unicode__(self):
> > return self.an 
> >
> > admin.site.register(Dossier)
> >
> >
> > >
>
>
> >
>

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



Keeping track of which user did what

2008-05-16 Thread Chris Farley

Django has that nice "auto_add=True" property you can set on a model's
field. I have two fields in my models called "created_at" and
"updated_at" that keeps track of each model instance's creation/
modification date. It's incredibly easy.

I also want to keep track of which user created/updated each instance.
Right now, I'm doing this from my views -- I just get the user from
the request object and manually populate my "created_by" and
"updated_by" fields. This definitely violates the DRY principle... I
would love to move this code into my model code (by maybe overriding
the save method), but I don't think I have access to the request
object in my models.

Any suggestions? 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: This field is required. NO!

2008-05-16 Thread Ben Ford

Andre,

You also need blank=True here:
pn = models.CharField('Publication number', max_length=20, null=True)


That will fix you :-)
Ben


Andre Meyer wrote:
> hi all
>
> now, this is driving me crazy. this problem persists even after
> switching from 0.96.1 to the newforms-admin branch.
>
> after declaring a model class with an attribute that may be null (pn)
> the admin site still tells me to fill in that field, because "This
> field is required.", but it isn't.
>
> i have registered the model class to the admin site without any custom
> options.
>
> recreated the database file (sqlite) after switching to the na branch.
>
> checked in SQLite Manager that the pn field may indeed be null.
>
> new Dossier instances can be created and saved in the shell without
> the pn attribute, but when viewing the instance on the admin page and
> pressing Save, the error appears.
>
> what is the matter?
>
> thanks for your suggestions
> cheers
> André
>
>
> code:
>
> /model.py
> /
> class Dossier(models.Model):
> an = models.CharField('Dossier number', max_length=10,
> primary_key=True)
> pn = models.CharField('Publication number', max_length=20, null=True)
>
> def __unicode__(self):
> return self.an 
>
> admin.site.register(Dossier)
>
>
> >


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



Re: This field is required. NO!

2008-05-16 Thread Jarek Zgoda

Andre Meyer pisze:

> now, this is driving me crazy. this problem persists even after
> switching from 0.96.1 to the newforms-admin branch.
> 
> after declaring a model class with an attribute that may be null (pn)
> the admin site still tells me to fill in that field, because "This field
> is required.", but it isn't.
> 
> i have registered the model class to the admin site without any custom
> options.
> 
> recreated the database file (sqlite) after switching to the na branch.
> 
> checked in SQLite Manager that the pn field may indeed be null.
> 
> new Dossier instances can be created and saved in the shell without the
> pn attribute, but when viewing the instance on the admin page and
> pressing Save, the error appears.
> 
> what is the matter?

http://www.b-list.org/weblog/2006/jun/28/django-tips-difference-between-blank-and-null/

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

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



Re: This field is required. NO!

2008-05-16 Thread Kenneth Gonsalves


On 16-May-08, at 5:36 PM, Andre Meyer wrote:

> after declaring a model class with an attribute that may be null  
> (pn) the admin site still tells me to fill in that field, because  
> "This field is required.", but it isn't.

have you set blank=True?

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: This field is required. NO!

2008-05-16 Thread Scott Moonen
Andre, in addition to saying null=True, try adding blank=True.

  -- Scott

On Fri, May 16, 2008 at 8:06 AM, Andre Meyer <[EMAIL PROTECTED]>
wrote:

> hi all
>
> now, this is driving me crazy. this problem persists even after switching
> from 0.96.1 to the newforms-admin branch.
>
> after declaring a model class with an attribute that may be null (pn) the
> admin site still tells me to fill in that field, because "This field is
> required.", but it isn't.
>
> i have registered the model class to the admin site without any custom
> options.
>
> recreated the database file (sqlite) after switching to the na branch.
>
> checked in SQLite Manager that the pn field may indeed be null.
>
> new Dossier instances can be created and saved in the shell without the pn
> attribute, but when viewing the instance on the admin page and pressing
> Save, the error appears.
>
> what is the matter?
>
> thanks for your suggestions
> cheers
> André
>
>
> code:
>
> *model.py
> *
> class Dossier(models.Model):
> an = models.CharField('Dossier number', max_length=10,
> primary_key=True)
> pn = models.CharField('Publication number', max_length=20, null=True)
>
> def __unicode__(self):
> return self.an
>
> admin.site.register(Dossier)
>
>
> >
>


-- 
http://scott.andstuff.org/ | http://truthadorned.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: This field is required. NO!

2008-05-16 Thread Almir Karic

On Fri, May 16, 2008 at 2:06 PM, Andre Meyer <[EMAIL PROTECTED]> wrote:
> pn = models.CharField('Publication number', max_length=20, null=True)

missing a 'blank=True'

-- 
For far too long, power has been concentrated in the hands of "root"
and his "wheel" oligarchy. We have instituted a dictatorship of the
users. All system administration functions will be handled by the
People's Committee for Democratically Organizing the System (PC-DOS).

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



This field is required. NO!

2008-05-16 Thread Andre Meyer
hi all

now, this is driving me crazy. this problem persists even after switching
from 0.96.1 to the newforms-admin branch.

after declaring a model class with an attribute that may be null (pn) the
admin site still tells me to fill in that field, because "This field is
required.", but it isn't.

i have registered the model class to the admin site without any custom
options.

recreated the database file (sqlite) after switching to the na branch.

checked in SQLite Manager that the pn field may indeed be null.

new Dossier instances can be created and saved in the shell without the pn
attribute, but when viewing the instance on the admin page and pressing
Save, the error appears.

what is the matter?

thanks for your suggestions
cheers
André


code:

*model.py
*
class Dossier(models.Model):
an = models.CharField('Dossier number', max_length=10, primary_key=True)
pn = models.CharField('Publication number', max_length=20, null=True)

def __unicode__(self):
return self.an

admin.site.register(Dossier)

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



Re: Uploading files to subdirectories

2008-05-16 Thread Sergio

Hello James,

You can do that following this:

http://code.djangoproject.com/wiki/CustomUploadAndFilters

It uses signals to customize the upload path.

James McGill escribió:
> Hi All,
> I'm new to Django and I'm not sure how best to achieve the following:
>
> Users may upload files - each uploaded file is tied to a user in the
> database using a ForeignKey.
>
> In order to prevent pain to the underlying O/S I don't want to put all
> these files in to a single directory. I could separate the files by
> upload time as mentioned in the Django documentation, but it would be
> nicer to have all the files uploaded by a single user under a single
> subdirectory.
>
> Example:
> Greg uploads "holiday.rtf", it is saved as /media/uploads/greg/
> holiday.rtf
> Sally uploads "family.rtf", it is saved as /media/uploads/sally/
> family.rtf
>
> My current model:
>
> class FileModel(models.Model):
> user = models.ForeignKey(User)
> file = models.FileField(upload_to = 'uploads/'
>
> I am saving the file using FileModel_Instance.save_file_file('path',
> file_contents). Adding extra folders to the path (i.e. path = greg/
> holiday.rtf) doesn't work - I assume this is a security restriction.
>
> I am using the SVN version of Django. Any help would be appreciated.
>
> Regards,
> James
>
>
> >
>   


-- 
   Un saludote..
 --==@ Sergio @==--

Barraquito.net - http://www.barraquito.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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Printing out HTML that doesn't get converted to

2008-05-16 Thread Gabriel

Alex  gmail.com> writes:

> 
> 
> I'm working on my first Django project and I can't seem to get
> information printed out as I would like it. I'm trying to print out
> quotes to a page with the newlines turned into HTML  tags (similar
> to PHP's nl2br function). So far I've been able to do this using the
> __str__ function for the Quote model, but it escapes the tags into
> html entities that I see the tags in my browser instead of the line
> breaks. I'm using the development version of Django.
> 

Hi Alex

AFAIK the Django dev version automatically escapes output unless you mark it
safe. Check the docs for more info.


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



Custom model field for sequence-functionality

2008-05-16 Thread mwebs

Hello,

what I need is a modelField that provides sequence-functionality for a
model.
This field should have the following features:
- auto_increment when a new instance of the Model is created
- a method move_up() // Increments the sequence of the object
- a method move_down() // Decreases the sequence of the object
- a method sync_order() // Syncronizes all sequences; This sould be
called when a certain model-instance was deleted. The method finds the
"hole" and decreses all other items greater than the one that was
deleted.

My plan was to extend PositiveIntegerField and adding the desired
functionality.
But I could not figure out how to add auto_increment, without falling
back to raw sql.
...and how to add the 3 methods I mentioned above

Here a short example how a Model containing the  SequenceField should
be used:

n = News.objects.get(pk = id)
n.moveUp() || n.moveDown()

I am relativley new to Django, and need some help of how to implement
this custom model field.
Thanks, Toni
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django and Linux distros

2008-05-16 Thread Jarek Zgoda

JonSidnell pisze:


> It's been a wee while since I stuck my toes in the Linux waters, so I
> was wondering if anyone here has any recommendations for a dev machine
> setup? Due to the django host I've signed with, I'm largely stuck with
> MySQL, and don't mind using the manage.py dev server while actually
> developing. Everything else is up for grabs in my mind - distro,
> editor, desktop manager skin, whatever! Although I'm unlikely to man
> up to something like emacs or vi for code editing...
> 
> What works for you?

If you ever plan to use PostgreSQL instead of MySQL, stay away from
OpenSuse 10.3, I did not found a way to have working psycopg1 in this
distro. I'd recommend Ubuntu, but YMMV.

-- 
Jarek Zgoda
Skype: jzgoda | GTalk: [EMAIL PROTECTED] | voice: +48228430101

"We read Knuth so you don't have to." (Tim Peters)

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



Re: Django and Linux distros

2008-05-16 Thread Andre Meyer
hi Jon

ubuntu certainly works like a charm and you may want to use eclipse with
pydev, just like on windows. i use it on both platforms (even on the same
machine using a shared partition).

cheers
André


On Fri, May 16, 2008 at 12:24 PM, JonSidnell <[EMAIL PROTECTED]> wrote:

>
> Hi everyone
>
> I'm suddenly struck by the notion that I would like to be dev'ing
> Django on Linux of some flavour rather than Windows.
>
> It's been a wee while since I stuck my toes in the Linux waters, so I
> was wondering if anyone here has any recommendations for a dev machine
> setup? Due to the django host I've signed with, I'm largely stuck with
> MySQL, and don't mind using the manage.py dev server while actually
> developing. Everything else is up for grabs in my mind - distro,
> editor, desktop manager skin, whatever! Although I'm unlikely to man
> up to something like emacs or vi for code editing...
>
> What works for you?
>
> Cheers
> Jon
> >
>

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



Re: Django and Linux distros

2008-05-16 Thread Kenneth Gonsalves


On 16-May-08, at 3:54 PM, JonSidnell wrote:

> What works for you?

try mandriva spring 2008 - perfect for people migrating from the  
windows world

-- 

regards
kg
http://lawgon.livejournal.com
http://nrcfosshelpline.in/code/




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



Re: Django and Linux distros

2008-05-16 Thread Gabriel

JonSidnell  gmail.com> writes:

> 
> 
> Hi everyone
> 
> I'm suddenly struck by the notion that I would like to be dev'ing
> Django on Linux of some flavour rather than Windows.
> 
> It's been a wee while since I stuck my toes in the Linux waters, so I
> was wondering if anyone here has any recommendations for a dev machine
> setup? Due to the django host I've signed with, I'm largely stuck with
> MySQL, and don't mind using the manage.py dev server while actually
> developing. Everything else is up for grabs in my mind - distro,
> editor, desktop manager skin, whatever! Although I'm unlikely to man
> up to something like emacs or vi for code editing...
> 
> What works for you?
> 

Hello mate

I've been using Ubuntu 8.04 desktop on my macbook. It's really superb. I prefer
gnome because in Ubuntu it is so much more polished. I can also get apache,
mysql, etc running, along with any revision control system I desire - which at
the moment means Bazaar.

For actually editing I use Gedit, with the extra plugins installed, and all
snippets etc enabled. If I don't feel like Gedit I use Komodo IDE.

I think we both need to do some soul-searching to pluck up enough courage to
take on the mighty beasts of Vi and Emacs!!


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



Django and Linux distros

2008-05-16 Thread JonSidnell

Hi everyone

I'm suddenly struck by the notion that I would like to be dev'ing
Django on Linux of some flavour rather than Windows.

It's been a wee while since I stuck my toes in the Linux waters, so I
was wondering if anyone here has any recommendations for a dev machine
setup? Due to the django host I've signed with, I'm largely stuck with
MySQL, and don't mind using the manage.py dev server while actually
developing. Everything else is up for grabs in my mind - distro,
editor, desktop manager skin, whatever! Although I'm unlikely to man
up to something like emacs or vi for code editing...

What works for you?

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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread James Bennett

On Fri, May 16, 2008 at 5:02 AM, ydjango <[EMAIL PROTECTED]> wrote:
> I have propriety commercial code and some formula/ algo
> implementations which I do not want to expose.
> Hence I do not want to upload .py source files

If your host's setup would allow other users to view this code, you
have much larger and much more dangerous security problems to worry
about (since, for example, that would mean they could also see
sensitive passwords in configuration files).


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

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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread Gabriel

ydjango  gmail.com> writes:


> I have propriety commercial code and some formula/ algo
> implementations which I do not want to expose.
> Hence I do not want to upload .py source files
> 
> Is rewriting that business logic in a compiled langauge only way out?
> how do I call it from python, Using web services?
> 


No no, I have come across a number of ways of obfuscating Python code, just have
a search. Using the .pyc files provides weaker obfuscation which may or may not
be enough. Can you not simply do something using rsync:
rsync -vrlptzH --delete --progress /home/user/*.pyc \
[EMAIL PROTECTED]:/home/user/www

Can't remember what exactly to get rsync to only copy pyc files but check the
man pages. Otherwise you could look at scp.


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



Re: how to avoid uploading .py source files to shared hosting server

2008-05-16 Thread ydjango

I have propriety commercial code and some formula/ algo
implementations which I do not want to expose.
Hence I do not want to upload .py source files

Is rewriting that business logic in a compiled langauge only way out?
how do I call it from python, Using web services?



Ashish

On May 15, 2:51 pm, jonknee <[EMAIL PROTECTED]> wrote:
> > I want to upload only .pyc and no source files. Whats the best way to
> > make sure my .pyc works there.
>
> Your best bet is to probably upload the .py files, run the app and
> then delete the .py files. That way you're sure that the .pyc files
> are compatible. But unless you really need to get rid of the .py
> files, you should leave them be.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



hot pictures of indian actress, models and fashion shows

2008-05-16 Thread nagma

hot pictures of indian actress, models and fashion shows

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



Re: Printing out HTML that doesn't get converted to

2008-05-16 Thread Adi J. Sieker

Alex wrote:
> I'm working on my first Django project and I can't seem to get
> information printed out as I would like it. I'm trying to print out
> quotes to a page with the newlines turned into HTML  tags (similar
> to PHP's nl2br function). So far I've been able to do this using the
> __str__ function for the Quote model, but it escapes the tags into
> html entities that I see the tags in my browser instead of the line
> breaks. I'm using the development version of Django.
> 
> Here's what my __str__ function looks like:
> 
> return self.quote.replace('\n', '')
> 
> And I'm just printing them out with a generic view that looks like
> this:
> 
> {% for quote in object_list %}
> {{ quote }}
You need to run your HTML through the safe filter.
Django auto escapes HTML.
so the above would be {{ quote|safe}}

see 
http://www.djangoproject.com/documentation/templates/#automatic-html-escaping

adi

-- 
Adi J. Sieker mobile: +49 - 178 - 88 5 88 13
Freelance developer   skype:  adijsieker
SAP-Consultantweb:http://www.sieker.info/profile
   openbc: https://www.openbc.com/hp/AdiJoerg_Sieker/

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



Mysql vs. sqlite filtering of datetimefields with None values

2008-05-16 Thread Hans

I have recently come across a slight difference in the way that
datetimefields are handled by mysql and sqlite. Locally, on my desktop
I use sqlite for debugging, while the production server runs mysql.
Running django-trunk. One of my models includes a datetimefield:

last_fetched = models.DateTimeField(null=True, blank=True)

In some of my instances the field is still None, while others have a
datetime set. When trying to filter on the instances where the
datetime is earlier/lower than a given date or the datetime is still
None I initially tried something along the lines of:

queryset_something.exclude(last_fetched__gt=given_date)

On sqlite this returned both the datetimes that where lower and the
once not yet set. On mysql, however, it did not return the empty
datetimes. I then tried to use Q-objects, like this:

queryset_something.filter(Q(last_fetched__lt=given_date) |
Q(last_fetched__isnull = True))

This worked, but I keep wondering if this is the best sollution and if
this actually is an unwanted inconsistency of Django. Comments?


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



Uploading files to subdirectories

2008-05-16 Thread James McGill

Hi All,
I'm new to Django and I'm not sure how best to achieve the following:

Users may upload files - each uploaded file is tied to a user in the
database using a ForeignKey.

In order to prevent pain to the underlying O/S I don't want to put all
these files in to a single directory. I could separate the files by
upload time as mentioned in the Django documentation, but it would be
nicer to have all the files uploaded by a single user under a single
subdirectory.

Example:
Greg uploads "holiday.rtf", it is saved as /media/uploads/greg/
holiday.rtf
Sally uploads "family.rtf", it is saved as /media/uploads/sally/
family.rtf

My current model:

class FileModel(models.Model):
user = models.ForeignKey(User)
file = models.FileField(upload_to = 'uploads/'

I am saving the file using FileModel_Instance.save_file_file('path',
file_contents). Adding extra folders to the path (i.e. path = greg/
holiday.rtf) doesn't work - I assume this is a security restriction.

I am using the SVN version of Django. Any help would be appreciated.

Regards,
James


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



Re: MySQL Boolean vs. PostgresQL Boolean

2008-05-16 Thread Karen Tracey
On Thu, May 15, 2008 at 7:04 PM, Szaijan <[EMAIL PROTECTED]> wrote:

>
> I see it in my views.  When I return the set and saved values for a
> model, I get True or False from my app on the MacBook (Postgres) and 1
> or 0 from the exact same code on my Slicehost site (MySQL.)
>
> So, if I add something like:
>
> m = Model.objects.get(id=id)
> print m.boolean_field_name
>
> I get True/False on my MacBook and 1/0 on my Slicehost site.  I have
> also confirmed this in python manage.py shell.
>
> >>> from visionary.harp.models import Combatant_Template
> >>> ct = Combatant_Template.objects.all()
> >>> ct[0]
> 
> >>> ct[0].party <--- A BooleanField
> 0 <-- result on Slicehost site using MySQL
>
> >>> ct[0].party <--- A BooleanField
> True <-- result on MacBook Pro using PostgreSQL
>
> Perhaps there's a setting I need that is missing?
>

Hmm, that's interesting, and I never noticed it.  I guess I haven't
interrogated values directly like that.  That does seem odd, I'd expect a
boolean field to be returning a boolean value. But in Python 1 == True
evaluates to True and 0 == False evaluates to True, so your code doesn't
really need to care one way or the other what is returned, does it?

I also see on further looking around that there is a ticket open on this:

http://code.djangoproject.com/ticket/7190

Also note you don't have to supply 0/1 when querying. You can filter values,
e.g. on True/False and that works properly.

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Boolean Values: PostgreSQL vs. MySQL

2008-05-16 Thread Karen Tracey
On Thu, May 15, 2008 at 1:59 PM, Szaijan <[EMAIL PROTECTED]> wrote:

> Hi, I developed my first Django app on my Macbook Pro using PostgreSQL
> and
> have recently moved it to a production site which uses MySQL.
> PostgreSQL stores boolean values as True and False, just like Python
> and JS, while MySQL uses 1 and 0.
>
> Is there some automated way to get the models to understand this and
> present/save boolean values to and from views, or do I need to
> override the save and get methods so that they translate 0 to False, 1
> to True, and vice versa?  This seems to be a barrier to portability if
> I have to hard code DB awareness into my models.
>

You don't need to do anything, the right thing will just happen.  Your
Python/Django code deals with boolean fields and doesn't need to know
anything about the details of how MySQL stores them.  (Unless you use raw
sql, in which case you might have to care.)

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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---