Earn Real Money...

2006-08-22 Thread Bugüne Kadar Nelere Üye Olmadik ki?

Play online Backgammon...

The Largest Backgammon Room whole the World...

Try it...

http://www.play65.com/EN/index.html?did=20&tag1=9564


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



enhance Adimin interface

2006-08-22 Thread Rares Vernica

Hi,

I like the Admin interface very much. :)

Currently the Admin interface is designed for adding or changing 
objects, bot not for *viewing* them. I am thinking to enhance it with 
view capabilities.

For example, when you want to change an object you have some nice 
features to select the object you want to use (like filter or sort). 
When you click on an object you get to change it. I would like to add 
the feature that you can also view the object (without changing it).

Moreover, when you view certain objects, some nice view features can be 
added, like: when the object is an address you get a link to 
google/yahoo maps or when the object is an email you get a "mailto:"; link.

In immediate use case would be a Contacts application where you can use 
the filtering and sorting capabilities of the Admin interface and when 
you find the right contact you get to view it nicely. (If you want to 
change it you get to do that very easily also.)

I would not like to reinvent all the nice Admin features.

Do you think is possible to easily extend the Admin interface? What 
would be a good point to start?

Thanks in advance,
Ray


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Lost in the Admin section...

2006-08-22 Thread Sean Schertell

On Aug 23, 2006, at 2:48 PM, Burhan wrote:

> return self.date.strftime("%b %d %Y")

Thanks Burhan, I actually tried that and it didn't work. But now I  
try it again and it works great. I guess I must have had some kind of  
syntax error last time. Anyway -- that's the stuff. One down, seven  
to go ;-)

Sean


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Lost in the Admin section...

2006-08-22 Thread Sean Schertell


On Aug 23, 2006, at 1:59 PM, Bryan Murdock wrote:

>
> On 8/22/06, Sean Schertell <[EMAIL PROTECTED]> wrote:
>> (4) I don't want to use Users/Groups/Sites at all. What's the best
>> way to make it completely go away?
>
> I think if you remove them from your INSTALLED_APPS setting they will
> probably go away.  I haven't tried it yet, you might need to
> ./manage.py sqlcear  for each of them too.
>
>> (6) I meticulously followed instructions for overwriting the admin/
>> base_site.html template. It worked before when I went through the
>> tutorial but now I can't get it to work for some mysterious reason.
>> I've checked all the obvious stuff and don't know where to go from
>> here. Any tips for troubleshooting this?
>
> I had this problem once, and if I remember right it's because I
> changed something in settings.py, TEMPLATE_DIRS or TEMPLATE_LOADERS
> maybe.  Anyway, check those.
>
>> Sorry to overwhelm the list with noobie questions -- I promise to
>> help out other noobs once I get a handle on Django :-)
>
> Bryan, another noob trying to pay it forward.


And pay it forward you have! I owe ya one (two actually).

In case it helps someone else:

For #4:
Just remove these two lines from installed apps:
'django.contrib.auth',
'django.contrib.sites',

For #6:
Don't be an idiot and try to use a relative path for your templates  
dir ;-)

So that's 3 down (incl Burhan's solution to #1), and 5 to go.

:-)

Sean

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Lost in the Admin section...

2006-08-22 Thread Burhan

Finally, something I do know about because I struggled with the same
problem!

> (1) My model includes an Event class. Events should be displayed
> using the date as their name. So the name of the event might be
> "August 25th, 2006". But if I add a def(self): __str__(self.date) to
> the class, I get an error "__str__ returned non-string (type
> datetime.date)" -- how can I make it a pleasantly formatted date string?

def __str__(self):
  return self.date.strftime("%b %d %Y")

You can see the reference for the time module (
http://docs.python.org/lib/module-time.html ) to get all the formatting
codes for stftime().

I'll try to see if I figure out the rest, as I have run into similar
problems (especially wrt the 24 hour clock thing).


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Better way to do this?

2006-08-22 Thread Burhan

Thanks Russ.  Is there a way to have a multiple select drop down
without using a m2m and a filter?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Lost in the Admin section...

2006-08-22 Thread Bryan Murdock

On 8/22/06, Sean Schertell <[EMAIL PROTECTED]> wrote:
> (4) I don't want to use Users/Groups/Sites at all. What's the best
> way to make it completely go away?

I think if you remove them from your INSTALLED_APPS setting they will
probably go away.  I haven't tried it yet, you might need to
./manage.py sqlcear  for each of them too.

> (6) I meticulously followed instructions for overwriting the admin/
> base_site.html template. It worked before when I went through the
> tutorial but now I can't get it to work for some mysterious reason.
> I've checked all the obvious stuff and don't know where to go from
> here. Any tips for troubleshooting this?

I had this problem once, and if I remember right it's because I
changed something in settings.py, TEMPLATE_DIRS or TEMPLATE_LOADERS
maybe.  Anyway, check those.

> Sorry to overwhelm the list with noobie questions -- I promise to
> help out other noobs once I get a handle on Django :-)

Bryan, another noob trying to pay it forward.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Trouble accessing photos in my template

2006-08-22 Thread SmileyChris

{% for photo in object.photo_set.all %}

{% endfor %}

PS: It would be better to call the field 'entry' rather than 'photoid'


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Lost in the Admin section...

2006-08-22 Thread Sean Schertell

Hi Guys,

A few things I'm trying to figure out -- any pointers would be great!

(1) My model includes an Event class. Events should be displayed  
using the date as their name. So the name of the event might be  
"August 25th, 2006". But if I add a def(self): __str__(self.date) to  
the class, I get an error "__str__ returned non-string (type  
datetime.date)" -- how can I make it a pleasantly formatted date string?

(2) The 24 hour clock widget doesn't work for me. This is a nightclub  
so shows are almost always listed as 7:00pm or 12:30am etc. (am/pm).  
Is there a way for me collect this information more naturally in the  
admin form and then convert it for mysql storage? (note: it needs to  
be stored as a time object so it can be sorted chronologically)

(3) I'm using a pull-down menu for the event status -- using the  
"choices=( ('1','blah'), ('2', 'blahblah'), )" format. I've also got  
a sensible default selection.  But the menu still displays this  
option: "". How can I remove this option from the list?

(4) I don't want to use Users/Groups/Sites at all. What's the best  
way to make it completely go away?

(5) Nine times out of ten, the user is going to want to edit or add  
events immediately after logging into the admin section. Can I set  
the events list page as the index?

(6) I meticulously followed instructions for overwriting the admin/ 
base_site.html template. It worked before when I went through the  
tutorial but now I can't get it to work for some mysterious reason.  
I've checked all the obvious stuff and don't know where to go from  
here. Any tips for troubleshooting this?

(7) For each band that gets displayed, there's an associated photo.  
The admin section displays the filepath -- any way to get it to  
display the actual photo instead?

(8) Any way to make the file upload a little nicer? Like to give you  
some indication that something is happening (ideally a progress bar)?

Sorry to overwhelm the list with noobie questions -- I promise to  
help out other noobs once I get a handle on Django :-)

Sean


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Django Models, DRY, Scalability

2006-08-22 Thread Sean Perry

bayerj wrote:
> As soon as I change my database schema, I have several possibilites to
> get my app up again:
> (a) Change the model. Then drop the current db schema, fire up the new
> one. Drawback: I lose my data.
> (b) Change the model and change the schema manually. Drawback: I am
> repeating myself.
> (c) Make everything right from the start. Drawback: Can only be reached
> asymptotical. (I won't argue about that :)
> 

I have just been dumping the data to a sql file, fixing for the new 
fields and using django initial sql support (myapp/sql/model.sql) to 
import the data each time. Works, is relatively easy and lets me twiddle 
and experiment.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Trouble accessing photos in my template

2006-08-22 Thread keukaman

p.s. I'm using generic views

keukaman wrote:
> I wrote a blog application that included a single image. I originally
> wrote my model so that the image was defined in the same class as the
> rest of the blog entries.
>
> I then decided that I wanted to be able to put multiple images into my
> blog, so I created a "Photo" class, with a var called "photoid =
> models.ForeignKey(Entry, ...)
>
> Anyway, my template originally had this code to access the single photo
> as follows (which worked):
>
> 
>
> Now that I have multiple images outside the "Entry" class, can someone
> share the code I need to use in my template to show those images?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Trouble accessing photos in my template

2006-08-22 Thread keukaman

I wrote a blog application that included a single image. I originally
wrote my model so that the image was defined in the same class as the
rest of the blog entries.

I then decided that I wanted to be able to put multiple images into my
blog, so I created a "Photo" class, with a var called "photoid =
models.ForeignKey(Entry, ...)

Anyway, my template originally had this code to access the single photo
as follows (which worked):



Now that I have multiple images outside the "Entry" class, can someone
share the code I need to use in my template to show those images?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Change App name in Django Admin

2006-08-22 Thread Adrian Holovaty

On 8/22/06, Seth Buntin <[EMAIL PROTECTED]> wrote:
> Can you change the displayed name of the app in the Django admin?

That's not possible at the moment -- Django just uses the name of the
app's Python module. But you can use a custom admin index template to
call it whatever you'd like (and design the page however you'd like);
just override the admin/index.html template.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Change App name in Django Admin

2006-08-22 Thread Seth Buntin

Can you change the displayed name of the app in the Django admin?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: extract keywords from model

2006-08-22 Thread limodou

On 8/23/06, richard mendes <[EMAIL PROTECTED]> wrote:
>
> Barry,
>
> Actually what i was thinking is to get a list with the keywords and
> then go with a forloop threw all keywords and get the values from a
> dictionary where the key's are the same as the keywords only in field
> names.
>
> so what i thought was get the keywords and do the following
> keywords = [ all the keywords from model ]
>
> for keyword in keywords:
>   apa = LupusApa( keyword = dictionary[str(keyword)]
>   apa.save()
>
> i thought this was the best solution there are two problems with this
> is one I couldnt figure out how  i got all the keywords from the model
> in a array and the second was if i save the object apa i gives a error
> because there are some fields that can't be zero.
>
> and i don't know how to create a object apa with all the keywords
> after eachother like ( apa = LupusApa (result_id =
> dictionary['result_id'], lab_id = dictionary['lab_id] ) without
> hardcoding the names in there.
>
> if someone knows how to deal with these two problems it would be a
> great help to me.
>
> thanks in advance,
>
> richard mendes
>
There is a create method in Model Manager Class, and there is a sample
code you can see:

def save(self, data, object_id=None):
params = {}
for key in data:
for f in self.model._meta.fields:
if key == f.column:
params[key] = data[key]
if not object_id:
return self.model.objects.create(**params)
else:
obj = self.model.objects.get(pk=int(object_id))
for key, value in params.items():
if hasattr(obj, key):
setattr(obj, key, params[key])
obj.save()
return obj

This function can create a new object or update a exists object. I
hope it can be some useful.


-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Multiple rows in a form

2006-08-22 Thread Corey Oordt
Stewart:Take a look at http://www.djangoproject.com/documentation/forms/ for more on creating forms, and simplifying the process.You will need to have to figure out how you want to handle the item listings. You will either have to have a static set of items or use some fancy _javascript_/DHTML to dynamically create new item listings.Something like:CoreyOn Aug 22, 2006, at 5:59 AM, [EMAIL PROTECTED] wrote:Hi.I've just started with Django and I'm liking it! A little confusedabout one thing though...I am experimenting with a basic ordering system, the model for whichlook like this:class stock_item(models.Model):    name = models.CharField(maxlength=200)class order(models.Model):    ordered_by = models.CharField(maxlength=200)class order_item(models.Model):    order = models.ForeignKey(order)    stock_item = models.ForeignKey(stock_item)    quantity = models.PositiveSmallIntegerField()This is all fine until I get to a form for placing orders. I envisioneda form something like this:{repeat for each stock_item}    {end}But I'm having some trouble writing the view code for it, does anyonehave any pointers?Thanks,Stewart.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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  -~--~~~~--~~--~--~---


Re: Passing user.is_superuser through form

2006-08-22 Thread Eric

This is what you'd do if you wanted to set is_superuser for a
manipulator and not use the 'hidden input' idea.

let's take your view from the point where you check if the for has been
posted:

manipulator = users.ChangeManipulator(user_id) # Let's get the
manipulator for a user

if request.POST:
  new_data = request.POST.copy() # We get the data from the post dict
  # At this point you can set the is_superuser value in new_data
  new_data['is_superuser'] = user.is_superuser # Perserve the user's
is_superuser
  errors = manipulator.get_validation_errors(new_data)
  ... etc ...

---
Now, that's a simple example, but you can set is_superuser to what ever
you want.  I just set it to the user object's current value so that it
stays the same, when the manipulator saves the object.
---
Take note that, since the is_superuser is not a required field, iirc,
you don't have to set it in new_data if your intent leave the value the
same.
---
As a security side note (this is for everyone in the group and I'm just
thinking out loud)  What if you have this code:

if request.POST:
  new_data = request.POST.copy()
  errors = manpulator.get_validation_errors()
  if not errors:
 manipulator.do_html2python(new_data)
 manipulator.save(new_data)

Let's say you're just have a form that sets the Name of the user,
new_data = {'firstname' : 'Eric', 'lastname' : 'Moritz'}

if someone crafts a melicious form that has three fields, 'firstname',
'lastname', and 'is_superuser' where is_superuser is set to 'on', will
the manipulator ignorantly set the is_superuser field in the user
object?.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: table relationship help

2006-08-22 Thread Rob Hudson

OK, I removed the admin from my Text table, did an edit_line=True and a
core and it works exactly as I pictured.  Awesome.  :)


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Better way to do this?

2006-08-22 Thread Russell Keith-Magee
On 8/23/06, Burhan <[EMAIL PROTECTED]> wrote:
I would appreciate if you could tell me a better way to get the m2mrelationship pulled in -- as the rest of the comments regarding thetemplate are something that I am well aware of.  Also, by better design
-- I didn't mean better design for the database, I meant better designin the sense a more django-way of getting that information out.You pretty much have it. Model.m2mfield.all() (or filtered as appropriate) is the way you traverse m2m relations. If you're dealing with ForeignKeys there are a few things you can do to pre-cache query results (see select_related), but these techniques don't apply to m2m fields.
Yours,Russ Magee %-)

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


Re: django cannot connect to mysql after upgrade

2006-08-22 Thread Baczek

Just wanted to add that I got hit by that too, just now. Hoping for a
quick fix here or in django...


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



Re: table relationship help

2006-08-22 Thread SmileyChris

Hi Rob,

You have the ForeignKey reference in the correct place.

Check out the documentation about edit_inline on the ForeignKey field.
You most likely don't actually need to use the class Admin: on your
Text class.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Formatting FloatField values in templates

2006-08-22 Thread SmileyChris

Hi Cary,

Try the stringformat filter
{{ r.hourly_rate|stringformat:".2f" }}


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Passing user.is_superuser through form

2006-08-22 Thread garaged

On 8/22/06, cyberco <[EMAIL PROTECTED]> wrote:
>
> Max, I'm not sure I fully understand your reply. Currently I got things
> working by passing the user object to the template and returning its
> attribute values:
>
> 
>  value="{{user.is_superuser}}" />
> 
>
> Is this a security hole?

Sean already gave you more details.

You should used exclusively the authentication mechanism to get any
user relevant data like if the user has permission to something, none
of that information can be trusted to a FORM, the form can be
dynamically changed on browsers, there are plugins for that, or you
can be tricked with automatic scripts that do the job as if they were
browsers (thats even more probable).

Hope I'm more clear now :) I assumed that you were experienced on web
development and its security issues, no offese on that please :)

Max
-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GS/S d- s: a-29 C++(+++) ULAHI+++ P+ L++>+++ E--- W++ N* o-- K- w
O- M-- V-- PS+ PE Y-- PGP++ t- 5- X+ R tv++ b+ DI+++ D- G++ e++ h+ r+
z**
--END GEEK CODE BLOCK--

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Re: Passing user.is_superuser through form

2006-08-22 Thread Vance Dubberly
It's not a security hole if you are writing a user management
application. And this information is being made avaliable to a trusted
"administrative user".

However,  if you are using this data to re-populate a user object or
edit user info, or for any purpose not administrative, and not
validating that the end user has permission to edit the is_superuser
property then yes it is. Any user viewing your page can simply view
source, see the hidden field and then use a tool, like "Tamper Data"
to alter the value of the field when the page is submited. This would
give them super user privileges. Even if the data is never stored in
the database they will have super user privs for the life of their log
in session. Which is long enough for any hacker to have a good time
with your site.

Vance



On 8/22/06, cyberco <[EMAIL PROTECTED]> wrote:
>
> Max, I'm not sure I fully understand your reply. Currently I got things
> working by passing the user object to the template and returning its
> attribute values:
>
> 
>  value="{{user.is_superuser}}" />
> 
>
> Is this a security hole?
>
>
> >
>


-- 
Most People are not even aware of their need to conform. They live
under the illusion that they follow their own ideas and inclinations,
that they are individualists, that they have arrived a their opinions
as the result of their own thinking – and that it just happens that
their ideas are the same as those of the majority
-- Eric Fromm

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: In a form: fill the ImageField with path

2006-08-22 Thread Jeremy Dunck
On 8/22/06, cyberco <[EMAIL PROTECTED]> wrote:
>
> In my form I want to enable users to change an image (ImageField), but
> although I can fill fields of other types with their existing values,
> this is not the case with an ImageField. How can I accomplish that?

If I understand what you're asking for correctly, the short answer is,
you can't.

Here's a good writeup:
http://www.cs.tut.fi/~jkorpela/forms/file.html#value

A simple test case is attached.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---









Re: returning related field as part of __str__() method?

2006-08-22 Thread Chris Long

Try either:

   def __str__(self):
return '%s - %s' % (self.name, str(self.category))

or

   def __str__(self):
return '%s - %s' % (self.name, self.category.name)

The problem is that it is using __repr__ to print it out, not str. To
force str you have to use the str(). Or you can override the __repr__
method, I suggest using the str() method, __repr__ should be used more
as a debug tool rather then representing the object w/ more debug
output then str does.

Chris


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Passing user.is_superuser through form

2006-08-22 Thread Jeremy Dunck

On 8/22/06, cyberco <[EMAIL PROTECTED]> wrote:
>
> Max, I'm not sure I fully understand your reply. Currently I got things
> working by passing the user object to the template and returning its
> attribute values:
>
> 
>  value="{{user.is_superuser}}" />
> 
>
> Is this a security hole?

Yes.
Never, ever, trust anything to the client's behavior.

If I knew your site's URL, I could log in as a super user right now.  :)

What's to stop be submitting an HTTP POST w/ a parameter
is_superuser=True?  The browser?  No, it's just bits on the wire.
There is no browser.  ;-)

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



Formatting FloatField values in templates

2006-08-22 Thread [EMAIL PROTECTED]

Hello,

I have some FloatField currency values that I want to display with two
decimal places (regardless of whether there are decimal values or just
".00"), and I can't seem to figure out the "graceful" way to do it. I
have defined the number of decimal places in the model:

hourly_rate = models.FloatField(max_digits=6, decimal_places=2,
core=True)

But values like "50.00" display as "50.0" when I place it in the
template: {{ r.hourly_rate }}

Is there something I can/should use to alter the display format,
perhaps a filter that I'm not aware of?

Thanks,
Cary


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Passing user.is_superuser through form

2006-08-22 Thread Sean

This is a major security hole. Just because a field is hidden doesn't
mean it cannot be changed. Use the request.user object for
authentication purposes. The authentication docs should give you an idea
what to do.


cyberco wrote:
> Max, I'm not sure I fully understand your reply. Currently I got things
> working by passing the user object to the template and returning its
> attribute values:
>
> 
>  value="{{user.is_superuser}}" />
> 
>
> Is this a security hole?
>
>
> >
>
>   


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



table relationship help

2006-08-22 Thread Rob Hudson

Hi,

I'd appreciate some help on how to set this up in Django.  The idea: A
page has many text entries (positions on the page).  Simple enough.

Here's how I was approaching the models (trimmed to remove extra info):

class Template(models.Model):
name = models.CharField(maxlength=64)

class Page(models.Model):
name = models.CharField(maxlength=64)
template = models.ForeignKey(Template)

class Text(models.Model):
page = models.ForeignKey(Page)
text = models.TextField()
position = models.CharField(maxlength=16)

What I'd like to see is only the Template and Page listed in the admin.
 Clicking a Page will show you it's columns, and inline will also show
you all the text for that page.

I feel like Page should reference Text and not the other way around
since that's the way I internalize it.  If I load this into Django the
admin shows me Text with Page as a pull-down.

Is there a better way to represent this?

Thanks,
Rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Passing user.is_superuser through form

2006-08-22 Thread cyberco

Max, I'm not sure I fully understand your reply. Currently I got things
working by passing the user object to the template and returning its
attribute values:





Is this a security hole?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Removing old permissions from auth_permission

2006-08-22 Thread cyberco

Once permissions are added to the auth_permission table it doesn't
matter how often I invoke 'manage.py syncdb app' or 'manage.py reset
app', stale records are never deleted. Is this normal behaviour?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: extract keywords from model

2006-08-22 Thread richard mendes

Barry,

Actually what i was thinking is to get a list with the keywords and
then go with a forloop threw all keywords and get the values from a
dictionary where the key's are the same as the keywords only in field
names.

so what i thought was get the keywords and do the following
keywords = [ all the keywords from model ]

for keyword in keywords:
  apa = LupusApa( keyword = dictionary[str(keyword)]
  apa.save()

i thought this was the best solution there are two problems with this
is one I couldnt figure out how  i got all the keywords from the model
in a array and the second was if i save the object apa i gives a error
because there are some fields that can't be zero.

and i don't know how to create a object apa with all the keywords
after eachother like ( apa = LupusApa (result_id =
dictionary['result_id'], lab_id = dictionary['lab_id] ) without
hardcoding the names in there.

if someone knows how to deal with these two problems it would be a
great help to me.

thanks in advance,

richard mendes

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Image validation works only once

2006-08-22 Thread cyberco

In my model:

=
image = models.ImageField(upload_to='pics',
validator_list=[validators.isValidImage], blank=True)
=

I am able to upload an image once using an appropriate form:

=
Image: {{form.image}}{{form.image_file}}
=

But the second time I try to upload an image I get the error:

=
{'image': ['No file was submitted. Check the encoding type on the
form.']}
=

When I remove the validation (in the model) everything works fine
again...


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Passing user.is_superuser through form

2006-08-22 Thread garaged

On 8/22/06, cyberco <[EMAIL PROTECTED]> wrote:
>
> I want to pass the user.is_superuser attribute through a form without
> enabling the user to edit it, so I use a hidden field. Like this:
>
> TEMPLATE=
>  value="{{userWrapperForm.is_superuser}}" />
> =
>
> Weird enough this results in the following HTML:
>
> =HTML
>  value=" class="vCheckboxField" name="is_superuser" />" />
> =
>
> And when submitted the received new_data for is_super user is:
>
> ===NEW_DATA=
> 'is_superuser': [' FormWrapper?

besides the bad syntax, that I didn't even checked :), you should
never want to do that, that is a security hole, take the superuser
state from the correct object, take a look at the authentication
manual if you don't know how.

Max

-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GS/S d- s: a-29 C++(+++) ULAHI+++ P+ L++>+++ E--- W++ N* o-- K- w
O- M-- V-- PS+ PE Y-- PGP++ t- 5- X+ R tv++ b+ DI+++ D- G++ e++ h+ r+
z**
--END GEEK CODE BLOCK--

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



returning related field as part of __str__() method?

2006-08-22 Thread [EMAIL PROTECTED]

I apologize in advance if this is a stupid question - I'm new to
Django, and a little over my head (but loving it!)

I'm trying to return a field from a foreign key relationship as part of
my __str__ method. When I do, I get this output in the admin interface:

Product Name - 

What am I doing wrong?

Code:

class Product(models.Model):
name = models.CharField(maxlength=100)
category = models.ManyToManyField(Category)
...
   def __str__(self):
return '%s - %s' % (self.name, self.category)

class Category(models.Model):
name = models.CharField(maxlength=100)
   def __str__(self):
return self.name


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



In a form: fill the ImageField with path

2006-08-22 Thread cyberco

In my form I want to enable users to change an image (ImageField), but
although I can fill fields of other types with their existing values,
this is not the case with an ImageField. How can I accomplish that?


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



Custom upload fields and filters

2006-08-22 Thread Enrico

Hi all,

I've made custom file upload fields with some extra features:

- automatic upload_to path (based on app/model/field names)
- automatic renaming the filename based on the primary key
- maximum width and/or height for images

I've created filters to automatically resize/crop images directly from
templates.

The original idea came from *ImageWithThumbnailField, I've recreated as
an exercise and to adapt it to my taste.
* http://trac.studioquattro.biz/djangoutils/wiki/Thumbnail

If someone's insterested, I can share the code.

Regards.
Enrico


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Passing user.is_superuser through form

2006-08-22 Thread cyberco

I want to pass the user.is_superuser attribute through a form without
enabling the user to edit it, so I use a hidden field. Like this:

TEMPLATE=

=

Weird enough this results in the following HTML:

=HTML
" />
=

And when submitted the received new_data for is_super user is:

===NEW_DATA=
'is_superuser': ['http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Admin won't show list of objects

2006-08-22 Thread [EMAIL PROTECTED]

Ok, I fixed it.

I had the following, which used to work, in my models.

date_added = models.DateTimeField(default=models.LazyDate(),
editable=False)

I changed it to the following and it now works.

date_added = models.DateTimeField(default=datetime.now(),
editable=False)

Now everything is fine.

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



Re: Admin won't show list of objects

2006-08-22 Thread [EMAIL PROTECTED]

I just rechecked and everything is using DateTimeField.

I'm pretty sure this happened without me making any changes to my
models. From what I can tell it's a problem with the "change list" that
the admin displays for each object. Before I have added and objects I
get the page but of course it's empty.

Chris


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Admin won't show list of objects

2006-08-22 Thread Waylan Limberg

On 8/22/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hi all,
>
> Has anybody seen the following exception? It was working till I did an
> svn update sometime in the last couple weeks. (I don't often use the
> admin so I'm not sure when.) I also tried getting it working with a
> clean syncdb but still get the error. I'm using sqlite.
>
> The error mesg is:
>
> Caught an exception while rendering: 'datetime.date' object has no
> attribute 'minute'
>
Right, datetime.date has no hours, minutes or seconds whereas
datetime.datetime does. This is a stab in the dark, but are you
perhaps storing times in a DateField rather than a DateTimeField or
visaversa?


-- 

Waylan Limberg
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Custom tags and template inheritance

2006-08-22 Thread Julio Nobrega

  I opened a ticket for a similar problem. It's a feature ;)

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

On 8/22/06, Enrico <[EMAIL PROTECTED]> wrote:
>
> - or the docs should say that "load" tags doesn't get inherited.

-- 
Julio Nobrega - http://www.inerciasensorial.com.br

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



Re: Custom db fields / creation.py

2006-08-22 Thread funk

Hi Ian,
thanks very much, this works fine and it is the OO way, i think. 
Having my pictures regarded :)

Regards,
Frank

Am Donnerstag 17 August 2006 22:42 schrieb Ian Clelland:
> On 8/17/06, Frank Stüss <[EMAIL PROTECTED]> wrote:
> > Hi all,
> > is there a best practice to overwrite/extend
> > django.db.backends..creation without doing it in django
> > source?
> >
> > I want to have a spezialiced ImageField.
>
> Hi Frank,
>
> What I've done in the past, to avoid having to tinker with the backend
> source, is to override the get_internal_type method of my custom
> fields. By default, it returns the name of the class it is called
> from, but you can override that to return the string "ImageField" and
> the database table will be created correctly.
>
> Regards,
> Ian Clelland
> <[EMAIL PROTECTED]>
>
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: list_filter across multiple ForeignKeys

2006-08-22 Thread Waylan Limberg

On 8/22/06, Waylan Limberg <[EMAIL PROTECTED]> wrote:
>
> It occurs to me that it may be related to the inability to sort such
> items in the 'list_display'. For example, in FooBar I also have the
> following property defined:
>
After posting that I remembered that those model methods/properties
are 'row-level' were I want 'table-wide' filtering so I tried a custom
manager. It works great, except I have no idea how to us it with
list_filter, if it's even possable. Anyone have any input on that?

Anyway, here's my manager as it currently stands:

class FooBarManager(models.Manager):
def by_foo(self, fooname):
'''
Returns all FooBars for Bars of a given Foo

Usage:
>>> FooBar.objects.by_foo('Blah')
'''
return self.get_query_set().filter(bar__foo__name=fooname)

As I expected list_filter = ('by_foo') didn't work and doesn't really
make sense anyway. On the otherhand my initial attempt at list_filter
= ('bar__foo') seems like it should work.

-- 

Waylan Limberg
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Are you getting caught in the Django Trac's spam filter? Read this.

2006-08-22 Thread Tom Tobin

It seems I've been designated the "Django spam maven"; what this means
for you, if you've been getting caught in the Django Trac's spam
filters, is that you need to write me and let me know your IP address
(or the typical range of IP addresses you use) so I can whitelist you.
 Once I do this, you won't trigger the "Akismet rejected spam" or any
other spam-rejection errors.

Tom Tobin
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Custom tags and template inheritance

2006-08-22 Thread Enrico

It isn't clear on the docs that custom tags doesn't get inherited from
parent templates.

I can see two paths:

- maybe the template engine should implement this feature (not sure if
this is the best approach, it can end up loading a bunch of useless
stuff).

- or the docs should say that "load" tags doesn't get inherited.

Regards.
Enrico


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Admin won't show list of objects

2006-08-22 Thread [EMAIL PROTECTED]

Hi all,

Has anybody seen the following exception? It was working till I did an
svn update sometime in the last couple weeks. (I don't often use the
admin so I'm not sure when.) I also tried getting it working with a
clean syncdb but still get the error. I'm using sqlite.

The error mesg is:

Caught an exception while rendering: 'datetime.date' object has no
attribute 'minute'

 "result_list cl" on line 17 is highlighted in original *

7   {% block coltype %}flex{% endblock %}
8   {% block content %}
9   
10  {% if has_add_permission %}
11  {% blocktrans with
cl.opts.verbose_name|escape as name %}Add {{ name }}{% endblocktrans
%}
12  {% endif %}
13  
14  {% block search %}{% search_form cl %}{% endblock %}
15  {% block date_hierarchy %}{% date_hierarchy cl %}{% endblock %}
16  {% block filters %}{% filters cl %}{% endblock %}
17  {% block result_list %}{% result_list cl %}{% endblock %}
18  {% block pagination %}{% pagination cl %}{% endblock %}
19  
20  
21  {% endblock %}
22

The traceback is:

Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in
render_node
  706. result = node.render(context)
File "/usr/lib/python2.4/site-packages/django/template/__init__.py" in
render
  862. dict = func(*args)
File
"/usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_list.py"
in result_list
  182. return {'cl': cl,
File
"/usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_list.py"
in results
  179. yield list(items_for_result(cl,res))
File
"/usr/lib/python2.4/site-packages/django/contrib/admin/templatetags/admin_list.py"
in items_for_result
  140. result_repr = capfirst(dateformat.format(field_val,
datetime_format))
File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py" in
format
  252. return df.format(format_string)
File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py" in
format
  27. pieces.append(str(getattr(self, piece)()))
File "/usr/lib/python2.4/site-packages/django/utils/dateformat.py" in P
  93. if self.data.minute == 0 and self.data.hour == 0:

  AttributeError at /admin/repository/project/
  'datetime.date' object has no attribute 'minute'


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



list_filter across multiple ForeignKeys

2006-08-22 Thread Waylan Limberg

First, here is an example model:

Foo
name

Bar
foo = fk(Foo)

FooBar
bar = fk(Bar)

Given the above (simplified) model, the following works fine:

>>> FooBar.objects.filter(bar__foo__name='blah')

However, if I want to use that for a 'list_filter' in the Admin to
filter FooBars by 'name' I get the following Error:

myproject.foobar: "admin.list_filter" refers to 'bar__foo', which
isn't a field.

For kicks I tried using 'bar.foo' with the same results. I tried
adding '__name' or '.name' to the end (ie.: 'bar__foo_name'), but that
didn't help either.

Can't 'list_filter' filter across mutiple ForeignKeys?

And now I attempt to answer my own question:

It occurs to me that it may be related to the inability to sort such
items in the 'list_display'. For example, in FooBar I also have the
following property defined:

def _get_bar_foo(self):
  return self.bar.foo
name = property(_get_bar_foo)

And in the 'list_display' for FooBar:

list_display = ('name')

Which works great, except that column is not sortable, which is fine
in this case. Even so, I would still like to view only FooBars in
which bar.foo.name = "blah" via 'list_filter'.

-- 

Waylan Limberg
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: how to assign permissions to users and groups?

2006-08-22 Thread Luis P. Mendes

thank you for your help!

Luis P. Mendes

Chris Long escreveu:
> To add permissions.
> For user: user.user_permissions.add(perm)
> (I think, don't have the chance to double check) For group:
> group.permissions.add(perm)
> 
> For your question, the permission table contains the codename, verbose
> name and content type of the object. In most cases, you could probably
> get away without having the contenttype, but it might be a good idea to
> put in there if you the permission is only to be used with that
> specific model. So both are right, just depends on how you want to use
> the permission. Also, probably a good idea to have the codename of the
> form: app_name.code_name, it's the format used for the default
> permissions and might make your life easier to keep it in the same
> format.
> 
> Chris
> 

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Better way to do this?

2006-08-22 Thread Burhan

First, thanks for your opinons.

Tim:

  This was what I did the first way I did it, because it didn't make
sense to me to have a table that is just going be used for a lookup.
However, with that option, I didn't get the option to do a multiple
select on the days. If a flight is only on sunday or monday, I cannot
select it.  However, after chatting a bit with the people in #django,
they told me to do it using the table, as that's the only way to get
the select to work.  I would be happy if there was another way to do a
multiple select.

Russ:

  Yes, I know about the template part, and that's where this is
heading.  However, I purposely put the html in the view.py file because
I am trying to do a rough prototype of for this before I start
templating.  The main idea behind this functionality of the application
is the front end where people can see a table with the flight number,
origin, destination and frequency.  I could not get the frequency to
show up in the admin backend, which is why I improvised this solution
for the view.

I would appreciate if you could tell me a better way to get the m2m
relationship pulled in -- as the rest of the comments regarding the
template are something that I am well aware of.  Also, by better design
-- I didn't mean better design for the database, I meant better design
in the sense a more django-way of getting that information out.

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



Re: slow response when using manage runserver without Internet connection

2006-08-22 Thread Adrian Holovaty

On 8/22/06, DD <[EMAIL PROTECTED]> wrote:
> I am using the Django built-in web server. The server's reponse time is
> nomal when connecting to Internet, once it's offline, the speed is
> extremely slow. Does anyone have experience how to fix it?

Hi DD,

A few days (weeks?) ago, we improved the built-in Django Web server
not to do reverse DNS lookup. If you can, try upgrading to the Django
development version ("trunk") and see if your problem is solved.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.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
-~--~~~~--~~--~--~---



Re: Can't get Django to work Apache + mod_python

2006-08-22 Thread Silas

I figured out what my problem was. It was me being stupid.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Can't get Django to work Apache + mod_python

2006-08-22 Thread Silas

mxDateTime is installed
 - /usr/lib/python2.3/site-packages/mx/DateTime/mxDateTime/

I'm not positive how mxDateTime interacts with Django, but since it
works fine with "./manage.py runserver", that is Django can talk to
PostgreSQL, it seems the problem might having something to do with
mod_python or the Apache settings, permissions, or something.

I'll keep messing with stuff.

[EMAIL PROTECTED] wrote:
> Hi.
>
> Your output has this error message:
>
> "ImproperlyConfigured: Error loading psycopg module: No module named
> DateTime "
>
> Did you install the EGenix "mxDatetime" package? And did you specify
> the correct location when compiling psycopg?
> psycopg seems to require this package.
> See http://www.egenix.com/files/python/mxDateTime.html
>
> See http://brianray.chipy.org/2005/Mar for the following example:
>
> ./configure
> --with-mxdatetime-includes=`pwd`/../egenix-mx-base-2.0.X/mx/DateTime/mxDateTime/
> --with-postgres-includes=`pwd`/../temp/include
> --with-postgres-libraries=`pwd`/../temp/lib
> 
>   Daniel


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Paging admin pages

2006-08-22 Thread Chris Long

This might be of use:

http://www.djangoproject.com/documentation/model_api/#list-per-page

Chris


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: My blog is now Django -- source is available

2006-08-22 Thread nate-django

On Tue, Aug 22, 2006 at 06:20:14AM -0700, Tim Shaffer wrote:
> It looks like some of your views are very simple and could use generic
> views, if you wanted.
> 
> def home(request):
>   return render_to_response('home.html')
> 
> could use django.views.generic.simple.direct_to_template

I was leaving room for making that a more complex view later, but I may
never get to that.

> def entry(request, entry_id):
>   e = get_object_or_404(Entry, pk=entry_id)
>   return render_to_response('blog/entry.html', { 'entry': e })
> 
> could use django.views.generic.list_detail.object_detail

I do.  I probably can remove all of those views.

Nate

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Paging admin pages

2006-08-22 Thread Giovanni Giorgi

Hi all,
 I have searched the mailing archive about paging the admin interface
but without success.
I have done a small blog application, and when I go to
 http://myhost/admin/blog/post/
I see a very huge list of "post" objects.
I have reached 26 posts without paging...I have read it can be done
with little effort.
I need a very basic behavior.
Can you point me to some documentation page?
I'd like to not rewrite the admin inteface!
Thank you.


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



Re: django cannot connect to mysql after upgrade

2006-08-22 Thread garaged

I thinks its a problem on mysql-client package, I haven't made any
testing with other packages, but probably there are others broken too.

Hopefully will be corrected soon :)

Max

-- 
-BEGIN GEEK CODE BLOCK-
Version: 3.12
GS/S d- s: a-29 C++(+++) ULAHI+++ P+ L++>+++ E--- W++ N* o-- K- w
O- M-- V-- PS+ PE Y-- PGP++ t- 5- X+ R tv++ b+ DI+++ D- G++ e++ h+ r+
z**
--END GEEK CODE BLOCK--

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: how to assign permissions to users and groups?

2006-08-22 Thread Chris Long

To add permissions.
For user: user.user_permissions.add(perm)
(I think, don't have the chance to double check) For group:
group.permissions.add(perm)

For your question, the permission table contains the codename, verbose
name and content type of the object. In most cases, you could probably
get away without having the contenttype, but it might be a good idea to
put in there if you the permission is only to be used with that
specific model. So both are right, just depends on how you want to use
the permission. Also, probably a good idea to have the codename of the
form: app_name.code_name, it's the format used for the default
permissions and might make your life easier to keep it in the same
format.

Chris


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: [Fwd: multiple forms]

2006-08-22 Thread sean

That seems to work, 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
-~--~~~~--~~--~--~---



Re: My blog is now Django -- source is available

2006-08-22 Thread Tim Shaffer

It looks like some of your views are very simple and could use generic
views, if you wanted.

def home(request):
return render_to_response('home.html')

could use django.views.generic.simple.direct_to_template

def entry(request, entry_id):
e = get_object_or_404(Entry, pk=entry_id)
return render_to_response('blog/entry.html', { 'entry': e })

could use django.views.generic.list_detail.object_detail


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



My blog is now Django -- source is available

2006-08-22 Thread nate-django

Since so many people are developing their own blogs in Django, I thought
it would be good to announce that the source code to mine is now
available.  Mine is probably of most interest to people migrating from
COREBlog or other Zope blogging software.

Browse: http://refried.org/viewvc/viewvc.py/refriedorg
svn co http://refried.org/svn/refriedorg

My implementation is a very simple, multi-user blog.  The most important
feature to me was a complete migration from COREBlog.  I was able to
import all of my COREBlog entries, with images and comments.

My to do list includes:
 - style the comment form
 - More blog centric admin interface
  - show unapproved comments
  - Make retagging entries easy
  - Ability to preview the entry while editting
 - Photo manager and gallery

Nate

P.S. I also have Jacob's sudoku app ported to magic-removal in 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
-~--~~~~--~~--~--~---



Re: Better way to do this?

2006-08-22 Thread Tim Shaffer

You can use choices for the Frequency model, if you like. It may
simplify things.

DAY_CHOICES = (
('Sa', 'Saturday'),
('Su', 'Sunday'),
('Mo', 'Monday'),
('Tu', 'Tuesday'),
('We', 'Wednesday'),
('Th', 'Thursday'),
('Fr', 'Friday'),
)

class Frequency(models.Model):
days = models.CharField('Frequency', maxlength=2,
choices=DAY_CHOICES)
def __str__(self):
return self.get_days_display()

In your view, I'm not sure why you're putting all the HTML in the view
itself. A better solution would be to use a template and do the output
that way.

from django.shortcuts import render_to_response
from project.app.models import Frequency, Airline, Schedule

def index(request):
flight_list = Schedule.objects.all().order_by('-departs')
return render_to_response('flights.html', {'flight_list':
flight_list})

Then in flights.html you would do:


FlightAirlineFrequency
{% for fl in flight_list %}

{{ fl.flightNumber }}
{{ fl.airline.aname }}

{% for x in fl.freq.all %}
{{ fl.get_days_display }}
{% endfor %}

{% endfor %}

{% endfor %}


This is not tested, so it might not work, but it should put you on the
right track.


Burhan wrote:
> Hello Everyone:
>
>   I am trying my luck with django again, and I found a way to show a
> list of related objects in a many-to-many relationship, using the
> following model and view:
>
> Model
>
> # Flight Frequency
> class Frequency(models.Model):
>
> day_translated = {'Sa': 'Saturday', 'Su': 'Sunday', 'Mo': 'Monday',
> 'Tu': 'Tuesday', 'We': 'Wednesday', 'Th': 'Thursday', 'Fr': 'Friday'}
>
> days = models.CharField('Frequency', maxlength=2)
>
> def __str__(self):
> return self.day_translated[self.days];
>
>
>
> # Flight Schedule
>
> class Schedule(models.Model):
> flightNumber = models.CharField('Flight', maxlength=20)
> from_city = models.ForeignKey(Destination, related_name='From',
> verbose_name='Origin')
> to_city   = models.ForeignKey(Destination, related_name='To',
> verbose_name='Destination')
> airline   = models.ForeignKey(Airline)
> departs   = models.TimeField(help_text='All times are local')
> arrives   = models.TimeField(help_text='All times are local')
> from_date = models.DateField('Valid From', blank=True, null=True)
> till_date = models.DateField('Valid Till', blank=True, null=True)
>
> freq =
> models.ManyToManyField(Frequency,filter_interface=models.HORIZONTAL,
> verbose_name='Occurance')
>
> def __str__(self):
> return 'Flight '+self.flightNumber
>
> class Admin:
> list_display = ('flightNumber','from_city','to_city','airline',
> 'departs', 'arrives')
> list_filter = ['freq','from_city','to_city',
> 'departs','arrives']
> search_fields = ['from_city','to_city','freq']
>
> View:
>
> def index(request):
> flight_list = Schedule.objects.all().order_by('-departs')
> output = ' width="50%">FlightAirlineFrequency'
>
> for fl in flight_list:
> output = output + '' + fl.flightNumber + ''
> output = output + fl.airline.aname + ''
> foo = fl.freq.all().values()
> for x in foo:
> output = output + ' ' + x['days']
> output = output + ''
> output = output + ''
> return HttpResponse(output)
>
>
> Now this does work, but is there a better way to get the same result?
> The way I did it seems a bit of a hack.
> 
> 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
-~--~~~~--~~--~--~---



Re: limit_choices_to Users in a Group

2006-08-22 Thread Waylan Limberg

On 8/21/06, Corey Oordt <[EMAIL PROTECTED]> wrote:
>
> I think you need to include django.core.exceptions
>
> And I think that the exception is ObjectDoesNotExist
>
That did the trick. Thanks.

-- 

Waylan Limberg
[EMAIL PROTECTED]

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Reproduce admin search functionality

2006-08-22 Thread DavidA


Seth Buntin wrote:
> So how will I get the queries if more than one word is used to search?
> The only reason I am using the way I am is in case people search
> multiple words.  Can I run queries and add them together or something?

Seth,

I do a similar thing using the ORM's Q object:
from django.db.models import Q

...

def search(request):

terms = request['search'].lower()
query = Q()
for term in terms.split(' '):
q = Q(instName__icontains=term)| \
Q(instDesc__icontains=term)| \
Q(instClass__icontains=term)| \
Q(note__icontains=term)
query = query & q

trades = RawTrade.objects.filter(query)

return render_to_response('trades/search', {'trades': trades,
'search': terms})

This will generate analogous SQL as your case but you don't have to
deal with all the gory SQL details.

-Dave


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Better way to do this?

2006-08-22 Thread Russell Keith-Magee
On 8/22/06, Burhan <[EMAIL PROTECTED]> wrote:
Now this does work, but is there a better way to get the same result?Erm Yes :-). However, it is a little difficult to establish what facet of your application you want to have critiqued. You have presented a very large model and view, without any particular explanation of what you are trying to achieve, and mail formatting has not been kind to it. Specific questions will gain much more productive answers.
However, here are some general notes:For starters, use the Django template system rather than hand cranking HTML. Follow through the third tutorial for more details; however, as a teaser, your index method should be little more than:
def index(request):    flight_list = Schedule.objects.all().order_by('-departs')    return render_to_response('flights.html', {'flight_list': flight_list})Then, set up a flights.html template that looks something like:
FlightAirlineFrequency{% for fl in flight_list %}   {% for freq in fl.freq.all %}  {{ 
fl.flightNumber }}
  {{ fl.airline.aname }}  {{ freq.days }}   {% endfor %}{% endfor %} There is no real need to use 'values()' - you know which attribute you want. 
My other major critique is one of database design. As currently represented, the 'Frequency' model is a little wasteful. You have an entire table dedicated to representing membership of a set (flight does/does not fly on day X). However, to use this data, you will need to perform a join across two tables (the m2m relations). If you have a lot of flights, this could get quite expensive in terms of database operations.
What would be a better design? Depends on your application. Entire university courses are dedicated to the fine art of database design; I suggest you seek out a good textbook on the subject.Yours,
Russ Magee %-)

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


Re: FileField shows as instead of

2006-08-22 Thread Russell Keith-Magee
On 8/22/06, cyberco <[EMAIL PROTECTED]> wrote:
This seems quite basic, but still, I'm missing something. What could bethe problem?Is this a direct copy and paste, or a retype? The reason I ask is that the behaviour you are reporting has all the symptoms of a mistyped template variable that is silently failing.
{{ form.videoFile }} will render as a input hidden; {{ form.videoFile_file }} should be rendering as the file input. Since the hidden input is being rendered, it suggests that there is something minor wrong with the second template field.
Try putting the following settings in your settings file: TEMPLATE_STRING_IF_INVALID = 'XXX' TEMPLATE_DEBUG=TrueThis will interpret any 'missing' fields as 'XXX', rather than the silent failure that Django usually adopts. If I'm right, you should start getting XXX in your rendered pages right after the hidden field.
Yours,Russ Magee %-)

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


Saving ManyToMany relationships in custom manipulator

2006-08-22 Thread James Mulholland

Hi, I have a routine like this in a custom manipulator (which handles
SMS message-sending from a web-page):

def save(self, data):
temp = Message(
contact_type = data['contact_type'],
mobile_number = data['mobile_number'],
message = data['message'],
date_sent = datetime.datetime.now(),
sender_id = data['sender'],
)
temp.set_teams(data['teams'])
temp.save()

So "teams" is the M2M relationship which I'm attempting to save along
with the message.  I get this error on submission:

'Message' object has no attribute 'set_teams'

Any ideas? TIA.

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



Re: extract keywords from model

2006-08-22 Thread spacedman


[EMAIL PROTECTED] wrote:
> thanks,
>
> that worked
>
> richard

 Ah, now I see my confusion. What you wanted was the 'field names', not
'keywords', and you said: [result_id,lab_id] when you really meant
['result_id','lab_id'].

Barry


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: django cannot connect to mysql after upgrade

2006-08-22 Thread zhongke chen

There is no MySQLdb-python package in my system. There is a package
named python-mysqldb. I reinstalled it and the problem is still the
same.

My system is debian etch, python-mysqldb is 1.2.1, python 2.3 or
2.4(both have the same problem), django 0.95 or svn(both the same).


On 8/22/06, Spike^ekipS <[EMAIL PROTECTED]> wrote:
>
> Hi, chen.
> I got the same problems after updating my system.
> Just re-install MySQLdb-python modules.
>
>
> zhongke chen wrote:
> > After upgrade mysql from 5.0.22 to 5.0.24, django cannot work with
> > mysql. The error messages as following:
> > Traceback (most recent call last):
> >   File "./manage.py", line 11, in ?
> > execute_manager(settings)
> >   File 
> > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
> > line 1343, in execute_manager
> > execute_from_command_line(action_mapping, argv)
> >   File 
> > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
> > line 1260, in execute_from_command_line
> > action_mapping[action]()
> >   File 
> > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
> > line 448, in syncdb
> > cursor = connection.cursor()
> >   File 
> > "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/backends/mysql/base.py",
> > line 90, in cursor
> > self.connection = Database.connect(**kwargs)
> >   File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line
> > 75, in Connect
> > return Connection(*args, **kwargs)
> >   File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line
> > 207, in __init__
> > self.autocommit(False)
> > _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you
> > can't run this command now")
> >
> >
> > --
> > from czk.
> > My old mail boxes([EMAIL PROTECTED], [EMAIL PROTECTED]) have been
> > deprecated. Please contact with me using the following email address
> > from now on: [EMAIL PROTECTED]
> > If you want to attach word/excel/powerpoint files for me, please
> > convert them to pdf. because i have no money to buy ms-office.
>
>
> >
>


-- 
from czk.
My old mail boxes([EMAIL PROTECTED], [EMAIL PROTECTED]) have been
deprecated. Please contact with me using the following email address
from now on: [EMAIL PROTECTED]
If you want to attach word/excel/powerpoint files for me, please
convert them to pdf. because i have no money to buy ms-office.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Foreign key spaghetti

2006-08-22 Thread Sybren Stüvel
On Mon, Aug 21, 2006 at 01:18:03PM -0400, Waylan Limberg wrote:
> In either case, you may want to take a look at the limit_choices_to
> argument of many-to-one fields[1].

Could you give me an example of how to do this? I've tried the
following. The source is in Dutch, but I'd rather copy & paste than
translate, so that I'm sure there are no mistakes in that area.
"Levensverzekering" is "LifeInsurance", "KlantProfielData" is
"CustomerData" and "Hypotheek" is "Mortgage".

class Levensverzekering(models.Model):
class Admin:
pass

klantprofiel = models.ForeignKey(KlantProfielData,
related_name='levensverzekeringen',
edit_inline=models.STACKED, num_extra_on_change=1,
num_in_admin=1)

ing = DateField(core=True, help_text='Ingangsdatum')
eind = DateField(core=True, help_text='Einddatum')
koop = PositiveIntegerField(core=True, help_text='Koopsom')
pre = PositiveIntegerField(core=True, help_text='Premie')
hyp = models.ForeignKey(
Hypotheek,
core=True,
blank=True,
limit_choices_to={'klantprofiel__exact': klantprofiel}
)

But this gives me the following error:

ProgrammingError at /django/admin/profiel/levensverzekering/add/

ERROR: syntax error at or near "<" at character 364 SELECT
"profiel_hypotheek"."id", "profiel_hypotheek"."klantprofiel_id",
"profiel_hypotheek"."aanvang", "profiel_hypotheek"."looptijd",
"profiel_hypotheek"."instelling", "profiel_hypotheek"."vorm",
"profiel_hypotheek"."hoofdsom", "profiel_hypotheek"."hypotheekrente",
"profiel_hypotheek"."rentevast" FROM "profiel_hypotheek" WHERE
("profiel_hypotheek"."klantprofiel_id" =
) ORDER BY
"profiel_hypotheek"."aanvang" ASC, "profiel_hypotheek"."looptijd" ASC

This:

"profiel_hypotheek"."klantprofiel_id" =


of course isn't proper SQL. Another thing I tried was nearly the same
code, except another limit_choces_to clause:

limit_choices_to={'klantprofiel__exact': klantprofiel.id}

Which gives me an error on the development server terminal:

kp.profiel: 'ForeignKey' object has no attribute 'id'

I've also tried this:

limit_choices_to={'klantprofiel_id__exact': klantprofiel}

Which gives me:

Cannot resolve keyword 'klantprofiel_id' into field

I don't know what else to try. Thanks in advance for any help or
suggestions.

Greetings,
-- 
Sybren Stüvel, B.Sc.
Stüvel IT
http://www.stuvel.eu/


signature.asc
Description: Digital signature


Multiple rows in a form

2006-08-22 Thread [EMAIL PROTECTED]

Hi.

I've just started with Django and I'm liking it! A little confused
about one thing though...

I am experimenting with a basic ordering system, the model for which
look like this:

class stock_item(models.Model):
name = models.CharField(maxlength=200)

class order(models.Model):
ordered_by = models.CharField(maxlength=200)

class order_item(models.Model):
order = models.ForeignKey(order)
stock_item = models.ForeignKey(stock_item)
quantity = models.PositiveSmallIntegerField()

This is all fine until I get to a form for placing orders. I envisioned
a form something like this:



{repeat for each stock_item}

{end}

But I'm having some trouble writing the view code for it, does anyone
have any pointers?

Thanks,
Stewart.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Global Variables

2006-08-22 Thread Thomas

Thanks to all of you...I have sorted the problem out...I took a look at
what all of you had to say and worked through the docs again, so a big
hell yeah to you all!


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Better way to do this?

2006-08-22 Thread Burhan

Hello Everyone:

  I am trying my luck with django again, and I found a way to show a
list of related objects in a many-to-many relationship, using the
following model and view:

Model

# Flight Frequency
class Frequency(models.Model):

day_translated = {'Sa': 'Saturday', 'Su': 'Sunday', 'Mo': 'Monday',
'Tu': 'Tuesday', 'We': 'Wednesday', 'Th': 'Thursday', 'Fr': 'Friday'}

days = models.CharField('Frequency', maxlength=2)

def __str__(self):
return self.day_translated[self.days];



# Flight Schedule

class Schedule(models.Model):
flightNumber = models.CharField('Flight', maxlength=20)
from_city = models.ForeignKey(Destination, related_name='From',
verbose_name='Origin')
to_city   = models.ForeignKey(Destination, related_name='To',
verbose_name='Destination')
airline   = models.ForeignKey(Airline)
departs   = models.TimeField(help_text='All times are local')
arrives   = models.TimeField(help_text='All times are local')
from_date = models.DateField('Valid From', blank=True, null=True)
till_date = models.DateField('Valid Till', blank=True, null=True)

freq =
models.ManyToManyField(Frequency,filter_interface=models.HORIZONTAL,
verbose_name='Occurance')

def __str__(self):
return 'Flight '+self.flightNumber

class Admin:
list_display = ('flightNumber','from_city','to_city','airline',
'departs', 'arrives')
list_filter = ['freq','from_city','to_city',
'departs','arrives']
search_fields = ['from_city','to_city','freq']

View:

def index(request):
flight_list = Schedule.objects.all().order_by('-departs')
output = 'FlightAirlineFrequency'

for fl in flight_list:
output = output + '' + fl.flightNumber + ''
output = output + fl.airline.aname + ''
foo = fl.freq.all().values()
for x in foo:
output = output + ' ' + x['days']
output = output + ''
output = output + ''
return HttpResponse(output)


Now this does work, but is there a better way to get the same result?
The way I did it seems a bit of a hack.

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



FileField shows as instead of

2006-08-22 Thread cyberco

With the following model and template:

==MODEL
videoFile = models.FileField (upload_to='videoupload', blank=True)


==TEMPLATE=

Video File:
{{form.videoFile}} {{form.videoFile_file}}




The HTML output renders {{form.videoFile}} {{form.videoFile_file}} as
type="hidden" instead of type="file".

==HTML==
Video File: 



This seems quite basic, but still, I'm missing something. What could 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
-~--~~~~--~~--~--~---



Re: django cannot connect to mysql after upgrade

2006-08-22 Thread Spike^ekipS

Hi, chen.
I got the same problems after updating my system.
Just re-install MySQLdb-python modules.


zhongke chen wrote:
> After upgrade mysql from 5.0.22 to 5.0.24, django cannot work with
> mysql. The error messages as following:
> Traceback (most recent call last):
>   File "./manage.py", line 11, in ?
> execute_manager(settings)
>   File 
> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
> line 1343, in execute_manager
> execute_from_command_line(action_mapping, argv)
>   File 
> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
> line 1260, in execute_from_command_line
> action_mapping[action]()
>   File 
> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/core/management.py",
> line 448, in syncdb
> cursor = connection.cursor()
>   File 
> "/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/db/backends/mysql/base.py",
> line 90, in cursor
> self.connection = Database.connect(**kwargs)
>   File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line
> 75, in Connect
> return Connection(*args, **kwargs)
>   File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line
> 207, in __init__
> self.autocommit(False)
> _mysql_exceptions.ProgrammingError: (2014, "Commands out of sync; you
> can't run this command now")
>
>
> --
> from czk.
> My old mail boxes([EMAIL PROTECTED], [EMAIL PROTECTED]) have been
> deprecated. Please contact with me using the following email address
> from now on: [EMAIL PROTECTED]
> If you want to attach word/excel/powerpoint files for me, please
> convert them to pdf. because i have no money to buy ms-office.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: Can't get Django to work Apache + mod_python

2006-08-22 Thread [EMAIL PROTECTED]

Hi.

Your output has this error message:

"ImproperlyConfigured: Error loading psycopg module: No module named
DateTime "

Did you install the EGenix "mxDatetime" package? And did you specify
the correct location when compiling psycopg?
psycopg seems to require this package.
See http://www.egenix.com/files/python/mxDateTime.html

See http://brianray.chipy.org/2005/Mar for the following example:

./configure
--with-mxdatetime-includes=`pwd`/../egenix-mx-base-2.0.X/mx/DateTime/mxDateTime/
--with-postgres-includes=`pwd`/../temp/include
--with-postgres-libraries=`pwd`/../temp/lib

  Daniel


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: NULL for TextField

2006-08-22 Thread cyberco

Ah! Thanks for the tip. That didn't cross my mind. Learning all the
time, I guess.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google 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
-~--~~~~--~~--~--~---



Re: slow response when using manage runserver without Internet connection

2006-08-22 Thread Russell Keith-Magee
On 8/22/06, DD <[EMAIL PROTECTED]> wrote:

Hi,I am using the Django built-in web server. The server's reponse time isnomal when connecting to Internet, once it's offline, the speed isextremely slow. Does anyone have experience how to fix it?

1) The django-developers list is for discussion of the internal design and development of django; django-users is for end users 'how do I do this/what am I doing wrong' type questions.2) CC'ing to both lists won't improve your chances of getting an answer. 
It just makes people angry :-) Don't worry about being ignored - the developers read both lists.3) Sounds like your problem is a DNS timeout issue. This topic came up on the users list just a few weeks ago. When offline, it takes about 60 seconds for DNS to determine that it can't resolve an address. Search the list archives around late July for a more in depth discussion and possible solutions; however, in short, it isn't a Django-specific problem.
Yours,Russ Magee %-)


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