Re: ORM and case study

2006-12-07 Thread Kenneth Gonsalves


On 08-Dec-06, at 6:43 AM, coulix wrote:

> If create tables without django model classes i guess i wont be  
> able to
> use ORM on it right ?

create the tables with django model classes - only populating the  
tables will be done directly and not through django
-- 

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



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



ORM and case study

2006-12-07 Thread coulix

Hello guys, i got an intern ship job in a trading company for summer.
They have several servers, and plenty of logs with transactions id and
states.
My job is to parse all these stuffs get the timings of the states and
build an interface to search look at specific transaction.

The log are huge from 1 to 200 Mb a day !, i wont get all the data from
it but still. Maybe i will have to average the results after a week.

Anyway, i prosposed this solution
- crontab jobs in python to parse the log and insert the results in the
DB (every day at 12)
- some other script working on the DB to calculate some statistics.
- A django project to handle the presentation of this data.

If create tables without django model classes i guess i wont be able to
use ORM on it right ?


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



Re: Optimizing Templates

2006-12-07 Thread John Lenton

On 12/7/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Well it's none of that. The template process time is literally
> 150-500ms using the profiling stuff...

me myself, I'd split that huge template into a hierarchy, and profile
each chunk separately. That might give you a better clue as to what is
wrong...

-- 
John Lenton ([EMAIL PROTECTED]) -- Random fortune:
The trouble with a lot of self-made men is that they worship their creator.

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



Re: HTTP PUT and DELETE with Django?

2006-12-07 Thread yi huang
>
> Is it possible to process HTTP PUT and DELETE requests with Django?  If
> so, how would I access the data uploaded in an HTTP PUT?
>
> (I would like to build a RESTful interface to some Django models.  I
> guess I can use POST to upload if I have to, but would like to try
> using PUT if possible.)


I've written a django collection
( like wsgicollection
), which build a generic RESTful
interface to django modals and use a middleware to parse PUT data .
I've tested it under both development server and mod_python.
Hope it to be useful ;-)

-- 
http://codeplayer.blogspot.com/


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


Re: test client - Keeps returning 301 status code and not sure why.

2006-12-07 Thread Russell Keith-Magee

On 12/7/06, MerMer <[EMAIL PROTECTED]> wrote:

Ok... First off - Russell wakes up and realizes the mistake he made.
Note to self - don't answer email with an unhappy 7 month old in your
lap. :-)

I'm not sure which dark corner of my brain 'c.response' came from, but
it was a bad suggestion - that attribute doesn't exist. I think I was
aiming for 'c.content', but that wouldn't be correct, either
(although, it would be interesting to see the value of 'c.content'.
Try:

c = Client()
response=c.get('/promotions/',)
print response['Location']

This should give you the location you are being redirected to.

> set this up via the URL conf and then tried again.  Same results as
> before.

Ok - you've given me little bits, and a vague set of instructions of
what you might have done, but not enough to replicate your problem.
Keep in mind that I don't have the problem you have, so you need to
help me help you. Giving me little bits of snippets of code, and
helpful hints like "I think I had failed to import everything" doesn't
help me replicate your problem.

What I need is a _complete project_ that exhibits the problem - that
means a model, view, URLpattern, settings, and complete execution
instructions.

Don't just send me your entire multi-view, multi-model application,
either. Send me a test case - the smallest project you can build that
exhibits the problem you are observing. I don't want to spelunk
through thousands of lines of code to try and work out which two lines
from your project are causing the problem. Again - help me help you.

Also, speaking from experience - the process of building this minimal
subset project quite often reveals that the actual problem is some
silly typo that you didn't spot, so it can be a valuable debugging
tool.

Yours,
Russ Magee %-)

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



Re: TIME_ZONE? LocalTimezone? Help!!!

2006-12-07 Thread Todd O'Bryan

Whoops!!!

I figured out what I was doing wrong.

In settings.py, I had

TIME_ZONE = 'America/New York'

Notice the space (which should be an underscore) in the middle of New
York. Terribly confused, my system just decided to leave me in UTC for
my own good. Pretty darned confusing, let me tell you.

By the way, the link to acceptable time zone names from the settings
documentation

http://www.djangoproject.com/documentation/settings/#time-zone

no longer exists.

We now return you to the non-confused portion of our programming.

Thanks,
Todd




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



Re: filter by related record

2006-12-07 Thread Russell Keith-Magee

On 12/8/06, Rory Campbell-Lange <[EMAIL PROTECTED]> wrote:
>
> I'm not sure how to do a join against a related record:

What you are looking for is:

g = SiteEnergy.objects.filter(siteyear=9, typer__isoffsite=False)

To explain why, lets look at your errors:

> g=SiteEnergy.objects.filter(siteyear=9, energy__isofsite=False)
> raise TypeError, "Cannot resolve keyword '%s' into field" % name
> TypeError: Cannot resolve keyword 'energy' into field

Your SiteEnergy model doesn't have an 'energy' field. The relation
with the Energy model is kept in a relation called "typer". Therefore,
you need to use typer__isoffsite to reference the property on the
related model.

Related note: if you were to query the Energy object, you _would_ use
the model name in your query:

Energy.objects.filter(siteenergy__source='foo')

In this case, Energy has an implied reverse relation on siteenergy,
which assumes the name of the related model by default. You can
override this default name using a 'related_name' kwarg. Check the
model API docs for more details.

> g=SiteEnergy.objects.filter(siteyear=9, typer.isoffsite=False)
> SyntaxError: keyword can't be an expression

Similarly - double underscore notation here, not dot notation. Keep in
mind that Django has found a creative use for Python kwarg syntax - we
haven't added any syntax to the Python interpreter. In this case, each
query argument is a named argument to a function - and function
arguments can't have dots in them (this would be an expression, not an
argument - hence the error message). The 'double underscore' is the
Django way of faking the '.' to provide relation traversal.

Hope this helps,

Yours,
Russ Magee %-)

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



Auto generate url patterns

2006-12-07 Thread leanmeandonothingmachine

Noob question: I've just started getting into django, and wanted to get
opinions on auto generating url patterns from a db. Is that bad
practice, will it slow down the site?

I'm thinking of doing this for a few reasons:

1) The client is very particular about the path. So I want to use one
app to serve a lot of differnet urls that all basically do the same
thing, but not have to specify each one in url.py files

2) While most pages would simply show some text from a table (basically
be static). Some of the pages in the tree would need more customization
(dynamic lists and so forth), and its my understanding that I can't do
that with flatpages, whereas with my own table a simple bool will tell
me which are which.

3) I need multiple languages support in the db. As far as I know,
flatpages doesn't do that. I can't just use the trans tag because the
translators need to be able to work through a db interface.

I am going about this the right way? or are there reasons why this
would be a bad idea? If there are any other suggestions of how to do
want I need better that would ge great too.

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



Re: Singleton model instance

2006-12-07 Thread spacedman

My slightly graceless method is to override .save and .delete:

http://groups.google.com/group/django-developers/browse_frm/thread/2caa976249783fae/#

Then whatever model you define, it can only ever have one row (well, it
will have zero rows before you put anything it).

Barry


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



Re: TIME_ZONE? LocalTimezone? Help!!!

2006-12-07 Thread Todd O'Bryan

On Thu, 2006-12-07 at 16:06 -0600, Jacob Kaplan-Moss wrote:
> On 12/7/06 3:41 PM, Todd O'Bryan wrote:
> > OK. I've read the Python docs on tzinfo objects and I think I could make
> > a tzinfo object, but it seems like there should be a way to get one out
> > of the Django innards.
> > 
> > I assume one can use the django.utils.tzinfo.LocalTimezone class to
> > create a tzinfo object, but what the heck do you pass to the constructor
> > so it knows what to do?
> 
> For some reason, dates/times and especially timezones absolutely suck eggs in 
> Python.  The best way I've found to sanely deal with 'em is the dateutil 
> package: http://labix.org/python-dateutil.
> 
> FWIW, though, here's a quick example that shows how you might use Django's 
> tzinfo module::
> 
>   >>> import datetime
>   >>> from django.utils import tzinfo
>   >>> utc = tzinfo.FixedOffset(0)
>   >>> utcnow = datetime.datetime.now(utc)
>   >>> utcnow
>   datetime.datetime(2006, 12, 7, 22, 3, 3, 481319, tzinfo=+)
> 
> You're not alone in being frustrated by datetimes in Python; I'd venture to 
> say that they're the suckiest part of being a Python programmer.
> 
> Jacob

I'm apparently worse off than I thought. I just tried the {% now %} tag,
and it gave me UTC. But SELECT NOW(); in MySQL returns local time (US
Eastern Standard Time) and my system clock as indicated by the "date"
command in a terminal also shows EST.

I checked the code for the now tag and it just uses datetime.now() with
no attempt to check the local time zone.

Is this the correct behavior or should {% now %} do something else? If
it is correct behavior, what the heck do I have TIME_ZONE = 'America/New
York' for in the settings.py file?

Todd


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



Re: displaying thumbnails in admin

2006-12-07 Thread [EMAIL PROTECTED]

true, worst idea becouse i need sometimes only quick view what's going
on.
If i need real thumbnail, i can do something like this:
   def picture(self):
  if no file called self.filename_admin_thumb:
 create_the_thumb()

  return ''

   picture.allow_tags = True

   class Admin:
list_display = ('filename', 'picture')

#you know what i mean, thats only the 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Validation Summary

2006-12-07 Thread Brian Morton

I can't figure out how to make a validation summary on a form.  I have 
examined the code in forms\__init__.py, and it reveals nothing about 
where the complete list of field/error pairs are stored.  I would like 
to do a for loop on that dictionary and output a validation summary, 
then mark each field with a simple * (which I already know how to do).

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



Re: displaying thumbnails in admin

2006-12-07 Thread nymbyl

I'm thinking he said it was the worst idea because it just uses the img
tag width and height to shrink the image - but the admin view would
still have to load the images at actual size.

For actual thumbnails, where the image that is loaded is actually
smaller here are some ideas:

http://groups.google.com/group/django-users/browse_frm/thread/bb7f406bffd697f5
http://trac.studioquattro.biz/djangoutils/wiki/Thumbnail


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



TIME_ZONE? LocalTimezone? Help!!!

2006-12-07 Thread Todd O'Bryan

OK. I've read the Python docs on tzinfo objects and I think I could make
a tzinfo object, but it seems like there should be a way to get one out
of the Django innards.

I assume one can use the django.utils.tzinfo.LocalTimezone class to
create a tzinfo object, but what the heck do you pass to the constructor
so it knows what to do?

Todd


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



Re: Session problems

2006-12-07 Thread Jakub Labath

Solved!

Of course It was my code that was causing it!
Python, apache, django (old or new version) mod_python, fastcgi are
all innocent.

What was it?

RESPONSE_OBJECT = None
def my_view(request):
  ...blah..
  global REPOSNE_OBJECT
  if not RESPONSE_OBJECT:
RESPONSE_OBJECT = HttpResponse()
...blah...
  return RESPONSE_OBJECT

All fine and dandy the response object gets saved for future users to
re-use. Which is what I wanted sine the response object in question
just holds a meaningless 1x1 transparent gif that is used for tracking
purposes.

But the response object also stores the session_id cookie of the user
that happens to be the first one to hit that view.

Symptoms: The problem only ever happens for real users (stress testing
tools won't cut it unless they can also download images and consider
the cookies that those images might send. Also if you are just few
users hitting the dev site it might take days for this to manifest
itself.

I know - silly me for caching the HttpResponse object like that.

Thanks to everybody that tried to help!

Finally I'd like to say that I was only able to track down this
problem due to open source nature of django and the fact that I was
able to insert logging statements everywhere and eventually caught the
problem when I started logging raw request and response headers.

Best Regards

On 12/4/06, Jakub Labath <[EMAIL PROTECTED]> wrote:
> No I'm using prefork MPM.
>
> On 12/3/06, Graham Dumpleton <[EMAIL PROTECTED]> wrote:
> >
> >
> > Jakub Labath wrote:
> > > Hi All,
> > >
> > > Sorry for being quiet for a while just got back from a vacation.
> > >
> > > >
> > > > Hi Jakub,
> > > >
> > > > Do you have any updates on this problem? Was it a mod_python bug?
> > > >
> > > > Adrian
> > > >
> > >
> > > No the problem persists and I noticed that my coworkers have not
> > > resolved this in my absence. I'm still not sure what the problem is,
> > > as I mentioned to Jacob and on modpython list my next move is building
> > > a tool that simulates bunch of users log-in and out of admin and
> > > seeing if two different users get send the same cookie. This should
> > > give me more reliable way to reproduce the problem quickly ... then
> > > I'll take it from there.
> > > Should I find something I will contact one of the core devs directly,
> > > but so far I don't even know what is going on all I really know is
> > > that it is happening.
> > >
> > > As for trying fcgi instead of modpython that is definitively on a to
> > > do list but two weeks ago I spent ridiculous amount of time switching
> > > our production server from debian to gentoo hoping to solve the
> > > problem quickly by using more recent software - that did not happen.
> > > At this point I really need a tool to reproduce the problem quickly
> > > and then debug the hell out of everything.
> >
> > One question for you about this, are you using Apache with a
> > multithreaded MPM? In other words, is Apache compiled with the 'worker'
> > MPM for UNIX?
> >
> > I ask as a separate thread on the list describes pushing data into
> > os.environ in order to communicate information to Django from a custom
> > mod_python wrapper handler. To me though, doing such a thing could
> > cause problems and makes me wander how much Django may depend on
> > sourcing configuration from os.environ as doing this in a multithreaded
> > MPM may not work as distinct requests could interfere with each other
> > due to using what is effectively global data with no thread protection
> > and no way to stop a distinct thread from changing values before the
> > first thread got to use them.
> >
> > Graham
> >
> >
> > > >
> >
>
>
> --
> Jakub Labath
>


-- 
Jakub Labath

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



Re: Optimizing Templates

2006-12-07 Thread Jeremy Dunck

On 12/7/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Good luck, here's one page's set:

IIRC, you're doing -lots- of hits on these pages.  Assuming you're
already caching results where you can (in memcache or http
downstream), you probably need to look at caching loaded templates.
I'm suggesting this because there are two phases to template usage:
loading and rendering.  Loading is pretty fast, but if you don't
change templates much, and you render lots, it may make sense to cache
the loaded node tree.

Something like this might help:

template_name = "detail.html"
t = cache.get(template_name)
if not t:
  t = loader.get_template(template_name)
  cache.set(template_name, t, 60*60)#1 hour
...

t.render(c)

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



Sitemap questions (probably dumb ones)

2006-12-07 Thread [EMAIL PROTECTED]

I've been playing with the sitemap stuff and am finding it to be quite
slick. I do, however, have some questions about some unusual cases.

1)It works beautifully for listing all the detail pages that make up a
list view, but what about the page that takes the list view? In my
case, For example, I've got all my guitar pages in there, but not the
"guitars" page itself.

2) what about pages that aren't directly tied to any particular view.
My home page, for example, is built mostly from template tags, grabbing
this and that from here and there.

3)What if there's some page that's completely outside of django? Create
a dummy class returning the hardcoded URL? I've got a forum-archive
subdomain django doesn't know anything about, since it only exists to
archive the old php-based board.

Thanks!


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

Thanks Istvan,

You guessed right I am on windows.

I changed the script, ran it, installed django and navigated to the
built in admin site where I was greeted by the nice clean looking admin
interface that I am used to seeing.


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Istvan Albert


Paul Childs wrote:

> I'm pretty sure that the download script that I found here...
> http://code.djangoproject.com/ticket/1327
> must not be doing the job properly.

if you are using windows you'll need to change line 41 to:

fp = open(basedir + link, 'wb+')
   
i.


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

I'm pretty sure that the download script that I found here...

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

must not be doing the job properly.

I took the media from the admin in the 0.95 release and replaced the
dev version's media and that fixed a good chunk of it.

I'll have to do a SVN checkout from home and bring it in to try here.

Sorry for the alarm and thanks for your input.


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Istvan Albert


Adrian Holovaty wrote:

> I have never seen anything like that. I suspect the images are
> corrupted somehow, and I have no idea how that might have happened.

One common cause is opening files in text mode under windows. The flags
need to be 'wb' not just 'w' 

i.


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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Adrian Holovaty

On 12/7/06, Paul Childs <[EMAIL PROTECTED]> wrote:
> Well, I tried again and installed everything from scratch - new
> project, app, database. I went through the first two sections of the
> tutorial and I still got the same problem. I have posted this image of
> the problem which shows how the admin looks through Firefox...
>
> http://static.flickr.com/108/316578699_11591b364d_o.gif

I have never seen anything like that. I suspect the images are
corrupted somehow, and I have no idea how that might have happened.
Did you try redownloading and reinstalling Django?

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Re: Upgrading from .95 to Development Version

2006-12-07 Thread James Bennett

On 12/7/06, Paul Childs <[EMAIL PROTECTED]> wrote:
> I think this is a serious problem, should this be posted on the
> developer group or a ticket raised?

The images and CSS in the admin haven't changed, so I'm wondering if
this is an issue with your browser or with a corrupt download maybe...

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

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



Re: Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

Well, I tried again and installed everything from scratch - new
project, app, database. I went through the first two sections of the
tutorial and I still got the same problem. I have posted this image of
the problem which shows how the admin looks through Firefox...

http://static.flickr.com/108/316578699_11591b364d_o.gif

I think this is a serious problem, should this be posted on the
developer group or a ticket raised?


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



Re: is there a way to combine generic views?

2006-12-07 Thread Condredge

Hey Anton,
Another option is to write a wrapper view that makes use of the generic
views but adds more to it.  James Bennett over at B-List wrote a very
useful article on this:
http://www.b-list.org/weblog/2006/11/16/django-tips-get-most-out-generic-views


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



Re: displaying thumbnails in admin

2006-12-07 Thread [EMAIL PROTECTED]

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



Re: Optimizing Templates

2006-12-07 Thread Don Arbow

On Dec 7, 2006, at 8:15 AM, [EMAIL PROTECTED] wrote:
>
> Right off the top, I'd suggest alot of your slowdown is in the number
> of http requests. It appears you're making quite a few javascript and
> css calls. I'd see if i could pare that back.
>
>
> Also, temporarily remove your google analytics code... I've seen that
> cause a major hang on some sites.


He's talking about the time that Django takes to create the page,  
before the browser even sees it.

Is the amount of time a problem? I'm not sure if half a second is a  
problem or not. The page doesn't look too exotic, but it is big, I  
did notice a regroup call in there, which may take some time  
depending on the data it has to process.

If the timing is a problem, have you looked into caching?

Don


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



Re: Re: is there a way to combine generic views?

2006-12-07 Thread Jay Parlar

On 12/7/06, Adrian Holovaty <[EMAIL PROTECTED]> wrote:
>
> On 12/7/06, Anton Daneika <[EMAIL PROTECTED]> wrote:
> > I want a page which displays both the details of an object and the list of
> > the objects. Is there a known way to combine generic views to produce such a
> > thing? The problem is that all generic views return HttpResponse which I
> > don't need in that case -- just the processing.
> > I suppose it's just not the use case of the generic views -- they are not
> > for this.
>
> Hi Anton,
>
> You suppose correctly. :) None of the generic views combine an "object
> detail" with "object list."

But it's very easy to pass in the object list as 'extra_context' to
the generic view, which I think people sometimes forget about.

Jay P.

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



Re: filter by related record

2006-12-07 Thread Rory Campbell-Lange

On 07/12/06, Rory Campbell-Lange ([EMAIL PROTECTED]) wrote:
> I'm not sure how to do a join against a related record:
> 
> g=SiteEnergy.objects.filter(siteyear=9, energy__isofsite=False)
> raise TypeError, "Cannot resolve keyword '%s' into field" % name
> TypeError: Cannot resolve keyword 'energy' into field

...

my sql was somewhat incorrect.

> SELECT 
> se.* 
> FROM 
> bm_siteenergy se, data_energy e 
> WHERE 
> se.typer_id = e.id 
> AND 
> e.isoffsite=FALSE
  AND
  se.siteyear = 9;

-- 
Rory Campbell-Lange 
<[EMAIL PROTECTED]>


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



filter by related record

2006-12-07 Thread Rory Campbell-Lange

I'm not sure how to do a join against a related record:

g=SiteEnergy.objects.filter(siteyear=9, energy__isofsite=False)
raise TypeError, "Cannot resolve keyword '%s' into field" % name
TypeError: Cannot resolve keyword 'energy' into field

g=SiteEnergy.objects.filter(siteyear=9, typer.isoffsite=False)
SyntaxError: keyword can't be an expression

The query looks like this is standard SQL (Postgres) -- I'm not sure of the
Django approach here.

SELECT 
se.* 
FROM 
bm_siteenergy se, data_energy e 
WHERE 
se.typer_id = e.id 
AND 
e.isoffsite=FALSE;

Thanks for any help;
Rory

class SiteEnergy (models.Model):
'''
An Energy supply definition for a particular Site for a particular
Year of Assessment
'''
siteyear= models.ForeignKey  (SiteYear)
typer   = models.ForeignKey  (Energy)
source  = models.CharField   ('Source'   , maxlength =250)
usage   = models.FloatField  ('Usage', max_digits=10 , 
decimal_places=2, default=0)
# units come from Energy
kwh = models.FloatField  ('kWh'  , max_digits=10 , 
decimal_places=2, default=0)
cwf = models.FloatField  ('Carbon Factor', max_digits=13 , 
decimal_places=5, default=0)

from data/models.py:

class Energy (models.Model, General):
name   = models.CharField ('EPLabel Energy Name', blank=False 
,maxlength = 200)
localname  = models.CharField ('Local Energy Name'  , blank=True  
,maxlength = 200)
factorname = models.CharField ('Factor Name', blank=False 
,maxlength = 50)
localfactorname = models.CharField('Local Factor Name'  , blank=True  
,maxlength = 50)
# factor numbers in format 99.999 (9 hundred thousand to 7 
decimal places)
unit   = models.CharField ('Factor Unit', blank=False 
,maxlength = 50)
factor = models.FloatField('Factor' , blank=False 
,max_digits= 13   , decimal_places=7)
isreverse  = models.BooleanField  ('Reverse Factor' , blank=False 
,default   = False)
isoffsite  = models.BooleanField  ('Off Site'   , blank=False 
,default   = False)
isthermal  = models.BooleanField  ('Thermal Type'   , blank=False 
,default   = False)
created= models.DateTimeField (auto_now=True)
country= models.ForeignKey(Country)

Postgres tables:

eplabel=> \d bm_siteenergy
   Table "public.bm_siteenergy"
   Column|  Type  | Modifiers   
   

-++
 id  | integer| not null default 
nextval('bm_siteenergy_id_seq'::regclass)
 siteyear_id | integer| not null
 typer_id| integer| not null
 source  | character varying(250) | not null
 usage   | numeric(10,2)  | not null
 kwh | numeric(10,2)  | not null
 cwf | numeric(13,5)  | not null
Indexes:
"bm_siteenergy_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"bm_siteenergy_siteyear_id_fkey" FOREIGN KEY (siteyear_id) REFERENCES 
bm_siteyear(id)
"bm_siteenergy_typer_id_fkey" FOREIGN KEY (typer_id) REFERENCES 
data_energy(id)

eplabel=> \d data_energy
  Table "public.data_energy"
 Column  |   Type   |
Modifiers 

-+--+--
 id  | integer  | not null default 
nextval('data_energy_id_seq'::regclass)
 name| character varying(200)   | not null
 localname   | character varying(200)   | not null
 factorname  | character varying(50)| not null
 localfactorname | character varying(50)| not null
 unit| character varying(50)| not null
 factor  | numeric(13,7)| not null
 isreverse   | boolean  | not null
 isoffsite   | boolean  | not null
 isthermal   | boolean  | not null
 created | timestamp with time zone | not null
 country_id  | integer  | not null
Indexes:
"data_energy_pkey" PRIMARY KEY, btree (id)
Foreign-key constraints:
"data_energy_country_id_fkey" FOREIGN KEY (country_id) REFERENCES 
data_country(id)


-- 
Rory Campbell-Lange 
<[EMAIL PROTECTED]>


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email 

Re: Read only fields once created

2006-12-07 Thread Ross Burton

MerMer wrote:
> You can add "editable=False" to you database model.  This prevents it
> from showing up in Admin,  though of course it can still be edited
> directly in the DB.

This stops it being set in the admin when creating a new object, which
isn't what I want.

I think I'll have to hack the save() method...

Ross


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



Re: Optimizing Templates

2006-12-07 Thread [EMAIL PROTECTED]

Well it's none of that. The template process time is literally
150-500ms using the profiling stuff...

On Dec 7, 5:15 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Right off the top, I'd suggest alot of your slowdown is in the number
> of http requests. It appears you're making quite a few javascript and
> css calls. I'd see if i could pare that back.
>
> Also, temporarily remove your google analytics code... I've seen that
> cause a major hang on some sites.


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



Re: Optimizing Templates

2006-12-07 Thread [EMAIL PROTECTED]

Right off the top, I'd suggest alot of your slowdown is in the number
of http requests. It appears you're making quite a few javascript and
css calls. I'd see if i could pare that back.


Also, temporarily remove your google analytics code... I've seen that
cause a major hang on some sites.


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



Re: HTTP PUT and DELETE with Django?

2006-12-07 Thread Adrian Holovaty

On 12/7/06, cmars232 <[EMAIL PROTECTED]> wrote:
> Is it possible to process HTTP PUT and DELETE requests with Django?  If
> so, how would I access the data uploaded in an HTTP PUT?

Try accessing request.raw_post_data, perhaps?

http://www.djangoproject.com/documentation/request_response/#attributes

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Re: Admin 404s on users

2006-12-07 Thread [EMAIL PROTECTED]

I got it!

I had a mismatch between content_types and permissions. Not sure how it
happened, but it's fixed!

Thanks to everyone, espeically Adrian, for your help. I feel like I can
actually use the admin again!


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



Re: Admin 404s on users

2006-12-07 Thread Adrian Holovaty

On 12/7/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> ContentType matching query does not exist.
> [...]
> I'm not exactly sure what it means, but it's DEFINITELY more helpful.
> Perhaps I should look at my content-type table?

Run this code:

"""
from django.contrib.contenttypes.management import create_contenttypes
from django.db.models import get_apps
for app in get_apps():
create_contenttypes(app, created_models=None, verbosity=2)
"""

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



HTTP PUT and DELETE with Django?

2006-12-07 Thread cmars232

Is it possible to process HTTP PUT and DELETE requests with Django?  If
so, how would I access the data uploaded in an HTTP PUT?

(I would like to build a RESTful interface to some Django models.  I
guess I can use POST to upload if I have to, but would like to try
using PUT if possible.)

Thanks,
Casey


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



Re: Admin 404s on users

2006-12-07 Thread [EMAIL PROTECTED]

Still no go... what the hell is it looking for?


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



Re: Optimizing Templates

2006-12-07 Thread [EMAIL PROTECTED]

Good luck, here's one page's set:

### bone.html ###

{% load profiling %}
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd;>
http://www.w3.org/1999/xhtml; lang="{{ LANGUAGE_USED }}"
xml:lang="{{ LANGUAGE_USED }}">



http://www.curse-gaming.com; />








{% block title %}{% endblock %} {{
current_site.get_title|escape }}





cu_nextpage = '{% if next %}{{ next }}{% else %}{{ path }}{% endif
%}';
cu_lang = '{{ LANGUAGE_CODE }}';
var browserName = navigator.appName;
if (browserName == 'Netscape') {
document.writeln('');
}






{{ sajax_js }}
{% block extraheader %}{% endblock %}


{{ ads.header }}

sas_tmstp=Math.round(Math.random()*100);sas_masterflag=1;
function SmartAdServer(sas_pageid,sas_formatid,sas_target) {
if (sas_masterflag==1) {sas_masterflag=0;sas_master='M';} else
{sas_master='S';};
document.write('http://www.smartadserver.com/call/pubj/' + sas_pageid + '/' +
sas_formatid + '/'+sas_master + '/' + sas_tmstp + '/' +
escape(sas_target) + '?">');
}




initTips();






{% block right %}{% include "right_bar.html" %}{% endblock %}



{% block content %}{% endblock %}





{{ left_menu }}
{% if ads.sky %}

{{ ads.sky }}

{% endif %}





Copyright  2006 http://www.curse-gaming.com/en/wiki/about/;>Curse Gaming -
Read our http://www.curse-gaming.com/en/wiki/terms-of-use/;>Terms of
Use and http://www.curse-gaming.com/en/wiki/privacy-policy/;>Privacy
Policy
{% if DEBUG %}- Processtime: {{ mw_time }} ms (middleware) {{ viewtime
}} ms (view), {{ cptime }} ms (context processors), {% template_time 1
%} ms (template) {{ sql_queries }}{% endif %}




{% include "header.html" %}




{% block outbound %}{% endblock %}



_uacct = "UA-252840-1";
urchinTracker();


{{ ads.footer }}



### header.html ###

{% load i18n %}





Portal:

Change Portal
{% if user.hide_ads %}

{% for portal in portal_list %}
{% if portal.visible %}

http://{{ 
portal.domain }}/{{ LANGUAGE_CODE }}/"
title="{{ portal.name|escape }}">
{{ 
portal.name|escape }}


{% endif %}
{% endfor %}

{% endif %}

Language:

Change Language
{% if user.hide_ads %}

{% for lang in LANGUAGE_LIST %}



{{ 
lang.1 }}


{% endfor %}

{% endif %}




Curse:
http://www.curse-gaming.com/;>Home

{{ 
current_site.name|escape }}
News
{{
current_site.name|escape }} Forums



  

{% if user.is_authenticated %}
Logged in as {{ user.username }}

   

Re: Optimizing Templates

2006-12-07 Thread Adrian Holovaty

On 12/7/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Any Tips?
>
> Our templates are running from 150ms-500ms process times, something we
> really need to cut down. As far as I can tell it's not doing any
> queries in them.

If you copy-and-paste us your templates, we may be able to give you
concrete suggestions.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



Optimizing Templates

2006-12-07 Thread [EMAIL PROTECTED]

Any Tips?

Our templates are running from 150ms-500ms process times, something we
really need to cut down. As far as I can tell it's not doing any
queries in them.


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



Re: is there a way to combine generic views?

2006-12-07 Thread Adrian Holovaty

On 12/7/06, Anton Daneika <[EMAIL PROTECTED]> wrote:
> I want a page which displays both the details of an object and the list of
> the objects. Is there a known way to combine generic views to produce such a
> thing? The problem is that all generic views return HttpResponse which I
> don't need in that case -- just the processing.
> I suppose it's just not the use case of the generic views -- they are not
> for this.

Hi Anton,

You suppose correctly. :) None of the generic views combine an "object
detail" with "object list."

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



datetime.now()

2006-12-07 Thread Todd O'Bryan

How can I get the current time in a way that respects the time zone I've
set in Django settings?

Or, alternatively, how do I convert a string like 'America/New York'
into a timezone object?

Thanks,
Todd


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



is there a way to combine generic views?

2006-12-07 Thread Anton Daneika
Greetings, django users.

I want a page which displays both the details of an object and the list of
the objects. Is there a known way to combine generic views to produce such a
thing? The problem is that all generic views return HttpResponse which I
don't need in that case -- just the processing.
I suppose it's just not the use case of the generic views -- they are not
for this.

Anton


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


Re: Admin 404s on users

2006-12-07 Thread [EMAIL PROTECTED]

Ah ha!

DoesNotExist at /admin/auth/user/1/
ContentType matching query does not exist.
Request Method: GET
Request URL:http://gretschpages.com/admin/auth/user/1/
Exception Type: DoesNotExist
Exception Value:ContentType matching query does not exist.
Exception Location:
/home2/baxter/lib/python2.4/django/db/models/query.py in get, line 213

I'm not exactly sure what it means, but it's DEFINITELY more helpful.
Perhaps I should look at my content-type table?


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



Upgrading from .95 to Development Version

2006-12-07 Thread Paul Childs

The firewall has the SVN port closed off so when I noticed this ticket
http://code.djangoproject.com/ticket/1327
I was encouraged to go and get a development version of Django. I
scooped the script and ran it and lo and behold I had Revision 4179 of
the 96-pre version of Django! I uninstalled my .95 (kept the same MySQL
DB) and ran the install script.

My elation was short lived when I logged into the admin and was
presented with a messed up interface with some missing images, missing
text, hash lines running all over and illegible buttons. It turned out
to be messed up in both Firefox and IE.

The rest of my site seems to be working just fine except the images
that I pull from media/images/admin seem to have wavy lines under them.

Is there a known bug here (I searched users and developers groups but
couldn't find anything) or is it the download script used from ticket
1327?

Any advise for upgrading from .95 to dev, possibly updating the DB for
example?

It would be nice to be working with the latest and greatest.

Thanks in advance.


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



Re: DJANGO_SETTINGS_MODULE undefined error

2006-12-07 Thread Baurzhan Ismagulov

Hello Thejaswi,

On Thu, Dec 07, 2006 at 09:59:28AM -, theju wrote:
> whenever i use the following command (in a python shell)
> I get the following error.
> EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
> undefined.

Set it in your shell before starting python. I do the following in bash:

export DJANGO_SETTINGS_MODULE=myproject.settings

With kind regards,
--
Baurzhan Ismagulov
http://www.kz-easy.com/

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



Re: Admin 404s on users

2006-12-07 Thread Adrian Holovaty

On 12/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Also, I commented out all apps in settings.py except the "default"
> django ones, and it still happened.
>
> Anyone got any more ideas? I kind of need user admin!

Hey Tim,

"svn update" your code, assuming you're using the Django development
version. Then, making sure DEBUG=True, try loading the admin user page
again. You will get a more useful error message. Let's cross our
fingers that the error message will help you debug what's wrong.

Adrian

-- 
Adrian Holovaty
holovaty.com | djangoproject.com

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



DJANGO_SETTINGS_MODULE undefined error

2006-12-07 Thread theju

Hi,
I use Django 0.95 with python 2.4.4 on Fedora Core 6.
I want to use the object_list generic view from
django.views.generic.list_detail.object_list, but whenever i use the
following command (in a python shell)
>>> from django.views.generic import list_detail
I get the following error.
///
Traceback (most recent call last):
  File "", line 1, in ?
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/views/generic/list_detail.py",
line 1, in ?
from django.template import loader, RequestContext
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/__init__.py",
line 894, in ?
add_to_builtins('django.template.defaultfilters')
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/__init__.py",
line 891, in add_to_builtins
builtins.append(get_library(module_name))
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/__init__.py",
line 880, in get_library
mod = __import__(module_name, '', '', [''])
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/template/defaultfilters.py",
line 5, in ?
from django.utils.translation import gettext
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/utils/translation/__init__.py",
line 3, in ?
if settings.USE_I18N:
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/conf/__init__.py",
line 27, in __getattr__
self._import_settings()
  File
"/usr/lib/python2.4/site-packages/Django-0.95-py2.4.egg/django/conf/__init__.py",
line 52, in _import_settings
raise EnvironmentError, "Environment variable %s is undefined." %
ENVIRONMENT_VARIABLE
EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is
undefined.
///
I can understand that I've to change the DJANGO_SETTINGS but how can it
be done?
I've consulted the documentation that says that by using import
.settings.main the problem can be solved but where is the
main.py or the settings directory (settings is just a file).

Thanking in advance
Thejaswi Puthraya


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



How would I add a custom widget in the admin for a ManyToMany relationship?

2006-12-07 Thread naitsirhc

Hello,

I am currently working on a Django app and am quite pleased with the
framework overall.

The problem I am currently having is that the default Django admin
widget for a ManyToMany relationship is a multiple select box.  This is
causing a big problem for me since I have thousands of entries in the
models table for the ManyToMany relationship.  This means that the
admin page is taking 10+ seconds to load, since it is populating the
select list with ALL possible values from the database.

I would like to implement some type of widget that will allow me to use
a pop-up to browse through the objects referred to by the ManyToMany
relationship, only a few at a time, and select/deselect them through
this interface.  I have a pretty decent javascript background and can
use AJAX to do multiple queries for the browsing - the implementation
of the widget is not my concern.  What I don't know how to do is to
instruct Django admin to use my custom javascript widget for the field
in question.  I have looked around a lot and have found lots of
references to editing Manipulators for cases that at first seem like
they could be similar to my own.  However, I haven't found a
satisfactory answer.

I'm thinking that I will need to create my own formfield object and
manipulator, and somehow override the ManyToMany relationship to use
the new formfield type instead of the default SelectField.  Beyond this
general concept, I am stumped.  Has anyone had experience with
something along these lines?  Can anyone give some suggestions?

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



Re: Anonymous Sessions

2006-12-07 Thread Jeremy Dunck

On 12/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> Hrm if that's the case, I msut have slipped up in the code somewhere.
> Thanks :)
>
> I'll go see if i am inserting into sessions for some reason if they're
> anonymous.

To aid in things like this, I used a modded version of sessions which
has a has_auth attribute.

I don't really recommend it generally, but I (and you) probably have
unusual needs for sessions.

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



model field question

2006-12-07 Thread Rob Slotboom

For a model I have defined two table fields.
To fill those fields in admin I want to provide an extra dropdown
field.

Is it possible to add an extra field to the model without creating a
corresponding database field?


The use:

field1 = content_type_id
field2 = content_item_id

Extra dropdown field = "id1 id2", "id1 id2","id1 id2","id1 id2",
Befor saving I grap the values using split.


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



Re: test client - Keeps returning 301 status code and not sure why.

2006-12-07 Thread MerMer

Russ,

I think I had failed to import everything.   I have now used  "from
django import * with partial success.   Then I tried.

>>c=Client()
>>d=c.get('/promotions/')
>>d.content

This worked and returned me a large page of in my shell view.
However,

>>d.context
>>d.template
returns nothing.

>>d(dir)
returns a list of available methods, but "response" is not included.

I then created a simple view:-

def testivew(request):
 return HttpResponse("This is a test")

set this up via the URL conf and then tried again.  Same results as
before.


I'm running Python 2.4 on Windows XP with the latest version of Django.

MerMer







> That's wierd. I can't think of any obvious reason that that would happen.
>
> Ok - help me replicate the problem. Can you provide a test case - that is:
> - the simplest subset of the view behind /promotions/ that exhibits the 
> problem
> - instructions on how you are invoking the test.
> - The test code that exhibits the problem.
> - Any details you can furnish on your platform, OS, etc.
> 
> Yours
> Russ Magee %-)


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



M2M order-problem

2006-12-07 Thread patrickk

class GradeMembers(models.Model):
 grade = models.ForeignKey(Grade, edit_inline=models.TABULAR)
 user = models.ForeignKey(User, raw_id_admin=True, core=True)
 grade_group = models.ManyToManyField(GradeGroup)

this doesn´t work:
grademembers = GradeMembers.objects.filter(grade=grade.id).order_by 
('grade_group')

... because of the order-clause.

is this intended? did I miss something?

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



Re: Re: Singleton model instance

2006-12-07 Thread Phil Powell

Thanks for the input guys.  I'm kind of approaching this from a client
perspective, so was fishing around for the simplest use case from an
inexperienced admin user's point of view.

The suggestions of using a Page and "chunk" schema makes perfect
sense, and a quick Google threw up a good example[1].

However, I was kind of missing a trick, as Django's admin provides
exactly what I need in the form of user permissions - all I need to do
is set up a single intance for a given page model, with the fields
defined.  Then it's just a matter of changing permissions to only
allow client users to edit that instance.

Thanks for your help guys - all food for thought.

-Phil

[1] http://www.carthage.edu/webdev/?p=15

On 05/12/06, Jeff Forcier <[EMAIL PROTECTED]> wrote:
>
> As James and Fredrik have implied, I believe the proper solution here
> is to abstract things enough so that you *can* map the concept to a
> relational database; in this case, assuming that every 'Page' has an
> identifier, a 'Title' and, perhaps, multiple 'Sections' (each with an
> identifier and text), you make a Page model with (unique) Name and
> Title attributes, and then a Section or PageSection or etc, model, with
> Name and Text fields and a ForeignKey to Page.
>
> Then your homepage is a Page whose Name is "homepage" and whose Title
> is the page title, then with a few Sections: one named "introduction"
> with the intro text, one named "footer" with footer text, etc.
>
> Finally, you'd probably want to make a templatetag that operates on
> these models, so you can do something like {% printsection 
>  %} where  is the current Page object, and  name> is the name of the section you wish to print.
>
> So your homepage would looke something like this:
>
> 
> 
> {{ mypage.title }}
> 
> 
> {{ mypage.title }}
> {% printsection mypage "introduction" %}
>
> stuff goes here
>
> {% printsection mypage "footer" %}
> 
> 
>
> I'm sure you can come up with more specific and/or efficient variants
> on this theme, but basically this is going down the road that leads to
> content management systems, which have solved this basic problem for
> some time now :)
>
> Regards,
> Jeff
>
> Phil Powell wrote:
> >
> > Perhaps I've not explained myself properly.  Here's an example:
> >
> > I have a "Homepage" which has fields such as "Page Title",
> > "Introduction Text", "Footer Text" etc.  I want to be able to edit
> > these fields just like I'd edit a standard model instance, but because
> > there is only one instance of my "Homepage" I never want more than one
> > instance of it to exist.
> >
> > -Phil
>
>
> >
>

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



Re: Re: test client - Keeps returning 301 status code and not sure why.

2006-12-07 Thread Russell Keith-Magee

On 12/7/06, MerMer <[EMAIL PROTECTED]> wrote:
>
> Russ,
>
> Many thanks for the response.  However, c.response isn't working for
> me. I'm getting "No attribute found".  Running dir(c) does not show up
> this method.

That's wierd. I can't think of any obvious reason that that would happen.

Ok - help me replicate the problem. Can you provide a test case - that is:
- the simplest subset of the view behind /promotions/ that exhibits the problem
- instructions on how you are invoking the test.
- The test code that exhibits the problem.
- Any details you can furnish on your platform, OS, etc.

Yours
Russ Magee %-)

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



Re: Re: test client - Keeps returning 301 status code and not sure why.

2006-12-07 Thread James Bennett

On 12/7/06, MerMer <[EMAIL PROTECTED]> wrote:
> Many thanks for the response.  However, c.response isn't working for
> me. I'm getting "No attribute found".  Running dir(c) does not show up
> this method.

Random, possibly silly question: do you have CommonMiddleware enabled
with APPEND_SLASH = True? If so, and if you're sending a request to a
URL which doesn't end in a trailing slash, Django will issue a
redirect...

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

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



Re: Fast fcgi on dreamhost --> shauwn of the dead, help me shoot zombies

2006-12-07 Thread Phil

Yes, me too
It failed twice since Monday morning.
)c:

But 'happily', it is not a mission critical site, so I can afford to
have some downtime from time to time.

Which you luck.

Phil.

On Dec 6, 11:43 pm, "coulix" <[EMAIL PROTECTED]> wrote:
> I did the rename trick, still screw today.
> I will change my hosting pay a little bite more for a virtual server
> and set up apache + mod_python.
> i should have done this since the begining.
>
> On Dec 5, 2:38 am, "Phil" <[EMAIL PROTECTED]> wrote:
>
> > I stumbled across your post via jeffcrot.com and this came just right
> > at the perfect timing.
>
> > I just launched my first django app this week end (a site about online
> > gaming,http://www.netday.be, but beware it's in french) and I run into
> > some much 500 error trouble that I wasn't really confident.
>
> > But now, it runs smoothly since.
>
> > A great thanks.
>
> > Phil.
>
> > On Dec 3, 4:37 pm, "Maciej Bliziński" <[EMAIL PROTECTED]>
> > wrote:
>
> > >coulixnapisał(a):
>
> > > > Any idea on how to fix these problems on dreamhost?I'm not sure if what 
> > > > you're currently experiencing is the same problem
> > > I had few days ago. I did notice zombie processes and my Django app on
> > > Dreamhost was down every now and then. I've solved this problem by
> > > renaming django.fcgi file to dispatch.fcgi and changing corresponding
> > > lines in the .htaccess file. More details on my 
> > > blog:http://automatthias.wordpress.com/2006/12/01/django-on-dreamhost-inco...
> 
> > > Cheers,
> > > Maciej


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



Re: test client - Keeps returning 301 status code and not sure why.

2006-12-07 Thread MerMer

Russ,

Many thanks for the response.  However, c.response isn't working for
me. I'm getting "No attribute found".  Running dir(c) does not show up
this method.   

MerMer


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



Re: Fast fcgi on dreamhost --> shauwn of the dead, help me shoot zombies

2006-12-07 Thread Ramdas S
Me too. I am looking at putting up a dedicated web server.

Its going to cost me between 1200 to 1600 USD a year compared to $99 I paid
Dreamhost.

But I think it will be worth it.

Ramdas
On 12/7/06, coulix <[EMAIL PROTECTED]> wrote:
>
>
> I did the rename trick, still screw today.
> I will change my hosting pay a little bite more for a virtual server
> and set up apache + mod_python.
> i should have done this since the begining.
>
>
> On Dec 5, 2:38 am, "Phil" <[EMAIL PROTECTED]> wrote:
> > I stumbled across your post via jeffcrot.com and this came just right
> > at the perfect timing.
> >
> > I just launched my first django app this week end (a site about online
> > gaming,http://www.netday.be, but beware it's in french) and I run into
> > some much 500 error trouble that I wasn't really confident.
> >
> > But now, it runs smoothly since.
> >
> > A great thanks.
> >
> > Phil.
> >
> > On Dec 3, 4:37 pm, "Maciej Bliziński" <[EMAIL PROTECTED]>
> > wrote:
> >
> > >coulixnapisał(a):
> >
> > > > Any idea on how to fix these problems on dreamhost?I'm not sure if
> what you're currently experiencing is the same problem
> > > I had few days ago. I did notice zombie processes and my Django app on
> > > Dreamhost was down every now and then. I've solved this problem by
> > > renaming django.fcgi file to dispatch.fcgi and changing corresponding
> > > lines in the .htaccess file. More details on my blog:
> http://automatthias.wordpress.com/2006/12/01/django-on-dreamhost-inco...
> >
> > > Cheers,
> > > Maciej
>
>
> >
>

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