autofilling select boxes

2009-05-10 Thread newbie

Hi,


  I'm new to django and also ajax. I want to create a form
which has a select box and based on the selection made, the options of
another select box are generated. I've achieved this task in web2py
but i'm porting my application into django and cudnt find a good start
using ajax in django. So it wud be of a great help if some1 cud help
me in this regard.

thanks,
nazgi.

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



Re: How to disable deletion af a model instance

2009-05-10 Thread Praveen

Hi, i do not know how its going to achieve but in my case.
For each payment entry i will add delete button and will disable the
default django admin interface.
Create a separate GroupProfile class
class GroupProfile(models.Model):
name = models.CharField(_('name'), max_length=80, unique=True)
group = models.ManyToManyField(Group, verbose_name=_('group'),
blank=True)
city = models.ForeignKey(city)
user = models.ManyToManyField(User)

class Meta:
verbose_name = _('group')
verbose_name_plural = _('groups')

def __unicode__(self):
return self.name

Create a group for instance do_delete and assign the permission to
delete the entry.
Now create an entry for GroupProfile for instance do_delete_group and
assign the user and do_delete to this group.

in payment view you can write this code

tc = GroupProfile.objects.all().filter(user=use)
gd= {}
for obj in tc:
n = obj.group.all()
for o in n:
 gd[o.name]=o.name
value = gd.values()
render the value to the template and check if the value exist then
show the delete button otherwise do not delete.
Thanks

On May 10, 7:15 am, Margie  wrote:
> I thought that might be the case.  Is that true of the deletes done by
> a formset save as well?  IE, when a formset.save() is done, in some
> cases my delete will be called, and in some cases not?
>
> Margie
>
> On May 9, 4:57 pm, James Bennett  wrote:
>
> > On Sat, May 9, 2009 at 7:49 PM, George Song  wrote:
> > > I think if you want to know definitively if your `delete()` method is
> > > being called or not, your debug statement should go in that method. I
> > > wouldn't be surprised if Django is sending pre and post delete signals
> > > even during bulk deletion.
>
> > It's kind of tricky, really, because there's not any guarantee one way
> > or another -- QuerySet.delete() *may* call delete() methods of
> > individual objects, or it may not. IIRC it mostly comes down to how
> > much of the deletion can be done in a bulk SQL DELETE statement, and
> > how much (due to, e.g., relationships involved) requires fetching the
> > individual objects and deleting them one at a time.
>
> > --
> > "Bureaucrat Conrad, you are technically correct -- the best kind of 
> > correct."
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: django decimal field query issue

2009-05-10 Thread Will Hardy

Firstly, I would very seriously recommend using geodjango for anything
that deals with longitude and latitude. I would also recommend using
IntegerField if your decimal_places is going to be 0.

As for you question, I have no idea why it wouldn't work. There seems
to be a space in your failing Decimal() test, but that wouldn't raise
an ObjectDoesNot exist error.

But using PointField in geodjango would probably avoid these issues anyway.

Cheers,

Will

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



django decimal field query issue

2009-05-10 Thread jai_python

Hie,
  I have a problem in django decimal field query
execution. Here i have explained clearly about my problem.

Model
Class VehicleLocation:
 simno = models.DecimalField(max_digits=10,
decimal_places=0)
 latitude = models.DecimalField(max_digits=25,
decimal_places=16)
 longitude =models.DecimalField(max_digits=25,
decimal_places=16)

Sample data in table:
simnolongitude latitude
  1   4545. 2493386.1000
  2   638936.
2745824.

1.Test.py
--
from decimal import *
def Location(request):
getcontext().prec = 16   # here make decimal precision length as 16
long=Decimal('2745824.')  # here 'long' data type is

VehicleObject=VehicleLocation.objects.get(longitude=long)
print VehicleObject

Ouput:
 I am able to get the vehilcelocation object.
---

2.Error.py
---
from decimal import *
def Location(request):
getcontext().prec = 16   # here make decimal precision length
long=Decimal('2493386.1000 ')  # here 'long' data type is

VehicleObject=VehicleLocation.objects.get(longitude=long)
print VehicleObject

Ouput:
error VehicleLocation matching query does not exist.


Issue:
The issue which i found was when we give any value other than
zero after dot(1.1000), then query always fail. If we give
values  zero after dot(1.) then i am able to  get
output.

How can i overcome this problem?


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



Re: Trouble Starting Up with runserver

2009-05-10 Thread Addy Yeow
What does 'ping localhost' in command-prompt tells you?Did you try 'python
manage.py runserver 127.0.0.1:8000'? Or 'python manage.py runserver :8000'

- Addy

On Mon, May 11, 2009 at 12:40 PM, Chris DPS  wrote:

>
> So I've definitely shut off all Firewalls.
> It still is having the same problem.
>
> HELP!!! PLEASE
>
> On May 10, 6:37 pm, Chris DPS  wrote:
> > How to tell if I have a Firewall running?
> > I have turned off Windows firewall. When I go to the Windows Security
> > Center, the Firewall option is Green, as in 'on'.
> > I looked for normal firewall products on my computer such as Symantec
> > and couldn't find any active ones.
> >
> > How can find which firewall I'm using and shut it off.
> >
> > ---Chris DPS
> >
> > On May 8, 8:10 pm, Addy Yeow  wrote:
> >
> > > Do you have firewall running?It could be blocking incoming local
> connection
> > > to port 8000.
> >
> > > - Addy
> >
> > > On Sat, May 9, 2009 at 7:01 AM, Chris DPS 
> wrote:
> >
> > > > I am new to Django.
> >
> > > > When I try to execute: python manage.py runserver, I get the
> following
> > > > error
> >
> > > > Error: [Errno 10104] getaddrinfo failed
> >
> > > > What is going on and what should I do?
> >
> > > > I am running Django Version 1.0.2-final and Python 2.6
> >
>

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



Re: OneToOneField, and inlines

2009-05-10 Thread nbv4



On May 10, 4:03 pm, Tom von Schwerdtner  wrote:
> Greetings folks, I've been wrestling with this and I really don't know
> what I'm not doing right, so here is where I am:
>
> In basic pseudocode, I have:
>
> models.py:
> ---
> class Address(models.Model):
>     ... ( street, city, etc)
>
> class Contact(models.Model):
>     ...
>     address = models.OneToOneField('Address')
>
> admin.py:
> -
>
> class AddressInline(admin.StackedInline):
>     model = models.Address
>
> class ContactAdmin(admin.ModelAdmin):
>     inlines = [AddressInline,]
>
> 
>
> However, when I try to add a new Contact I get this error:
>
>  has no ForeignKey to  'myapp.models.Contact'>
>
> It seems like this should work, any ideas what I'm doing wrong or what
> the correct way to handle this is?
>
> Thanks,
> Tom

Inlines are for objects that have connected objects which are not
directly related. Your contact model is directly related to address
because it has an "address" field. If the relationship was via a
"contact" field on the address model, then you'd need an inline.

In your example Django assumes the address model has a foreign key
relating to contact and it tries to set that foreign key to the
address pk, but it's not there so it errors.

My suggest for you is to just get rid of the inline all together. It
should automatically create a little widget with a green plus sign for
creating a new address object. If it's a no-popup inline-esque widget
you're after, then there may be another way to do that but I don't
know how.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Trouble Starting Up with runserver

2009-05-10 Thread Chris DPS

So I've definitely shut off all Firewalls.
It still is having the same problem.

HELP!!! PLEASE

On May 10, 6:37 pm, Chris DPS  wrote:
> How to tell if I have a Firewall running?
> I have turned off Windows firewall. When I go to the Windows Security
> Center, the Firewall option is Green, as in 'on'.
> I looked for normal firewall products on my computer such as Symantec
> and couldn't find any active ones.
>
> How can find which firewall I'm using and shut it off.
>
> ---Chris DPS
>
> On May 8, 8:10 pm, Addy Yeow  wrote:
>
> > Do you have firewall running?It could be blocking incoming local connection
> > to port 8000.
>
> > - Addy
>
> > On Sat, May 9, 2009 at 7:01 AM, Chris DPS  wrote:
>
> > > I am new to Django.
>
> > > When I try to execute: python manage.py runserver, I get the following
> > > error
>
> > > Error: [Errno 10104] getaddrinfo failed
>
> > > What is going on and what should I do?
>
> > > I am running Django Version 1.0.2-final and Python 2.6
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Accessing value of a Form.Field in templates

2009-05-10 Thread George Song

On 5/10/2009 5:32 PM, Martin wrote:
> 
> On 11 Mai, 02:07, George Song  wrote:
>> The ticket doesn't appear to be what you're asking for. I think the
>> easiest way is for you to insert an extra context variable in your view,
>> since `GET` and `POST` are verbs associated with a request, not a response.
>>
>> --
>> George
> 
> Thank you for the fast reply. Hm, my intention was to include a large
> JavaScript-file only if my form is not empty.
> I don't really understand why '.value' doesn't work for me.

Well, the ticket is still open so that means the issue is not resolved 
yet. If you want you can apply the patch, in which case you should be 
able to use the `.value` property.

-- 
George

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



Recursive ManyToMany?

2009-05-10 Thread nek4life

I'm trying to create a record label website and I'm modeling the music
data.  I have artists, albums, tracks so far.  What I'd like to do is
use the artists model for both individual recording artists and groups
of recording artists.  I'd like to be able to find any singular artist
or groups of artists by visiting one URL  /artists/artist_slug and be
able to view the related artists if there's a artist.artist_set.  Any
ideas about how I can achieve this using Django?   Keep in mind an
artist could be in more than one band at once, the reason I put
recursive many to many in the title.




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



Re: Django installation

2009-05-10 Thread Margie

At http://www.djangoproject.com/download/, Option 2 is actually the
1.1 Beta (which does not require subversion).  I've been using that
for some time and I find that the additions that have been made to the
admin interface are really very nice.  For example, you can edit
fields in the admin interface with 1.1  beta, but you can't in 1.02.
That is really nice.  I would personally recommend starting with the
1.1 Beta and then move to the final 1.1 release when it comes out
(which I think is coming soon, just based on reading the developer
google group).

Margie



On May 10, 6:48 pm, "veasna.phal"  wrote:
> Dear Django group,
>
> I am the first developer to start with django and my first problem is
> to install it.
>
> As I have read the instruction they need me to download django 1.0.2
> for option 1 and option 2 it required subversion of django. I would
> like to ask the group that can I just take the option 1 and no need to
> take the second option or not? if not please tell me what is option 2
> use for?
>
> Thank you so much,
>
> Best regards,
>
> PHAL Veasna,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Looking for something lighter than Sproutcore or Cappuccino that integrates well with Django

2009-05-10 Thread zweb

Hi,

I am also looking at Qooxdoo. What has been your experience so far?

Will it integrate with Django templates and views?



On Apr 8, 2:19 pm, Raymond Cote 
wrote:
> Rob Madole wrote:
> > The reason I'm posting is to ask the community if they have know of
> > anything that is at a higher level than jQuery + jQuery UI and a lower
> > level than Sproutcore/Cappuccino.  I'd like to find something that has
> > this kind of stuff in it:
>
>  From what I've seen, once you make that leap of higher than
> JQuery/Dojo/Mootools/Prototype/etc. you really do leap into a fully
> client-side environment like Cappuccino or Sproutcore and relegate your
> Django-side to be JSON-RPC or XML-RPC server.
>
> We've recently done the dance through a wide range of tools and ended up
> selectingQooxdoo(qooxdoo.org) for a variety of reasons.
> Also pretty heavy on the UI side, though it has capabilities to be used
> as a component on an otherwise static site.
> (we're drivingqooxdooagainst Twisted, and not Django, but the same
> principle applies).
>
> Of course, if you want a Gmail feel, there's always GWT (or, since this
> is a Python list, Pyjamas --http://code.google.com/p/pyjamas/)
> --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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Wait for file upload to complete?

2009-05-10 Thread tm

Some strange behavior I found while researching this:

If I set the django temp directory FILE_UPLOAD_TEMP_DIR to the same
directory that I want to upload the file to, the file using
'destination.write(chunk) actually gets saved out faster than the temp
file that django is writing to the same directory.

What is going on here?  I am also still unable to figure out my
original issue: why destination.write(...) doesn't wait for the file
to completely write out before it carries on.  Django is awesome but
the file upload is proving to be a little less than intuitive.



On May 10, 6:16 pm, tm  wrote:
> Does anyone know how to wait for a file upload to finish?  I do this
> section of code like the docs:
>
> def handle_uploaded_file(f):
>     ...
>     for chunk in f.chunks():
>         destination.write(chunk)
>      
>      ex_function()
>      
>
> but while a large file is writing out the code continues after this
> call straight to ex_function().  I need to wait until the file is
> completely uploaded until I call that function.  Any help would be
> greatly appreciated.
>
> Thanks, T
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Django installation

2009-05-10 Thread Wayne Koorts

Hi,

> As I have read the instruction they need me to download django 1.0.2
> for option 1 and option 2 it required subversion of django. I would
> like to ask the group that can I just take the option 1 and no need to
> take the second option or not? if not please tell me what is option 2
> use for?

In most cases you should use the 1st one, especially for your first
time.  Option 2 is only if you want the absolute latest testing
version.

Regards,
Wayne

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



Django installation

2009-05-10 Thread veasna.phal

Dear Django group,

I am the first developer to start with django and my first problem is
to install it.

As I have read the instruction they need me to download django 1.0.2
for option 1 and option 2 it required subversion of django. I would
like to ask the group that can I just take the option 1 and no need to
take the second option or not? if not please tell me what is option 2
use for?

Thank you so much,

Best regards,

PHAL Veasna,

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



Re: suggestion on querying external database

2009-05-10 Thread Karen Tracey
On Sun, May 10, 2009 at 8:45 PM, tekion  wrote:

>
> Yes. I saw this link. My impression on first read is that it imports
> the database into Django's database. I am not looking for this. I am
> looking to just be able to read in the data from the external database
> and leave the maintenance of the database to the external
> application.   Has anyone done gone done this path with Django.  If
> not, then I am thinking of writing my own code to generate the report
> and just use Django for displaying the data.  Thoughts?
>
>
I think you may be misunderstanding that page.  inspectdb looks at your
existing database tables and generates Django models that you can use to
access those tables.  If you only want to query those tables, then you can
do that.  You can still use whatever other methods you have in place to
update the existing tables, and your Django code that uses the generated
models will see the updates.  That is, inspectdb does not do any sort of
'import' from one DB to another, it simply provides a start at the Python
code you need to access your existing tables from a Django application.

Now, if you are going to be using Django-included apps like authentication,
admin, and session support, those apps require their own tables and (at
least until multi-DB support is added) those tables will need to be added to
your existing database.  You cannot currently easily segregate tables for
one app into one DB and tables for another app into another DB.

When I started with Django I was looking to add a web front-end to my
existing database.  I already had other tools to update the DB and was not
interested at that point in doing any updates from Django, I just wanted a
web front-end to see the data in ways I could not using my other tools.  I
was also pretty paranoid about letting this new untrusted tool change any of
my existing data, so I set up the database user I specified in settings.py
to not have any privileges that would let Django code make any changes to my
existing tables.  So you can use Django for read-only access to existing
tablesI did it for quite a while, until I decided to migrate my update
tools to a Django/web interface as well.

Karen

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



Re: Trouble Starting Up with runserver

2009-05-10 Thread Chris DPS

How to tell if I have a Firewall running?
I have turned off Windows firewall. When I go to the Windows Security
Center, the Firewall option is Green, as in 'on'.
I looked for normal firewall products on my computer such as Symantec
and couldn't find any active ones.

How can find which firewall I'm using and shut it off.

---Chris DPS

On May 8, 8:10 pm, Addy Yeow  wrote:
> Do you have firewall running?It could be blocking incoming local connection
> to port 8000.
>
> - Addy
>
> On Sat, May 9, 2009 at 7:01 AM, Chris DPS  wrote:
>
> > I am new to Django.
>
> > When I try to execute: python manage.py runserver, I get the following
> > error
>
> > Error: [Errno 10104] getaddrinfo failed
>
> > What is going on and what should I do?
>
> > I am running Django Version 1.0.2-final and Python 2.6
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Error: "Cannot identify image file" PIL + Django

2009-05-10 Thread Jacolyte

On May 10, 6:07 pm, Karen Tracey  wrote:
> 2009/5/10 Jacolyte 
>
>
>
>
>
> > I have a model that has an ImageField, and when I try to work with
> > this model in the admin interface by uploading an image of any type, I
> > usually receive the error "Cannot identify image file" - but there is
> > only one exception to this, which is when I use a picture taken from
> > my digital camera. *nothing* else will go through, I've
> > tried .gifs, .pngs, and .jpgs
>
> > I've transferred my Django project to my production machine, and it
> > works beautifully and accepts all images. They both run the most
> > recent SVN release on Python 2.6 using PIL 1.1.6
>
> > [snip debug details]
> > System information:
> > Django Version: 1.1 beta 1 SVN-10731
> > Python Version: 2.6.2
> > PIL Version: 1.1.6
> > Server: Django dev server
> > OS: Ubuntu 9.04
>
> > I tried installing PIL from the ubuntu repositories and from source,
> > both cases give me the exact same error message.
>
> > Any help on this would be greatly appreciated, thank you!
>
> The message you are getting is slightly different, and I don't understand
> how
I altered the Exception handling in fields.py to just raise whatever
exception came along, rather than throw a validation error. I got the
idea here:
http://jgeewax.wordpress.com/2008/07/28/debugging-django-image-uploading/
> it is a fix you will need to get file uploads working
> properly on the level of Django you are running.
I applied the patch, and it worked wonderfully.

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



Re: suggestion on querying external database

2009-05-10 Thread tekion

Yes. I saw this link. My impression on first read is that it imports
the database into Django's database. I am not looking for this. I am
looking to just be able to read in the data from the external database
and leave the maintenance of the database to the external
application.   Has anyone done gone done this path with Django.  If
not, then I am thinking of writing my own code to generate the report
and just use Django for displaying the data.  Thoughts?

On May 10, 9:13 am, Dougal Matthews  wrote:
> This might be 
> useful;http://docs.djangoproject.com/en/dev/howto/legacy-databases/
> It describes how to create models for your existing databases. However, it
> wont stop you being able to make writes with the django ORM.
>
> Dougal
>
> ---
> Dougal Matthews - @d0ugalhttp://www.dougalmatthews.com/
>
> 2009/5/10 tekion 
>
>
>
> > Hi,
> > I have an application which update MySQL database.  It has
> > aproximately 5 million rows.  I am new to django, I am thinking of
> > using django to generate report using the database as the data source.
> > From what I have seen of the tutorial, you create a model. The
> > database model, would create some sort of schema on the database of
> > your setting (depending on what option you have set up on your
> > setting.py file).  Update,ADD, MOD,Query would go against this
> > schema.  What I am not sure is, what if you don't want to
> > UPDATE,ADD,MOD, just select from the (external) database because
> > another application is responsible for the data in the database? Does
> > any one have ideas on how to best handle this?
>
> > From what I have seen with Django, I would have to write my own code
> > snippet to handle the query for the report in conjunction with Django
> > template system.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: multiple application under a project and handling of tables

2009-05-10 Thread tekion

Cool.  Thanks.  This is what I am looking for.


On May 10, 5:05 pm, Daniel Roseman 
wrote:
> On May 10, 10:02 pm, tekion  wrote:
>
> > Hi,
> > Given a scenarios where you have multiple applications under a
> > project.  You want to manage tables associated with one application
> > only, for example deleting data in tables associated with one
> > application only. Is there a way to manage that via Django?  Thanks.
>
> I think you'll need to give slightly more information about what you
> want to do.
>
> From the command line, manage.py reset  will delete all the
> data in the tables associated with the relevant application - is that
> what you meant?
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Accessing value of a Form.Field in templates

2009-05-10 Thread Martin


On 11 Mai, 02:07, George Song  wrote:
>
> The ticket doesn't appear to be what you're asking for. I think the
> easiest way is for you to insert an extra context variable in your view,
> since `GET` and `POST` are verbs associated with a request, not a response.
>
> --
> George

Thank you for the fast reply. Hm, my intention was to include a large
JavaScript-file only if my form is not empty.
I don't really understand why '.value' doesn't work for me.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Accessing value of a Form.Field in templates

2009-05-10 Thread George Song

On 5/10/2009 4:27 PM, Martin wrote:
> Hi,
> 
> I'm trying to check in a template if the form on this page was sent or
> not (in other words if the page was accessed by POST or GET). Is there
> a build-in way to do something like that down on the template. Or do I
> have to add a extra 'flag' for this in my view?
> Another possible solution for me would be to check if one of the
> 'required' fields of the form has a value.
> I stumbled upon http://code.djangoproject.com/ticket/10427
> So, I checked out the trunk, but MyForm.MyField.value still doesn't
> work. Did I misinterpret the status of the ticket? It's sometimes hard
> for me to understand the history.

The ticket doesn't appear to be what you're asking for. I think the 
easiest way is for you to insert an extra context variable in your view, 
since `GET` and `POST` are verbs associated with a request, not a response.

-- 
George

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



Re: Error: "Cannot identify image file" PIL + Django

2009-05-10 Thread Karen Tracey
2009/5/10 Jacolyte 

>
> I have a model that has an ImageField, and when I try to work with
> this model in the admin interface by uploading an image of any type, I
> usually receive the error "Cannot identify image file" - but there is
> only one exception to this, which is when I use a picture taken from
> my digital camera. *nothing* else will go through, I've
> tried .gifs, .pngs, and .jpgs
>
> I've transferred my Django project to my production machine, and it
> works beautifully and accepts all images. They both run the most
> recent SVN release on Python 2.6 using PIL 1.1.6
>
> [snip debug details]
> System information:
> Django Version: 1.1 beta 1 SVN-10731
> Python Version: 2.6.2
> PIL Version: 1.1.6
> Server: Django dev server
> OS: Ubuntu 9.04
>
> I tried installing PIL from the ubuntu repositories and from source,
> both cases give me the exact same error message.
>
> Any help on this would be greatly appreciated, thank you!


A bug was introduced in a very recent file storage change that affects file
uploads.  You might want to try the patch on this ticket:

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

The message you are getting is slightly different, and I don't understand
how, if you are running r10717 or higher on your production machine as well,
you don't see the problem there (nor why you don't see it with pictures from
your camera), but it is a fix you will need to get file uploads working
properly on the level of Django you are running.

Karen

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



Re: Field value from queryset as extra_context

2009-05-10 Thread George Song

On 5/10/2009 8:03 AM, Jamie Pittock wrote:
> Please excuse the subject if it makes no sense.
> 
> Simplified, I have two models Pub and Town.  Pub has a ForeignKey
> field called 'town'.  I'm using the generic object_list view to
> display all pubs in a particular town (based on a town slug in the
> url).  Something like this...
> 
> def pubs_by_town(request, town_slug):
> town = get_object_or_404(Town, slug=town_slug)
> return list_detail.object_list(
> request,
> queryset=Pub.objects.filter(town__slug=town_slug),
> extra_context={ 'town': town },
> template_name='pubs/pubs_by_town.html')
> 
> Pubs in {{ town.name }}
> 
> {% for pub in object_list %}
> * {{ pub.name }}
> {% endfor %}
> 
> This all works fine but getting the town object to use in the h1 seems
> a bit redundant seeing as every pub instance in object_list will have
> the same name of the town anyway.
> 
> Is it possible to use the queryset to pass the town name as
> extra_context so that a variable is available to use in my template?
> Is there a better way?

What you're doing is perfectly fine. You've already instantiated the 
town object anyway.

-- 
George

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



Error: "Cannot identify image file" PIL + Django

2009-05-10 Thread Jacolyte

I have a model that has an ImageField, and when I try to work with
this model in the admin interface by uploading an image of any type, I
usually receive the error "Cannot identify image file" - but there is
only one exception to this, which is when I use a picture taken from
my digital camera. *nothing* else will go through, I've
tried .gifs, .pngs, and .jpgs

I've transferred my Django project to my production machine, and it
works beautifully and accepts all images. They both run the most
recent SVN release on Python 2.6 using PIL 1.1.6

I received this friendly message when PIL was built:
--- TKINTER support ok
--- JPEG support ok
--- ZLIB (PNG/ZIP) support ok
--- FREETYPE2 support ok

Then the PIL tests:
bla...@blaine-laptop ~/apps/Imaging-1.1.6 $ python selftest.py
57 tests passed.

Seems to work on the python interactive shell:
>>> from PIL import Image
>>> from cStringIO import StringIO
>>> img = Image.open(StringIO("/home/blaine/Pictures/Me/neck-beard.jpg").read())
>>> img



But then I receive the following traceback when trying to upload an
image of any type (.jpg, .png, or .gif):
===
Environment:

Request Method: POST
Request URL: http://localhost:8000/admin/music/album/add/
Django Version: 1.1 beta 1 SVN-10731
Python Version: 2.6.2
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.admin',
 'jacolyte.music',
 'sorl.thumbnail',
 'tagging']
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware')

Traceback:
File "/home/blaine/site-packages/django/core/handlers/base.py" in
get_response
  92. response = callback(request, *callback_args,
**callback_kwargs)
File "/home/blaine/site-packages/django/contrib/admin/options.py" in
wrapper
  226. return self.admin_site.admin_view(view)(*args,
**kwargs)
File "/home/blaine/site-packages/django/contrib/admin/sites.py" in
inner
  184. return view(request, *args, **kwargs)
File "/home/blaine/site-packages/django/db/transaction.py" in
_commit_on_success
  240. res = func(*args, **kw)
File "/home/blaine/site-packages/django/contrib/admin/options.py" in
add_view
  715. if form.is_valid():
File "/home/blaine/site-packages/django/forms/forms.py" in is_valid
  120. return self.is_bound and not bool(self.errors)
File "/home/blaine/site-packages/django/forms/forms.py" in _get_errors
  111. self.full_clean()
File "/home/blaine/site-packages/django/forms/forms.py" in full_clean
  238. value = field.clean(value, initial)
File "/home/blaine/site-packages/django/forms/fields.py" in clean
  511. trial_image = Image.open(file)

Exception Type: IOError at /admin/music/album/add/
Exception Value: cannot identify image file
===


Some context as to where the error occured (line 511):
===
/home/blaine/site-packages/django/forms/fields.py in clean:
 504. file = StringIO(data.read())
 505. else:
 506. file = StringIO(data['content'])
 507.
 508. try:
 509. # load() is the only method that can spot a truncated JPEG,
 510. # but it cannot be called sanely after verify()

 511. trial_image = Image.open(file) ...

 512. trial_image.load()
 513.
 514. # Since we're about to use the file again we have to reset the
 515. # file object if possible.
 516. if hasattr(file, 'reset'):
 517. file.reset()

▼ Local vars
Image   
data
f   
file
initial None
self
===

System information:
Django Version: 1.1 beta 1 SVN-10731
Python Version: 2.6.2
PIL Version: 1.1.6
Server: Django dev server
OS: Ubuntu 9.04

I tried installing PIL from the ubuntu repositories and from source,
both cases give me the exact same error message.

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



inline within an inline -OR- __unicode__ for intermediary models

2009-05-10 Thread nbv4

I have one model that looks like this:

class Position(models.Model):
base = models.ManyToManyField("Base", through="PosBase",
blank=True)
[...]


class PosBase(models.Model):
position = models.ForeignKey("Position")
base = models.ForeignKey("Base")

class Base(models.Model):
name = models.CharField(max_length=32)


Pretty straightforward... Then I have another three-way object, but
it's connected to the PosBase object like so:

class Route(models.Model):
posbase = models.ManyToManyField("PosBase", through="RouteBase",
blank=True)
[...]

class RouteBase(models.Model):
position = models.ForeignKey("Position")
base = models.ForeignKey("Base")

class Base(models.Model):
name = models.CharField(max_length=32


I have an Inline set up so I can add/edit PosBase objects in the
Position admin page. I also have an inline set up to add/edit Route
objects from the PosBase admin page. I would like it so the Route
inline shows up under the Posbase inline on the Position page, but I
think thats asking too much. Is it indeed possible?

If it's impossible, then I would at least like to find out if theres a
way to set up a sane __unicode__ function for PosBase. The only really
important thing that I need displayed is the position name and the
base name. Both of those attributes are connected via a join, which
means I need to run a query, correct? I tried this:

def __unicode__(self):
p = PosBase.object.get(pk=self.pk)
b = p.base.identifier
return u"%s - %s" ("pb", "b")

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



Re: User Authentication Woes

2009-05-10 Thread George Song

On 5/10/2009 5:38 AM, Alfonso wrote:
> Hi,
> 
> App I'm currently working on can be accessed by either authorised
> admin users or authenticated customers (one customer might have a
> number of users on their account).  A non-admin user can login and
> view restricted sections of the site to check stuff like invoices,
> orders etc.
> 
> So as an example a customer, called bob can view his company's
> invoices at /customer/invoices/85  (number being the invoice number
> viewed).  In an attempt to break it I changed the url to /customer/
> invoices/84 and Bob can see invoice 84 but that invoices isn't
> registered to him, its for a different customer entirely.
> 
> Obviously I'm missing some authentication magic to stop that
> happening.  Question is I'm not sure how to go about that - is there a
> straightforward way I can implement more robust user authentication so
> a customer only sees the invoices they are destined to view!?
> 
> Code for invoice list and invoice detail:
> 
> http://dpaste.com/hold/42642/

Authentication as it says, only deals with authentication. Any kind of 
_authorization_ activity within your project is up to you to implement. 
In this case, all you have to do is a simple check to see if the right 
user can see the invoice requested, throw a 403 if not, and allow them 
to pass if they are.

-- 
George

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



Accessing value of a Form.Field in templates

2009-05-10 Thread Martin

Hi,

I'm trying to check in a template if the form on this page was sent or
not (in other words if the page was accessed by POST or GET). Is there
a build-in way to do something like that down on the template. Or do I
have to add a extra 'flag' for this in my view?
Another possible solution for me would be to check if one of the
'required' fields of the form has a value.
I stumbled upon http://code.djangoproject.com/ticket/10427
So, I checked out the trunk, but MyForm.MyField.value still doesn't
work. Did I misinterpret the status of the ticket? It's sometimes hard
for me to understand the history.


Django Revision 10732


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



Wait for file upload to complete?

2009-05-10 Thread tm

Does anyone know how to wait for a file upload to finish?  I do this
section of code like the docs:

def handle_uploaded_file(f):
...
for chunk in f.chunks():
destination.write(chunk)
 
 ex_function()
 

but while a large file is writing out the code continues after this
call straight to ex_function().  I need to wait until the file is
completely uploaded until I call that function.  Any help would be
greatly appreciated.

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



Re: multiple application under a project and handling of tables

2009-05-10 Thread Daniel Roseman

On May 10, 10:02 pm, tekion  wrote:
> Hi,
> Given a scenarios where you have multiple applications under a
> project.  You want to manage tables associated with one application
> only, for example deleting data in tables associated with one
> application only. Is there a way to manage that via Django?  Thanks.

I think you'll need to give slightly more information about what you
want to do.

>From the command line, manage.py reset  will delete all the
data in the tables associated with the relevant application - is that
what you meant?
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Field value from queryset as extra_context

2009-05-10 Thread Daniel Roseman

On May 10, 5:03 pm, Jamie Pittock  wrote:
> Please excuse the subject if it makes no sense.
>
> Simplified, I have two models Pub and Town.  Pub has a ForeignKey
> field called 'town'.  I'm using the generic object_list view to
> display all pubs in a particular town (based on a town slug in the
> url).  Something like this...
>
> def pubs_by_town(request, town_slug):
>     town = get_object_or_404(Town, slug=town_slug)
>     return list_detail.object_list(
>         request,
>         queryset=Pub.objects.filter(town__slug=town_slug),
>         extra_context={ 'town': town },
>         template_name='pubs/pubs_by_town.html')
>
> Pubs in {{ town.name }}
>
> {% for pub in object_list %}
> * {{ pub.name }}
> {% endfor %}
>
> This all works fine but getting the town object to use in the h1 seems
> a bit redundant seeing as every pub instance in object_list will have
> the same name of the town anyway.
>
> Is it possible to use the queryset to pass the town name as
> extra_context so that a variable is available to use in my template?
> Is there a better way?

If you really wanted to avoid the extra query, you could do
{{ object_list.0.town.name }}
but I'm not sure if the lack of clarity is worth it.
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



OneToOneField, and inlines

2009-05-10 Thread Tom von Schwerdtner

Greetings folks, I've been wrestling with this and I really don't know
what I'm not doing right, so here is where I am:

In basic pseudocode, I have:


models.py:
---
class Address(models.Model):
... ( street, city, etc)

class Contact(models.Model):
...
address = models.OneToOneField('Address')


admin.py:
-

class AddressInline(admin.StackedInline):
model = models.Address

class ContactAdmin(admin.ModelAdmin):
inlines = [AddressInline,]




However, when I try to add a new Contact I get this error:

 has no ForeignKey to 

It seems like this should work, any ideas what I'm doing wrong or what
the correct way to handle this is?

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



multiple application under a project and handling of tables

2009-05-10 Thread tekion

Hi,
Given a scenarios where you have multiple applications under a
project.  You want to manage tables associated with one application
only, for example deleting data in tables associated with one
application only. Is there a way to manage that via Django?  Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: "-" in template variables

2009-05-10 Thread Danne

Yeah, that could have been a greate solution :) The problem is that
there is a huge amount of key-value sets to replace, and i don't want
to replace "-" in the blog posts (Tumblr is a blogging service). That
would result in a pretty complex regular expression.

What I did instead to solve this was to make a template filter.
Syntax for using this is {{ post|tumblr_var:"regular-title" }}, and it
will print post["regulat-title"].

The code in the filter is simple:

from django import template

register = template.Library()

def tumblr_var(value, key):
return value[key]

register.filter("tumblr_var", tumblr_var)

Thanks for your comments :)

On May 10, 12:17 pm, Daniel Roseman 
wrote:
> On May 10, 1:58 am, Danne  wrote:
>
> > I'm using the Tumblr (http://www.tumblr.com) REST Api, and keys in
> > returned json contains the character "-", like "post": {"regular-
> > title": "asdf" .}. I'm having trouble printing this in the django
> > templates since regular-title is an invalid variable name. I've tried
> > stuff like: post["regular-title"], post[regular-title], post.regular-
> > title and so on, and searched around the docs and mailing lists, but
> > haven't found any answers.
>
> > Is there a way to print template variables with "-" in their names?
>
> Django templates don't use brackets in dictionary lookups, so
> post.regular-title would be the correct syntax.
>
> How are you getting the data from Tumblr into the template? If the API
> is returning JSON, at some point (before you parse it) it's just a
> string, so you could do x.replace('regular-title', 'regular_title') to
> convert the keys into valid Python variables, if that is indeed the
> cause of your problem.
>
> It would probably help if you posted your view code.
> --
> DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: List users that are currently logged in

2009-05-10 Thread Addy Yeow
:) I was about to ask the exact same question. A quick Google, I found
this

1. 

http://groups.google.com/group/django-users/browse_thread/thread/4ba5652bcbd1f958

and

2. 

http://groups.google.com/group/django-users/browse_thread/thread/6f5f759d3fd4318a/
- I like the idea of using custom middleware that updates last_accessed
attribute in this post.

- Addy

On Mon, May 11, 2009 at 1:37 AM, jd20878  wrote:

>
>
> I am trying to list all users that are currently logged in.  I am having
> trouble getting this right.   I have been playing around with sessions but
> am afraid that I'm running down the wrong path.  Any ideas?
> --
> View this message in context:
> http://www.nabble.com/List-users-that-are-currently-logged-in-tp23472237p23472237.html
> Sent from the django-users mailing list archive at Nabble.com.
>
>
> >
>

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



List users that are currently logged in

2009-05-10 Thread jd20878


I am trying to list all users that are currently logged in.  I am having
trouble getting this right.   I have been playing around with sessions but
am afraid that I'm running down the wrong path.  Any ideas?
-- 
View this message in context: 
http://www.nabble.com/List-users-that-are-currently-logged-in-tp23472237p23472237.html
Sent from the django-users mailing list archive at Nabble.com.


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



Re: Django-storages S3 setup

2009-05-10 Thread Karen Tracey
On Sun, May 10, 2009 at 12:14 PM, Dan Jewett  wrote:

>
> Having trouble getting files in the correct locations apparently.
>
> Here's one example of the setups I've tried:
>
> /Project/
>/backends/
>S3Storage.py
>/App/
>settings.py
>
> /site-packages/
>S3.py
>
> in settings.py: DEFAULT_FILE_STORAGE = 'backends.S3Storage.S3Storage'
>
> >>>from django.conf import settings
> >>> from django.core.files.storage import default_storage
> >>> print default_storage.__class__
> I continue to get:
> 
> instead of:
> 
>
> The only error I'm getting is a deprecated 'sets' warning.
>
> I've also tried running setup.py to install django-storages, but that
> makes the setting choice even more ambiguous (to me.)
>

django.core.files.storage.DefaultStorage is a LazyObject (see
django/utils/functional.py) that wraps the real storage class.  Setting
DEFAULT_FILE_STORAGE isn't going to change it's __class__ attribute.  What
you want to look at is _wrapped, after _setup() has been called on it.  For
example:

In [1]: from django.core.files.storage import default_storage

In [2]: default_storage._wrapped

In [3]: default_storage._setup()

In [4]: default_storage._wrapped
Out[4]: 

Karen

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



Django-storages S3 setup

2009-05-10 Thread Dan Jewett

Having trouble getting files in the correct locations apparently.

Here's one example of the setups I've tried:

/Project/
/backends/
S3Storage.py
/App/
settings.py

/site-packages/
S3.py

in settings.py: DEFAULT_FILE_STORAGE = 'backends.S3Storage.S3Storage'

>>>from django.conf import settings
>>> from django.core.files.storage import default_storage
>>> print default_storage.__class__
I continue to get:

instead of:


The only error I'm getting is a deprecated 'sets' warning.

I've also tried running setup.py to install django-storages, but that
makes the setting choice even more ambiguous (to me.)

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



Re: Category list in Django

2009-05-10 Thread Bro

I use this sample code :

from django.db import models

   import mptt

   class Genre(models.Model):
   name = models.CharField(max_length=50, unique=True)
   parent = models.ForeignKey('self', null=True, blank=True,
related_name='children')

   mptt.register(Genre, order_insertion_by=['name'])

But Django send me this error :

in register dispatcher.connect(pre_save,
signal=model_signals.pre_save, sender=modem)
AttributeError: 'module' object has no attribute 'connect'

On 10 mai, 17:57, Bro  wrote:
> Thanks :)
>
> On 10 mai, 17:15, Antoni Aloy  wrote:
>
> > 2009/5/10 Bro :
>
> > > Thanks, I try to use django-mptt.
> > > I've installed it but how do you use it ?
>
> > You have the documentation at:
>
> >http://django-mptt.googlecode.com/svn/trunk/docs/models.txt
>
> > mptt will give you lots of extra messages to deal with the category tree.
>
> > --
> > Antoni Aloy López
> > Blog:http://trespams.com
> > Site:http://apsl.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Category list in Django

2009-05-10 Thread Bro

Thanks :)

On 10 mai, 17:15, Antoni Aloy  wrote:
> 2009/5/10 Bro :
>
> > Thanks, I try to use django-mptt.
> > I've installed it but how do you use it ?
>
> You have the documentation at:
>
> http://django-mptt.googlecode.com/svn/trunk/docs/models.txt
>
> mptt will give you lots of extra messages to deal with the category tree.
>
> --
> Antoni Aloy López
> Blog:http://trespams.com
> Site:http://apsl.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Category list in Django

2009-05-10 Thread Antoni Aloy

2009/5/10 Bro :
>
> Thanks, I try to use django-mptt.
> I've installed it but how do you use it ?
>
You have the documentation at:

http://django-mptt.googlecode.com/svn/trunk/docs/models.txt

mptt will give you lots of extra messages to deal with the category tree.

-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Field value from queryset as extra_context

2009-05-10 Thread Jamie Pittock

Please excuse the subject if it makes no sense.

Simplified, I have two models Pub and Town.  Pub has a ForeignKey
field called 'town'.  I'm using the generic object_list view to
display all pubs in a particular town (based on a town slug in the
url).  Something like this...

def pubs_by_town(request, town_slug):
town = get_object_or_404(Town, slug=town_slug)
return list_detail.object_list(
request,
queryset=Pub.objects.filter(town__slug=town_slug),
extra_context={ 'town': town },
template_name='pubs/pubs_by_town.html')

Pubs in {{ town.name }}

{% for pub in object_list %}
* {{ pub.name }}
{% endfor %}

This all works fine but getting the town object to use in the h1 seems
a bit redundant seeing as every pub instance in object_list will have
the same name of the town anyway.

Is it possible to use the queryset to pass the town name as
extra_context so that a variable is available to use in my template?
Is there a better way?

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



get next/previous for IntegerField

2009-05-10 Thread Sydney Weidman

I have a model that requires browsing previous and next records by a
user-supplied integer value. What is the best way to handle this type
of requirement? I suppose I could do a query that looked up records
with a value less/greater than the current value with a LIMIT 1 clause
or something like that. But is there something simpler or built-in?

Thanks in advance for your help.

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



Re: Category list in Django

2009-05-10 Thread Bro

Thanks, I try to use django-mptt.
I've installed it but how do you use it ?

On 10 mai, 16:15, Antoni Aloy  wrote:
> 2009/5/10 Bro :
>
> > How to create a correct Tree of category ?
>
> Take a look at django-mptt athttp://code.google.com/p/django-mptt/it
> would help you a lot.
>
> --
> Antoni Aloy López
> Blog:http://trespams.com
> Site:http://apsl.net
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: ModelForm customizing

2009-05-10 Thread Julián C . Pérez

anyone?? any help??
:)

> hi all
> something like this had already been 
> reported:http://code.djangoproject.com/ticket/6138
>
> i tried sean's solutions but nothing happens...
> stand by...
> ;)
>
> On May 8, 7:25 pm, Julián C. Pérez  wrote:
>
> > thank you,s ean
> > i will try
> > ahh one thing i'd like to comment...
> > when creating an ProfileForm object I even give it the class as an
> > argument like this:
> > ...
> > profile, created = Profile.objects.get_or_create(user=request.user)
> > myProfileForm = ProfileForm(request.POST, instance=profile,
> > error_class=DivErrorList)
> > ...
> > but nothing happens... that object still uses the default error class
>
> > another question on my mind...
> > how can i assing to that form a custom class??
> > i mean, to create something like:
> > ...
> > 
> > ...
> > i'd like to achieve that in order to control those fields using jquery
> > -for validation reasons
>
> > thank you all!
>
> > On May 8, 12:13 pm, Sean Brant  wrote:
>
> > > Try this, not tested but it might work.
>
> > > class ProfileForm(forms.ModelForm):
> > >     def __init__(self, *args, **kwargs):
> > >         self.error_class = DivErrorList
> > >         super(ProfileForm, self).__init__(*args, **kwargs)
>
> > >     class Meta:
> > >         model = P
> > >         exclude = ('date', 'user', 'public')
>
> > > When you override a class method you need to make sure to call super
> > > inside it. This calls the classes parent method.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Category list in Django

2009-05-10 Thread Antoni Aloy

2009/5/10 Bro :
>
> How to create a correct Tree of category ?
>
Take a look at django-mptt at http://code.google.com/p/django-mptt/ it
would help you a lot.


-- 
Antoni Aloy López
Blog: http://trespams.com
Site: http://apsl.net

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



Re: Category list in Django

2009-05-10 Thread Bro

How to create a correct Tree of category ?

On 10 mai, 15:51, Bro  wrote:
> I want to create a list of category with subcategory.
> Here is the class :
>
> class Category(models.Model):
>     parent = models.ForeignKey('self', blank=True, null=True)
>     name = models.CharField(max_length=63)
>     child_list = []
>     def __unicode__(self):
>         return self.name
>
> I use this to create a tree :
>
> def show_categories():
>     category_list = list(Category.objects.all())
>     for category in category_list:
>         if category.parent != None:
>             category.parent.child_list.append(category)
>             category_list.remove(category)
>     return {'category_list':category_list}
>
> Do you think it is a good idea ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Category list in Django

2009-05-10 Thread Bro

I want to create a list of category with subcategory.
Here is the class :

class Category(models.Model):
parent = models.ForeignKey('self', blank=True, null=True)
name = models.CharField(max_length=63)
child_list = []
def __unicode__(self):
return self.name

I use this to create a tree :

def show_categories():
category_list = list(Category.objects.all())
for category in category_list:
if category.parent != None:
category.parent.child_list.append(category)
category_list.remove(category)
return {'category_list':category_list}

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



Category list in Django

2009-05-10 Thread Bro

I want to create a list of category with subcategory.
Here is the class :

class Category(models.Model):
parent = models.ForeignKey('self', blank=True, null=True)
name = models.CharField(max_length=63)
child_list = []
def __unicode__(self):
return self.name

I use this to create a tree :

def show_categories():
category_list = list(Category.objects.all())
for category in category_list:
if category.parent != None:
category.parent.child_list.append(category)
category_list.remove(category)
return {'category_list':category_list}

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



Re: suggestion on querying external database

2009-05-10 Thread Dougal Matthews
This might be useful;
http://docs.djangoproject.com/en/dev/howto/legacy-databases/
It describes how to create models for your existing databases. However, it
wont stop you being able to make writes with the django ORM.

Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/5/10 tekion 

>
> Hi,
> I have an application which update MySQL database.  It has
> aproximately 5 million rows.  I am new to django, I am thinking of
> using django to generate report using the database as the data source.
> From what I have seen of the tutorial, you create a model. The
> database model, would create some sort of schema on the database of
> your setting (depending on what option you have set up on your
> setting.py file).  Update,ADD, MOD,Query would go against this
> schema.  What I am not sure is, what if you don't want to
> UPDATE,ADD,MOD, just select from the (external) database because
> another application is responsible for the data in the database? Does
> any one have ideas on how to best handle this?
>
> From what I have seen with Django, I would have to write my own code
> snippet to handle the query for the report in conjunction with Django
> template system.
> >
>

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



suggestion on querying external database

2009-05-10 Thread tekion

Hi,
I have an application which update MySQL database.  It has
aproximately 5 million rows.  I am new to django, I am thinking of
using django to generate report using the database as the data source.
>From what I have seen of the tutorial, you create a model. The
database model, would create some sort of schema on the database of
your setting (depending on what option you have set up on your
setting.py file).  Update,ADD, MOD,Query would go against this
schema.  What I am not sure is, what if you don't want to
UPDATE,ADD,MOD, just select from the (external) database because
another application is responsible for the data in the database? Does
any one have ideas on how to best handle this?

>From what I have seen with Django, I would have to write my own code
snippet to handle the query for the report in conjunction with Django
template system.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Overwrite send_mail

2009-05-10 Thread Dougal Matthews
Thanks Will,
Found it here;
http://code.djangoproject.com/browser/django/trunk/django/test/utils.py#L50

That does look about what I am hoping to do, not so sure about monkey
patching the core though.

Basically, assuming django's send_mail is the standard most apps use, I want
to be able to hook into that and handle all my applications email_sending
how I wish. Be that through using django-mailer or something else.

Possible use cases could be;

   - A Queue email system like django-mailer
   - Adding in my own logging for emails sent
   - Take emails to mean something else, like actually going to SMS


I think the more hooks django gives you into replacing/customising like this
the better. I might go and see how hard it would be to patch...

Cheers,
Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/5/10 Will Hardy 

>
> The test runner does something similar if I remember correctly, have a
> look in django.test.utils and see if you can make something useful out
> of that.
>
> Cheers,
>
> Will
>
> >
>

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



Re: Overwrite send_mail

2009-05-10 Thread Will Hardy

The test runner does something similar if I remember correctly, have a
look in django.test.utils and see if you can make something useful out
of that.

Cheers,

Will

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



User Authentication Woes

2009-05-10 Thread Alfonso

Hi,

App I'm currently working on can be accessed by either authorised
admin users or authenticated customers (one customer might have a
number of users on their account).  A non-admin user can login and
view restricted sections of the site to check stuff like invoices,
orders etc.

So as an example a customer, called bob can view his company's
invoices at /customer/invoices/85  (number being the invoice number
viewed).  In an attempt to break it I changed the url to /customer/
invoices/84 and Bob can see invoice 84 but that invoices isn't
registered to him, its for a different customer entirely.

Obviously I'm missing some authentication magic to stop that
happening.  Question is I'm not sure how to go about that - is there a
straightforward way I can implement more robust user authentication so
a customer only sees the invoices they are destined to view!?

Code for invoice list and invoice detail:

http://dpaste.com/hold/42642/

Thanks


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



Re: Overwrite send_mail

2009-05-10 Thread mark hellewell
Hi,

The django-mailer app I've been using simply defines a send_mail function
with the same signature as the one from django.core.mail.  With the 'mailer'
app in your INSTALLED_APPS you can then just do something like this at the
top of your views.py etc:


# use django-mailer app if it's available
if 'mailer' in settings.INSTALLED_APPS:
from mailer import send_mail
else:
from django.core.mail import send_mail


django-mailer recently moved to GitHub:

http://github.com/jtauber/django-mailer/tree/master

Should be all there is to it!
mark

2009/5/10 Dougal 

>
> Hi,
>
> is there a hook to help me replace the django send_mail function?
>
> I know I can just create my own but I want a nice easy way to handle
> emails my own way for a bunch of apps and it seems almost all re-
> usable apps tend to use send_mail.
>
> I've hunted but can't find anything in the docs
>
> Cheers,
> Dougal
> >
>

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



Re: Model Formsets.save(commit=False) behaviour

2009-05-10 Thread goran

Thanks,

I think that it is saving the object twice because when I put a debug
print statement like print "Object Saved" in the model's save method,
it prints this twice when the code is executed.

However, I did go back to it and did an SVN update on django (to
10731), now it appears to be working properly!

I looked into it and it could have had to do with this ticket:
http://code.djangoproject.com/ticket/10750 which was recently fixed.

Thanks again for your help

Goran




On May 10, 4:58 pm, Margie  wrote:
> I've used that a lot and never had a problem.
>
> I'd recommend stepping through the code.  When you call save, you go
> into the save() function in django/forms/models.py, which immediatey
> takes you into the save_Instance() method.  That code is quite
> straight forward.  At the bottom it just looks at the value of commmit
> and if it is False, it doesn't do the save.  Keep in mind that the
> objects will be updated in memory in this case - just not saved out to
> the db.
>
> What makes you think that you are hitting the db when you do the
> refererals_formset.save(commit=False)?
>
> In any case, I think that commit=False is used a lot, so I'd walk
> through your own code once more ...
>
> Margie
>
> On May 9, 7:17 pm, gorans  wrote:
>
> > Hi all,
>
> > I'm trying to use the .save(commit=False) method on a model formset in
> > my view but for some strange reason, the django code executes the
> > model's save method.
>
> > My understanding of the docs is that when (commit=False) is passed -
> > the formset will return a list of model instances but not commit them
> > to the db.  However, when the formset's .save(commit=False) is called,
> > I note that the model instances are saved. Documentation: [http://
> > docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-
> > formsets]
>
> > I tried to trace through the django forms code to find out where this
> > happens but could not.
>
> > The code in my view is available here:http://dpaste.com/42538/
>
> > I note that there is a line where the model gets explicitly saved so
> > when I actually run that code the model gets saved twice - which I
> > don't want to happen.
>
> > Any help is much appreciated.
>
> > Cheers
>
> > Goran
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 'base' template

2009-05-10 Thread Daniel Roseman

On May 10, 1:14 am, lisa holper  wrote:
> No, sorry there is a misunderstanding. I did not use Apache, but just copied
> the html files in my directory of my homepage. So, this does not work? Do I
> need to use Apache?
> thanks again, Lisa
>

Again, you need to read the deployment documentation, a link to which
was posted above:
http://docs.djangoproject.com/en/dev/howto/deployment/
--
DR.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: How to solve value error

2009-05-10 Thread Daniel Roseman

On May 10, 4:17 am, Nalini  wrote:
> Hi,
>
> I am getting this value error in my report. i am using pagination fro
> my report. I have only 2 records in my database. so in order to check
> whether my pagination works i gave
> { % autopaginate Data 1 % } so that each record will get displayed in
> two different pages. when i generate my report the record in the 1st
> page is getting generated but when i click on the 2nd page link it
> displays me this error. can any one help me what might be the reason
> and solution for this.
>
> Error Message
> ===
> ValueError at /ReportIMH/
>
> The view Lab_Tools.ims.views.ReportIMH didn't return an HttpResponse
> object.
> Request Method:
> GET
> Request URL:http://127.0.0.1:8000/ReportIMH/
> Exception Type:
> ValueError


> Views.py
> ===
>
> def IRSerNum(request,Part_No):
>    ReportData=""
>    ReportHeader = HTML.Table()
>    ReportData = HTML.Table()
>    ReportHeader.rows.append(['Serial Number','Status of the
> Instrument'])
>    Sernos = Part.objects.filter(part_number=Part_No)
>    for field in Sernos:
>       SerNoList= "%s" % field.serial_number
>       testhistorystatus = TestHistory.objects.filter(SerNo = field)
>       for state in testhistorystatus:
>         teststat = "%s" % state.test_status
>       ReportData.rows.append([SerNoList,teststat])
>    DateTime=current_datetime()
>    return render_to_response('Reports/IR/SerNo.html', {'SNos':
> ReportData , 'Part' : Part_No, 'Header' : ReportHeader.rows , 'Data' :
> ReportData.rows,'Time' : DateTime},context_instance=RequestContext
> (request))
>
> SerNo.html
> ==
>
> {% extends 'Main_Template.html' %}
> {% load pagination_tags %}
> {% block menu %}
> {% endblock %}
> {% block content %}
>
> 
>
> 
> 
> Serial Numbers for the Part Number {{Part}} 
>   {{Time}}
> {% autopaginate Data 1%}
>
>   
>    {% for row in Header %}
>   
>                 {% for value in row %}
>                         {{ value }}
>                 {% endfor %}
>   
>    {% endfor %}
>
>   {% for row in Data %}
>   
>
>         {% for value in row %}
>         {{ value }}
>         {% endfor %}
>    
>   {% endfor %}
>
>   
>   
>  {% paginate %}
>
>    
>
> {% endblock %}

Where is the autopaginate tag coming from? As the error message
states, the view that is throwing the error is called ReportIMH, not
IRSerNum. Presumably the pagination links are taking you to a
different view, which is throwing a ValueError for some reason. Maybe
you should look at that view - or, if you're not supposed to be going
to that view, work out why autopaginate is taking you there.

--
DR.


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



Re: "-" in template variables

2009-05-10 Thread Daniel Roseman

On May 10, 1:58 am, Danne  wrote:
> I'm using the Tumblr (http://www.tumblr.com) REST Api, and keys in
> returned json contains the character "-", like "post": {"regular-
> title": "asdf" .}. I'm having trouble printing this in the django
> templates since regular-title is an invalid variable name. I've tried
> stuff like: post["regular-title"], post[regular-title], post.regular-
> title and so on, and searched around the docs and mailing lists, but
> haven't found any answers.
>
> Is there a way to print template variables with "-" in their names?

Django templates don't use brackets in dictionary lookups, so
post.regular-title would be the correct syntax.

How are you getting the data from Tumblr into the template? If the API
is returning JSON, at some point (before you parse it) it's just a
string, so you could do x.replace('regular-title', 'regular_title') to
convert the keys into valid Python variables, if that is indeed the
cause of your problem.

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



Re: "-" in template variables

2009-05-10 Thread Dougal Matthews
>From the docs;
"Variable names must consist of any letter (A-Z), any digit (0-9), an
underscore or a dot."

http://docs.djangoproject.com/en/dev/ref/templates/api/#rendering-a-context

I suppose you could write a template tag to handle it or something. Not
sure.

Dougal


---
Dougal Matthews - @d0ugal
http://www.dougalmatthews.com/



2009/5/10 Danne 

>
> I'm using the Tumblr (http://www.tumblr.com) REST Api, and keys in
> returned json contains the character "-", like "post": {"regular-
> title": "asdf" .}. I'm having trouble printing this in the django
> templates since regular-title is an invalid variable name. I've tried
> stuff like: post["regular-title"], post[regular-title], post.regular-
> title and so on, and searched around the docs and mailing lists, but
> haven't found any answers.
>
> Is there a way to print template variables with "-" in their names?
>
> >
>

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



Re: simpletag to accumulate media without duplicates

2009-05-10 Thread Margie

Yes, I bet you are right.  I think I have to use a "non simple" tag,
the kind where I write the parser and renderer.  I think I did that a
while back, will go off and search my old code.

Thanks for the pointer.

Margie

On May 9, 9:39 pm, Dan Mallinger  wrote:
> Hi Margie,
>
> I'm not sure off the top of my head, but if memory serves me right,
> template tags may not allow variable number of parameters.  I'd take a
> look at the code from the {% url %} template tag, it's syntax allows
> for multiple variables, but they're passed in a very particular way.
> It's actually some very straightfoward but powerful code in the core
> and a great place to start getting to konw djano a little better.
> I've done some similar stuff to create template view requests (a more
> rails way of thinking about things) as well as a tag for partial urls.
>
> Cheers
> Dan
>
> On Sun, May 10, 2009 at 12:28 AM, Margie  wrote:
>
> > I want to write a templatetag that goes through a bunch of media and
> > returns the media lines without duplicates, something like this
> > (except I'm not removing duplicates here, not sure if the '+' is going
> > do it for me or not).
>
> > def form_media(*args):
> >    finalFormMedia = Media()
> >    for formMedia in args:
> >        finalFormMedia += formMedia
> >    return finalFormMedia
> > register.simple_tag(form_media)
>
> > When I try to use this tag with something like this
>
> > {% form_media taskForm.media assignmentFormSet.media %}
>
> > I get the error
>
> > Exception Type:         TemplateSyntaxError
> > Exception Value:
> > form_media takes 0 arguments
>
> > Anyone know how I do a tag with variable number of arguments?
>
> > Margie
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Model Formsets.save(commit=False) behaviour

2009-05-10 Thread Margie

I've used that a lot and never had a problem.

I'd recommend stepping through the code.  When you call save, you go
into the save() function in django/forms/models.py, which immediatey
takes you into the save_Instance() method.  That code is quite
straight forward.  At the bottom it just looks at the value of commmit
and if it is False, it doesn't do the save.  Keep in mind that the
objects will be updated in memory in this case - just not saved out to
the db.

What makes you think that you are hitting the db when you do the
refererals_formset.save(commit=False)?

In any case, I think that commit=False is used a lot, so I'd walk
through your own code once more ...

Margie

On May 9, 7:17 pm, gorans  wrote:
> Hi all,
>
> I'm trying to use the .save(commit=False) method on a model formset in
> my view but for some strange reason, the django code executes the
> model's save method.
>
> My understanding of the docs is that when (commit=False) is passed -
> the formset will return a list of model instances but not commit them
> to the db.  However, when the formset's .save(commit=False) is called,
> I note that the model instances are saved. Documentation: [http://
> docs.djangoproject.com/en/dev/topics/forms/modelforms/#inline-
> formsets]
>
> I tried to trace through the django forms code to find out where this
> happens but could not.
>
> The code in my view is available here:http://dpaste.com/42538/
>
> I note that there is a line where the model gets explicitly saved so
> when I actually run that code the model gets saved twice - which I
> don't want to happen.
>
> Any help is much appreciated.
>
> Cheers
>
> Goran
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---