using frames in django

436 views
Skip to first unread message

Gboro54

unread,
May 4, 2008, 11:26:36 PM5/4/08
to Django users
Hi everyone...I want to use frames in a web app i am building..I have
a display.html that has the frames sets and takes 2 other html
files...the one problem is the other 2 pages have variables binded to
them...I am not sure how to get this to work...any advice would be
apprciated...Thanks(code provided below for the html)

sidbar.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
</head>
<img height="100" alt="The Bass Log Online" src="{{location}}"
width="100" align="left">
</body>
</html>

main.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
</head>
<body>
<div align="center">

<h1>
<img src="{{location}}" alt="The Bass Log Online" width="100"
height="100" align="left"/>
<img src="{{ad}}" alt="The Bass Log Online" width="400" height="75"
align="top"/>
</h1>
<h1>Welcome to Bass Log Online</h1>
</div>
</body>
</html>



display.html

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>



<frameset cols="20%,80%">

<frame src={{side}}>
<frame src={{main}}>


</frameset>

</html>

LaundroMat

unread,
May 5, 2008, 7:10:48 AM5/5/08
to Django users
Just use urls in your display.html file, and let urlconf.py translate
those to views. Within those views, you can render your template &
pass along your variables.

Ben Eliott

unread,
May 5, 2008, 8:03:37 AM5/5/08
to django...@googlegroups.com
Hi, I'm getting started in the (highly enjoyable!) admin models -
FileField upload works when I give upload_to the full absolute filepath.
However, as soon as I try and use MEDIA_ROOT in settings.py it baulks.
Permissions are wide open, I've tried every combination of slashes &
paths -- but it only likes it when upload_to gets given the absolute
path. Any suggestions or even hints of ideas will be most welcome - it's
bound to be some small, simple thing! Thank you.
Ben

Kenneth Gonsalves

unread,
May 5, 2008, 8:39:25 AM5/5/08
to django...@googlegroups.com

On 05-May-08, at 5:33 PM, Ben Eliott wrote:

> Hi, I'm getting started in the (highly enjoyable!) admin models -
> FileField upload works when I give upload_to the full absolute
> filepath.
> However, as soon as I try and use MEDIA_ROOT in settings.py it baulks.

what do you mean by 'baulks' - what is the error message?

--

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

Ben Eliott

unread,
May 5, 2008, 9:16:58 AM5/5/08
to django...@googlegroups.com
Hi kg,
Thanks for for your swift attention.
It reloads the same form with the message at the top: 'Please correct
the error below.' (although it doesn't actually show any error below).

Best,
Ben

--

--
No virus found in this incoming message.
Checked by AVG.
Version: 7.5.524 / Virus Database: 269.23.8/1415 - Release Date:
05/05/2008 06:01

Kenneth Gonsalves

unread,
May 5, 2008, 9:29:13 AM5/5/08
to django...@googlegroups.com

On 05-May-08, at 6:46 PM, Ben Eliott wrote:

> Thanks for for your swift attention.
> It reloads the same form with the message at the top: 'Please correct
> the error below.' (although it doesn't actually show any error below).

please paste your model here

Ben Eliott

unread,
May 5, 2008, 9:52:55 AM5/5/08
to django...@googlegroups.com
Hi kg,

Class HIP has a 1-to-many with Property (many HIPs / 1 Property) . The
offending field is HIP.hip

#CODE
class Property(models.Model):
"""Model of a property"""


reference = models.CharField(max_length=20)
Archive = models.BooleanField()
SSTC = models.BooleanField()
price_prefix =
models.IntegerField(max_length=1,choices=PRICE_PREFIX,default=2) #temp
price = models.DecimalField(max_digits=10,decimal_places=2)
address_1 = models.CharField(max_length=50)
address_2 = models.CharField(max_length=50)
address_3 = models.CharField(max_length=50,blank=True)
address_4 = models.CharField(max_length=50,blank=True)
postcode = models.CharField(max_length=10)
property_type =
models.CharField(max_length=30,choices=TYPES,default='House')
bedrooms = models.IntegerField()
reception_rooms = models.IntegerField(null=True,blank=True)
summary = models.CharField(max_length=200)
description = models.TextField(blank=True)
lease_years = models.IntegerField(null=True,blank=True)
ground_rent =
models.DecimalField(null=True,max_digits=10,decimal_places=2,blank=True)
service_charge =
models.DecimalField(null=True,max_digits=10,decimal_places=2,blank=True)
created_at = models.DateTimeField(auto_now_add=True)
modified_at = models.DateTimeField(auto_now=True)

class HIP(models.Model):
hip = models.FileField(upload_to='/tmp',core=True)
property =
models.ForeignKey(Property,edit_inline=models.TABULAR,num_in_admin=10,ma
x_num_in_admin=10,min_num_in_admin=10)

#END

If I change the upload_to to ='/full/path/to/tmp', (so long as
MEDIA_ROOT = '') it works fine!
As soon as I switch to MEDIA_ROOT = '/full/path/to/' and upload_to =
'/tmp' (all slash permutation tried!) it's 'Please correct the error
below'.....

Maybe this will be of help: the MEDIA_URL is: 'http://example.com/tmp/
(there is a further tmp subdir within that) and when the files save
correctly the admin form shows the link as the absolute path that was
written in upload_to clicking to http//example.com +appended with the
same absolute path 'http://www.example.com/absolute/path/to/file.txt'.


-----Original Message-----
From: django...@googlegroups.com
[mailto:django...@googlegroups.com] On Behalf Of Kenneth Gonsalves
Sent: 05 May 2008 14:29
To: django...@googlegroups.com
Subject: Re: Filefield upload_tol

--

--

Kenneth Gonsalves

unread,
May 5, 2008, 10:13:44 AM5/5/08
to django...@googlegroups.com

On 05-May-08, at 7:22 PM, Ben Eliott wrote:

> hip = models.FileField(upload_to='/tmp',core=True)

try upload_to='tmp' <----------- no '/'

Mike H

unread,
May 5, 2008, 10:20:39 AM5/5/08
to django...@googlegroups.com

I can replicate this by putting in a file path that does not exist in
the HIP form. The validation fails for the file field but the error is
not rendered.

edit_inline is known to be buggy - some validation faliures on models
that are being edited inline aren't rendered, but the user is told
there is an error. I think there are a number of tickets logged, but
the official word is to wait until newforms-admin is complete. (I
think, anyone know better?)

Cheers,

Mike

Ben Eliott

unread,
May 5, 2008, 10:24:51 AM5/5/08
to django...@googlegroups.com
Hi Kg,
You're beautiful, you know that don't you? It worked a treat. And just
in time moments before the Chelsea game starts too.
When I said all slash permutations tried, I did of course mean, all but
that one....
Thanks a million.
Ben


-----Original Message-----
From: django...@googlegroups.com
[mailto:django...@googlegroups.com] On Behalf Of Kenneth Gonsalves
Sent: 05 May 2008 15:14
To: django...@googlegroups.com
Subject: Re: Filefield upload_tol

--

--

Gboro54

unread,
May 5, 2008, 10:28:30 AM5/5/08
to Django users
That is what I figured on doing...I was just seeing if there was an
easier way of doing it...

Thanks
> pass along your variables.- Hide quoted text -
>
> - Show quoted text -

Ben Eliott

unread,
May 5, 2008, 10:33:14 AM5/5/08
to django...@googlegroups.com
Hi Mike,

Thanks for your attention on this.
Kg solved this a few moments back. As suspected, a bit of basic muppetry
on my part.

Solution was only to change:
Upload_to = '/tmp'
TO:
Upload_to = 'tmp'

Nice.

Reply all
Reply to author
Forward
0 new messages