Re: displaying thumbnails in admin
the worst idea is: class Picture(models.Model): file = models.ImageField(upload_to=settings.MY_MEDIA, blank=True, null=True) entry = models.ForeignKey(Entry) def filename(self): if os.name == 'nt': return str(self.file.split('\\')[-1]) else: return str(self.file.split('/')[-1]) def picture(self): return '' + self.filename() picture.allow_tags = True class Admin: list_display = ('filename', 'picture') 2006/12/6, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: > > Hi -- how can I make the admin interface display images? The default > is to show the link to an image. I know it should be easy but I'm not > sure how to go about doing it. > > 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: implementing user themes using Django templates
Rohit wrote: > I am using Django templates standalone for rendering an > Apache/modpython website (without Django apps). I need to provide > themes for each user: they will have the ability to choose from a set > of themes and when that changes the base template directory needs to > change *for that user only*. > I would suggest that you setup your templates with proper XHTML and then use CSS to handle the varying themes. I've done this on a number sites myself(none in django...yet) and it works very well. You basically swap out which css file to link the page to in the template and just always pass that flag in. This lets you give each user an option in a profile for which theme they prefer. So in your template you place a block in the portion of the page and replace it with something like this: You could even go as far as having this info in it's own class and then linking a profile to it. The biggest advantage here is that you can use a base set of templates, and continuously add themes without any changes to the templates. The biggest disadvantage being that you need to spend the time to make proper validating XHTML that will be flexible for every thing you will need it to do. (It really is worth the extra effort to ensure that you XHTML and your CSS validates properly, saves a lot of time trying to figure out strange layout issues later) I submit this site for an example of what you can do with XHTML and CSS. This site has only one real page, but shows hundreds of different themes using the exact same xhtml: http://www.csszengarden.com/ Hope this helps! Calvin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Admin fields for contained members
>From tutorial, part 2, the following type of code class Poll(models.Model): ... class Admin: fields = ( ) is used to control how the admin interface displays the Poll objects (controlling which items appear on separate lines, etc). How can I control how the contained objects are displayed? (eg, the Choice items referring to this particular Poll)For instance, suppose I wanted to have the Choice question and the vote count items on separate lines? I tried adding the "class Admin: fields..." code to Choice, but that didn't make any difference to the compound display that the admin interface creates for creating/editing Poll objects. 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: limit_choices_to and negative logic in Q objects?
Well, I figured this part out at least... QNot(Q(field__filter='some value')) Next Question. Is there a way to reference 'self.id' inside the model class, to exclude the current self from the select list? In my case, I have a self-referencing table of parents and children. I want to eliminate the possibility of a user entering/selecting a child as their own parent... hence the need to exclude. If I use 'self.id' in my Q expression, the model returns "self undefined" Help? -D On Dec 6, 2006, at 10:31 PM, Darin Lee wrote: > > Hi, > > I'm trying to figure out how to use inverted/NOT logic in the > limit_choices_to argument for models.ForeignKey() fields. A google > search turned up the following: > http://code.djangoproject.com/ticket/1579 > > This tracker comment indicates that this issue was/is resolved by > adding support for 'Q' objects. The Q objects work fine, but for the > life of me, I can't figure out how to 'invert' it? Does anyone have > any pointers on how to make this work? > > Thanks in advance! > 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: limit_choices_to and negative logic in Q objects?
On 12/6/06, Darin Lee <[EMAIL PROTECTED]> wrote: > Does anyone have > any pointers on how to make this work? from django.core.meta import Q, QNot q=QNot(Q(whatever__exact=1)) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
limit_choices_to and negative logic in Q objects?
Hi, I'm trying to figure out how to use inverted/NOT logic in the limit_choices_to argument for models.ForeignKey() fields. A google search turned up the following: http://code.djangoproject.com/ticket/1579 This tracker comment indicates that this issue was/is resolved by adding support for 'Q' objects. The Q objects work fine, but for the life of me, I can't figure out how to 'invert' it? Does anyone have any pointers on how to make this work? Thanks in advance! 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
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. On Dec 6, 4:27 pm, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > It is a problem. It hits the db if it has to create it.Sorry I still don't > > understand :-). You say that you do need > authentication but don't need anonymous sessions. Then in default Django > setup you never hit a database unless you try to store something in > session. So you can check if you work with authenticated (non-anonymous) > user and hit session only then: > > def some_view(request): >if request.user.is_authenticated(): > request.session['last_login'] = datetime.now() >... >return ... > > Am I thinking in a wrong direction? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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.
On 12/7/06, MerMer <[EMAIL PROTECTED]> wrote: > > I am trying to get to grips with the test client > (Django.test.client.Client) > > I've done the following > > >>from Djano.test.client import Client > >>c=Client() > >>c=c.get('/promotions/',) > >>c.status_code > 301 301 is a permanent redirection, which indicates that the view attached to /promotions is returning a HttpResponsePermanentRedirect. Another common (and similar) response is 302 - a HttpReponseRedirect, which happens after a successful post to a generic view. If you check the contents of c.response, you should see the URL that you are being redirected to (which may be the same URL). 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 -~--~~~~--~~--~--~---
test client - Keeps returning 301 status code and not sure why.
I am trying to get to grips with the test client (Django.test.client.Client) I've done the following >>from Djano.test.client import Client >>c=Client() >>c=c.get('/promotions/',) >>c.status_code 301 I keep getting 301 or 500 status codes. I've tried the full URL but have not got any further. The URL works fine in a normal browser and in the manage.py runserver window it shows a status code of 200. Anybody have any ideas of where I'm going wrong with the Test Client. 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: Re: High Load
On 12/6/06, Uros Trebec <[EMAIL PROTECTED]> wrote: > That might be a good idea. It seams that PgSQL scales 200% percent > better than MySQL (when using multiple processors/cores/machines. > > Take a look at this test ( http://tweakers.net/reviews/646/1 ). It's > basically a CPU comparison but using DB performance on real live > example as tests. Here's the scaling properties ( > http://tweakers.net/reviews/646/15 ), but I recommend reading the whole > article. > Maybe this one shows it even better: http://tweakers.net/reviews/657/5 regards, Uros --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Random Data
I have can generate random data like Alan Boyce suggested, and that works to a point but as my models evolved I am looking for a more general way of generate random data so that I don't have to mess with the random generation section every time I change a model. I am asking because I am still learning how to think in python, I am used to statically defining almost everything in my program and I am trying to learn how to think in abstractions and patterns. On 12/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > You can use python. Try: > > # Make a random phone number > def mkphone(): > import random > phone = "" > for i in range(10): > if (i == 3): > phone += "-" > if (i == 6): > phone += "-" > phone += str(random.randrange(0,9)) > return phone > > # Based on > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59865 > > # make a random username > def randomLine(filename): > "Retrieve a random line from a file, reading through the file > once" > fh = open(filename, "r") > lineNum = 0 > it = '' > while 1: > aLine = fh.readline() > lineNum = lineNum + 1 > if aLine != "": > # > # How likely is it that this is the last line of the file ? > > if random.uniform(0,lineNum)<1: > it = aLine > else: > break > fh.close() > return it > > I usually use a file like /usr/share/dict/names or something similar to > make user names > > Best, > > Alan Boyce > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Random Data
You can use python. Try: # Make a random phone number def mkphone(): import random phone = "" for i in range(10): if (i == 3): phone += "-" if (i == 6): phone += "-" phone += str(random.randrange(0,9)) return phone # Based on http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/59865 # make a random username def randomLine(filename): "Retrieve a random line from a file, reading through the file once" fh = open(filename, "r") lineNum = 0 it = '' while 1: aLine = fh.readline() lineNum = lineNum + 1 if aLine != "": # # How likely is it that this is the last line of the file ? if random.uniform(0,lineNum)<1: it = aLine else: break fh.close() return it I usually use a file like /usr/share/dict/names or something similar to make user names Best, Alan Boyce --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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
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: Random Data
I wrote a utility to parse a model files as well as embedded comments that provided data loading hints. It was trivial to do. The utility used "cog" to generate a data loading program. That worked like a charm even as the underlying models evolved. (This approach was a "win" since the data loading program was quite complex. We have sinced rewritten the loading utility with python and simplified it to the point where the need to automatically generate the code for the data loader is overkill.) Combining that idea with techniques for generating random data should be easy. The http://agiletesting.blogspot.com/";>Agile Testing Blog" has a recent post about Python Fuzz testing Tools that has some good links regarding the generation and use of random data. On Dec 6, 3:34 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > I was wondering if anybody has any ideas on random generation of data. > I want to fill some of my models with random data with random users and > such. So that I can see how my UI is doing and some other tests. I > figured that becuase there is alot of data defenition in the models > there is probably away to do auto random data generation. > > Any Ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Read only fields once created
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. MerMer Ross Burton wrote: > Hi, > > Is it possible to have fields in the model that can be set at object > creation, but are immutable after that? I have an "original estimate" > field that should only be set when creating the object, and never > edited after that. > > Thanks, > 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: OpenID
There was a very recent post on CAS (Central Authentication System). The author has written the middeware for Django and is making it publically available. I've no idea if there are any differences between CAS and OpenID, but thought it might be worth a mention. 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 -~--~~~~--~~--~--~---
Random Data
I was wondering if anybody has any ideas on random generation of data. I want to fill some of my models with random data with random users and such. So that I can see how my UI is doing and some other tests. I figured that becuase there is alot of data defenition in the models there is probably away to do auto random data generation. Any Ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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
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! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Multiprocessing and Django
On 12/6/06 12:00 PM, garyrob wrote: > Due to Python's global interpreter lock, I assume that Django can't > take advantage of multiple CPU's. Is that correct? But most high-end > machines these days come with multiple CPU's. No, that's not correct; if you're running Django in an approved deployment setup -- that is, under mod_python or FCGI -- you'll be running a number of processes anyway; each gets its own Python process, and so the GIL isn't an issue. Every single one of the machines I run Django on is, in fact, a multi-core machine (two or four). I can attest to the fact that Django runs very, very fast on them ;) You might check out some performance tips I wrote up a while back: http://www.jacobian.org/writing/2005/dec/12/django-performance-tips/ -- stuff there is a *lot* more important than the chipset you're running on. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Multiprocessing and Django
My company is buying a new machine to run a Django-based application. Due to Python's global interpreter lock, I assume that Django can't take advantage of multiple CPU's. Is that correct? But most high-end machines these days come with multiple CPU's. If so, is there any reason we can't ameliorate that problem by running multiple instances of Django on the same box, running the same application? That is, there's no more of a problem running them on one box than in dealing with the session issues related to running them on different boxes, is there? Thanks, Gary --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Outputting comma separated list for objects in a ForeignKey?
Brilliant, 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 -~--~~~~--~~--~--~---
displaying thumbnails in admin
Hi -- how can I make the admin interface display images? The default is to show the link to an image. I know it should be easy but I'm not sure how to go about doing it. 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: Outputting comma separated list for objects in a ForeignKey?
On 12/6/06 1:48 PM, [EMAIL PROTECTED] wrote: > I have a model, which has ForeignKey relationship to another model set > up. How can I output a list of all the objects within the ForeignKey as > a comma separated list? > > For example - the list has 3 objects (a, b, c) - so should output a > list like "a, b, c" > > How can I do this (in the template)? {{ myobject.relation_set|join:", " }} See http://www.djangoproject.com/documentation/templates/#join Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Read only fields once created
On Dec 6, 2:48 pm, "Sarcastic Zombie" <[EMAIL PROTECTED]> wrote: > On Dec 5, 3:24 am, "Ross Burton" <[EMAIL PROTECTED]> wrote: > > > Hi, > > > Is it possible to have fields in the model that can be set at object > > creation, but are immutable after that? I have an "original estimate" > > field that should only be set when creating the object, and never > > edited after that. > > > Thanks, > > RossSeems to me that the easiest route is to overload the object's > __setattr__ or __save__ method. For example, if you went the save > route: > > def __save__(self): > old = Object.objects.get(id=self.id) # Fetch a pristine copy from the > database. > if self.orig_estimate and old.orig_estimate: # If the object has a > previous value... > self.orig_estimate = old.orig_estimate # Then overwrite the initial > value over top of the field. > super(self.__class__, self).save() > > I prefer the save route over __setattr__ even though the former would > likely be more efficient. The __save__ method has the advantage of > gating at the "writing to the database" step, which keeps anyone from > mucking around with the object's value dict and saving it. > > Keep in mind, the code is off the top of my head, but I *think* it's > correct. Should give you something to google off of, anyway. :) > > -SZ Eww, I didn't know it shortened the line length so much. For reference, the code is: def __save__(self): old = Object.objects.get(id=self.id) if self.orig_estimate and old.orig_estimate: self.orig_estimate = old.orig_estimate super(self.__class__, self).save() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Read only fields once created
On Dec 5, 3:24 am, "Ross Burton" <[EMAIL PROTECTED]> wrote: > Hi, > > Is it possible to have fields in the model that can be set at object > creation, but are immutable after that? I have an "original estimate" > field that should only be set when creating the object, and never > edited after that. > > Thanks, > Ross Seems to me that the easiest route is to overload the object's __setattr__ or __save__ method. For example, if you went the save route: def __save__(self): old = Object.objects.get(id=self.id) # Fetch a pristine copy from the database. if self.orig_estimate and old.orig_estimate: # If the object has a previous value... self.orig_estimate = old.orig_estimate # Then overwrite the initial value over top of the field. super(self.__class__, self).save() I prefer the save route over __setattr__ even though the former would likely be more efficient. The __save__ method has the advantage of gating at the "writing to the database" step, which keeps anyone from mucking around with the object's value dict and saving it. Keep in mind, the code is off the top of my head, but I *think* it's correct. Should give you something to google off of, anyway. :) -SZ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Outputting comma separated list for objects in a ForeignKey?
Hey, I have a model, which has ForeignKey relationship to another model set up. How can I output a list of all the objects within the ForeignKey as a comma separated list? For example - the list has 3 objects (a, b, c) - so should output a list like "a, b, c" How can I do this (in the template)? Many Thanks, O --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: problems turning debug off
Flat pages catches a 404 and then looks to see if a flat page exists for that url --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Converting a Django site to flat HTML
Here's the wget flags I'm using to do something similar: wget -E --load-cookies /path/to/firefox/profiles/cookies.txt -r -k -l inf -N -p -E = use .html as extension -r = recurse -k = convert links -l inf = infinite depth -N = disable timestamping? -p = get page requisites Other than that, I also created an "all objects" page that gets all my objects that map to pages, call get_absolute_url() on each one, and print out a list. I call wget on that URL to make sure it hits every page in the database just in case some pages aren't linked to directly (eg: when we have a JS redirect to a page depending on some user interaction.) -Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
AttributeError: 'NoneType' object has no attribute 'split'
Forwarded from the Django dev list in the hopes that future searchers find this... The python2.4 email module has a bug which affects Django upload handling for multipart forms (e.g. forms w/ file uploads). -- Forwarded message -- From: Jeremy Dunck <[EMAIL PROTECTED]> Date: Dec 6, 2006 11:59 AM Subject: Re: New faster SelectBox.js To: django-developers@googlegroups.com On 12/6/06, Graham King <[EMAIL PROTECTED]> wrote: > PS: > If you have lots of elements in your select box, and your object has a > FileField (meaning multipart encoding on your form), you might run into > an intermittent bug Saving, whereby in http.__init__ on this line: > > name_dict = parse_header(submessage['Content-Disposition'])[1] > > parse_header gets give None. > This is, believe it or not, a Python email package bug: > > http://sourceforge.net/tracker/index.php?func=detail&aid=170&group_id=5470&atid=305470 Christ, I've been trying half-heartedly to reproduce that for ages. I just pinged the python bug to get it fixed. I don't see a way to work around this without patching email.message_from_string. All, here's a traceback for the problem, for future searchers: File "/pegasus/code/current/django/utils/httpwrappers.py", line 46, in parse_file_upload name_dict = parse_header(submessage['Content-Disposition'])[1] File "/usr/lib/python2.4/cgi.py", line 331, in parse_header plist = map(lambda x: x.strip(), line.split(';')) AttributeError: 'NoneType' object has no attribute '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: Best way to administer static configuration data?
Ah, and you also have to override the .delete() method! http://groups.google.com/group/django-developers/browse_frm/thread/2caa976249783fae/# --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Best way to administer static configuration data?
[EMAIL PROTECTED] wrote: > I could create a model and then only have one row, but that seems > clunky. I did exactly this and overrode the .save() method so that the model was constrained to only have one row by resetting self.id to 1 in the .save() (I think...). Effect was that if you added a second row in the admin - and this is the only clunkiness I perceived - you just got one row with your new data. You could also edit the existing one row. 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: Anonymous Sessions
[EMAIL PROTECTED] wrote: > It is a problem. It hits the db if it has to create it. Sorry I still don't understand :-). You say that you do need authentication but don't need anonymous sessions. Then in default Django setup you never hit a database unless you try to store something in session. So you can check if you work with authenticated (non-anonymous) user and hit session only then: def some_view(request): if request.user.is_authenticated(): request.session['last_login'] = datetime.now() ... return ... Am I thinking in a wrong direction? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Best way to administer static configuration data?
On 12/6/06 9:04 AM, [EMAIL PROTECTED] wrote: > I'm looking to manage site configuration data through an administrative > interface, such as changing the header graphic of my site. In my > pre-Django days I would have loaded a text configuration file's > contents into form fields, and the save would overwrite it. > > I could create a model and then only have one row, but that seems > clunky. > > Any ideas? The way we usually do it -- for our news sites, so YMMV -- is with some sort of SiteConfig object. We give it a ``date_effective`` field along with all the site configuration options we need. We can then get the latest SiteConfig based on the date effective (from a template tag or a context processor, depending), and use that throughout the site. Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Best way to administer static configuration data?
I'm looking to manage site configuration data through an administrative interface, such as changing the header graphic of my site. In my pre-Django days I would have loaded a text configuration file's contents into form fields, and the save would overwrite it. I could create a model and then only have one row, but that seems clunky. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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
It is a problem. It hits the db if it has to create it. If i have to I'll rewrite the library. On Dec 6, 12:31 pm, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > Well we obviously need authentication, we just don't need anonymous > > session handling.Then it shouldn't be a problem. Sessions are created and > > hit db only if > you store something in it. Or if you have SESSION_SAVE_EVERY_REQUEST = > True. Otherwise request.session is just an empty dict created in memory. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: GenericForeignKey
On 12/6/06 6:32 AM, paulh wrote: > Using a GenericForeignKey everything seems to work until you try to use > fields in an Admin class. That's right - generic relations don't (yet) have the necessary code for admin interfaces. It'll happen eventually, but for now, sorry! Jacob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Converting a Django site to flat HTML
Hi, yes I looked at Curl but I was looking for a quick 'n' dirty way to do it, without worrying too much about the options on the command line. Since I'm coming to Python from Perl, I would also probably choose a Perl-ish way to do what you're accomplishing with Python modules. But, whatever :) Can you share the scripts you've written? I wonder if there's a generic need for this kind of thing, but maybe what you've done is specific to your setup... I'm quite taken with the idea of using Django as a web-site factory regardless of the final deployment environment, so maybe a write-up of the alternatives would find some readers. -- James --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
GenericForeignKey
Using a GenericForeignKey everything seems to work until you try to use fields in an Admin class. The you get an error like this: FieldDoesNotExist at /modp/admin/tst2/comnam/add/ Comnam has no field named 'com_obj' and a python dump. Just updated by copy of django with the latest dev version and this is still the case. Setup is: ubuntu linux; apache2; mod_python on server and a windows client. Paul Hide --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: High Load
[EMAIL PROTECTED] je napisal: > We may test postgreSQL to see if this fixes our latest problem, as our > SQL cluster isnt setup yet as the hoster didnt have it ready, and this > is a peak traffic day. That might be a good idea. It seams that PgSQL scales 200% percent better than MySQL (when using multiple processors/cores/machines. Take a look at this test ( http://tweakers.net/reviews/646/1 ). It's basically a CPU comparison but using DB performance on real live example as tests. Here's the scaling properties ( http://tweakers.net/reviews/646/15 ), but I recommend reading the whole article. regards, Uros --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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
[EMAIL PROTECTED] wrote: > Well we obviously need authentication, we just don't need anonymous > session handling. Then it shouldn't be a problem. Sessions are created and hit db only if you store something in it. Or if you have SESSION_SAVE_EVERY_REQUEST = True. Otherwise request.session is just an empty dict created in memory. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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
Well we obviously need authentication, we just don't need anonymous session handling. On Dec 6, 11:31 am, Ivan Sagalaev <[EMAIL PROTECTED]> wrote: > [EMAIL PROTECTED] wrote: > > I'd like a simple option to disable this, any plans to implement > > something of the sorts?The intended way is to remove SessionMiddleware and > > those depending on > it (AuthenticationMiddleware) from MIDDLEWARE_CLASSES and > 'django.contrib.sessions', 'django.contrib.auth' from INSTALLED_APPS in > your settings. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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
[EMAIL PROTECTED] wrote: > I'd like a simple option to disable this, any plans to implement > something of the sorts? The intended way is to remove SessionMiddleware and those depending on it (AuthenticationMiddleware) from MIDDLEWARE_CLASSES and 'django.contrib.sessions', 'django.contrib.auth' from INSTALLED_APPS in your settings. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: can't figure out how to call a generic view inside my own view
Anton Daneika wrote: > Hello, everyone. > > I am trying to call django.views.generic.list_detail.object_list from my > own view, but I get the error page saying "dict' object has no attribute > '_clone'" > > Here is the function: > def my_gallery_listing(request, gallery_id): > d = dict(queryset=Photo.objects.filter(gallery__pk = gallery_id), > paginate_by= 2, allow_empty= True) > django.views.generic.list_detail.object_list(request, d) The info_dict that you usually construct in urlconf is not intended to be passed to a generic view "as is". It has to be converted into keyword arguments which in Python is done with '**': return django.views.generic.list_detail.object_list(request, **d) This is equivalent to: return django.views.generic.list_detail.object_list(request, queryset=Photo.objects.filter(...), paginate_by=..., allow_empty=) When you pass it without converting as a single argument `object_list` thinks that `d` is its first parameter where it expects a queryset and calls `_clone` on it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
can't figure out how to call a generic view inside my own view
Hello, everyone. I am trying to call django.views.generic.list_detail.object_list from my own view, but I get the error page saying "dict' object has no attribute '_clone'" Here is the function: def my_gallery_listing(request, gallery_id): d = dict(queryset=Photo.objects.filter(gallery__pk = gallery_id), paginate_by= 2, allow_empty= True) django.views.generic.list_detail.object_list(request, d) I guess the way I call it is totally wrong. The documentation at http://www.djangoproject.com/documentation/generic_views/#django-views-generic-list-detail-object-listsays there's only one required param -- queryset: A QuerySet that represents the objects. I did try some variations of the call, but fail to find the correct one. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
implementing user themes using Django templates
I am using Django templates standalone for rendering an Apache/modpython website (without Django apps). I need to provide themes for each user: they will have the ability to choose from a set of themes and when that changes the base template directory needs to change *for that user only*. For the initial template that I am loading I can achieve this by reading the template from the appropriate theme directory, call loader.get_template_from_string() and render it. My problem is when the template has included templates using {% include %}. Those will still use the global TEMPLATE_DIRS setting, right? How can I get those to be searched based on the current theme directory? Is this possible at all, or do I need to extend Django somehow to do this? Thanks, Rohit --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---