Re: get_FOO_display and grouped data
Jacob Kaplan-Moss wrote: > Try:: > > {% regroup feature.task_set.all|dictsortreversed:"priority" by > get_priority_display as grouped %} > > That is, the "by" argument to {% regroup %} doesn't just have to be a field > name; it can be anything that a variable could resolve. Excellent, 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 -~--~~~~--~~--~--~---
Saving info about viewed tags
Hi, I have an Objects Model and a Tags Model with a M2M relationship between them. I want to update info about the tags of the object visited by the user updating it everytime the user requests an Object. Is it a crazy idea? I want to know wich tags are the most viewed by the user and wich are the most recent he has view so that I can recommend him Objects that have also such tags (objects that are related to the ones he is interested in). This is my main idea how the models should be: === class MyObject(models.Model): tags = models.ManyToManyField(Tag) etc. class Tag(models.Model): etc... class RelationModel(models.Model): my_object = models.ForeignKey(MyObject) tag = models.ForeignKey(Tag) times_viewed = models.PositiveIntegerField() latest_view= models.DateTimeField() Problems I see: === - Lets say I have 30 tags for each object, I need to create_or_update 30 rows everytime a user requests an object. That could be a bottleneck :( - The relation table can be very big: 100.000 users x 2.000 tags each user = 200.000.000 rows in the relation table I should limit it to lets say 50 tags per user and in each update overwrite the less viewed and older tags with the new ones. -> more updates on every request :S - Is this the better way to do what I want to do? Any ideas? Thank you for your 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: Admin 404s on users
On 12/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > It doesn't give me anything to go on: > > Page not found (404) > Request Method: GET > Request URL:http://gretschpages.com/admin/auth/user/1/ > > You're seeing this error because you have DEBUG = True in your Django > settings file. Change that to False, and Django will display a standard > 404 page. Try running "manage.py syncdb" to install any permissions that might be missing. I think an ObjectDoesNotExist exception is being raised somewhere, causing the 404. I seem to recall having a similar problem once, where the PermissionDoesNotExist exception was causing a 404. 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: DB Query
Found it - a custom manager: http://www.djangoproject.com/documentation/model_api/#custom-managers --~--~-~--~~~---~--~~ 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: Pagination variable problem with generic list and limited queryset
Thanks for the explanation Rajesh. On Dec 4, 2:31 pm, "RajeshD" <[EMAIL PROTECTED]> wrote: > On Dec 3, 8:36 pm, "Silas" <[EMAIL PROTECTED]> wrote: > > > I have a problem with generic.list_detail.object_list, a limiting > > queryset, and pagination variables. > > > For some reason when I use the code below, results are restricted to > > the sliced 100, but all the pagination variables show results as if the > > slice wasn't there.I don't have a solution, but I can explain the reason > > for this > behaviour. > > - The ObjectPaginator uses the QuerySet.count() method in deriving the > 'hits' count that is then used in all its paging calculations > - The QuerySet.count() method does not take into account the slice > offset and limit > > I suppose you could file this as a bug in ObjectPaginator -- if it were > to base its hits on len(QuerySet), that would solve this problem. Not > sure if there would be a performance issue from len() evaluating the > QuerySet. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
DB Query
How can one perform a database query from an overloaded admin save function? I want to retrieve an old value, compare it to the one currently being saved, then perform an action based on the result of the comparison. Thanks, Bret --~--~-~--~~~---~--~~ 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: Dynamic includes in template?
On 12/5/06, matthew <[EMAIL PROTECTED]> wrote: > > Hi, > > Looking at the documentation, I see that you can do "include > template_name" or "include 'template.html'". I'd like to combine these > - concatenating a couple of strings and a variable to make the template > name - but it's not working (no error, but no template included). > > This template displays a survey. Each survey question has a 'type' > attribute with several choices defined in the model > ("multiplechoice","matrix","ranking" etc). > > I'd like to loop through the list of questions and render each question > using the appropriate template, which is determined by the type of > question. So for example a 'multiplechoice' question corresponds to the > 'questions/multiplechoice.html' template. > > This is the bit that's not working (viewsurvey.html): > {% for question in questions %} > {% include 'questions/' + question.get_type_display() + '.html' %} > {% endfor %} > > Why can't I concatenate the strings and variable to include the > relevant template? > > The model looks like this: > class Question(models.Model): > Types = ((0,"TrueFalse"), > (1,"MultipleChoice")) > type = models.IntegerField(choices=Types) > > I'v write some custom tags you can try: expr http://code.djangoproject.com/wiki/ExprTag then the sample code is: {% for question in questions %} {% expr 'questions/' + question.get_type_display() + '.html' as tmp %} {% include tmp %} {% endfor %} But I don't know if it can do the work, but you can try it. You should save ExprTag code into some templatetags file, and use load tag to import it. See the template_python document to get the details. -- I like python! UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad My Blog: http://www.donews.net/limodou --~--~-~--~~~---~--~~ 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: get_FOO_display and grouped data
On 12/4/06 4:34 PM, Ross Burton wrote: > In my view, I'm grouping the data on the priority: > > {% regroup feature.task_set.all|dictsortreversed:"priority" by priority > as grouped %} > {% for group in grouped %} > {{ group.grouper }} > > However, when I do this, group.grouper expands to "0" or "2", not "Low" > or High". How can I get the display name for this field? Try:: {% regroup feature.task_set.all|dictsortreversed:"priority" by get_priority_display as grouped %} That is, the "by" argument to {% regroup %} doesn't just have to be a field name; it can be anything that a variable could resolve. 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: Searching a ForeignKey
On 12/4/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > > On 12/5/06, Bret Walker <[EMAIL PROTECTED]> wrote: > > > > Is there a way to search a CharField contained in a ForeignKey? > > Yes. You can traverse any foreign key or m2m relation in Django's query > language. For example: > > Article.objects.filter(author__firstname='Bret') > > would retrieve all article objects that have a related author with a first > name of 'Bret'. The double underscore notation is used to describe how you > want to traverse relations; the underlying table joins (if required) will be > automatically constructed by Django. > > More detail here: > http://www.djangoproject.com/documentation/db_api/ > > Yours, > Russ Magee %-) > Thanks, Russ. I realized that I left out one important part of my question. a CharField contained in a ForeignKey *from the admin interface*? I'm not quite sure how I'd use the code given in the API documentation to achieve this. Thanks, Bret --~--~-~--~~~---~--~~ 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: Searching a ForeignKey
On 12/5/06, Bret Walker <[EMAIL PROTECTED]> wrote: > > > Is there a way to search a CharField contained in a ForeignKey? Yes. You can traverse any foreign key or m2m relation in Django's query language. For example: Article.objects.filter(author__firstname='Bret') would retrieve all article objects that have a related author with a first name of 'Bret'. The double underscore notation is used to describe how you want to traverse relations; the underlying table joins (if required) will be automatically constructed by Django. More detail here: http://www.djangoproject.com/documentation/db_api/ 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: Admin 404s on users
Are you saying you broke your model? Mine validate. Or am I misunderstanding? --~--~-~--~~~---~--~~ 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
I had a similar problem the other day. I had made a mistake on one of my fields of another model, which was edited inline via the User Model. MerMer [EMAIL PROTECTED] wrote: > I just know there's a simple explanation for this, but my brain is > fried. > > My admin area decided today it was going to start throwing a 404 error > for every user. > > When I go to the admin, under "Auth" and click "users" all is well. I'm > presented with a list of users. > > When I try to click one of the users - any of the users - it 404s. Even > if I click on my own user name. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic includes in template?
Will do. Thanks, Matthew On Dec 4, 9:57 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 12/4/06, matthew <[EMAIL PROTECTED]> wrote: > > > This is the bit that's not working (viewsurvey.html): > > {% for question in questions %} > > {% include 'questions/' + question.get_type_display() + '.html' %} > > {% endfor %} > > > Why can't I concatenate the strings and variable to include the > > relevant template?The Django template language does not support arbitrary > > Python > expressions; only the tags and syntax defined in the template > documentation are allowed. Your best bet here is probably to write a > template tag (the inclusion_tag shortcut is probably exactly the sort > of thing you want here). > > -- > "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 -~--~~~~--~~--~--~---
get_FOO_display and grouped data
Hi, I have a model with an integer field that uses choices for display names: class Task(models.Model): PRIORITY_CHOICES = ( ('0', 'Low'), ('1', 'Normal'), ('2', 'High') ) priority = models.IntegerField(choices=PRIORITY_CHOICES) In my view, I'm grouping the data on the priority: {% regroup feature.task_set.all|dictsortreversed:"priority" by priority as grouped %} {% for group in grouped %} {{ group.grouper }} However, when I do this, group.grouper expands to "0" or "2", not "Low" or High". How can I get the display name for this field? 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 -~--~~~~--~~--~--~---
Searching a ForeignKey
Is there a way to search a CharField contained in a ForeignKey? If one wants to use a foreign key to prevent repetition and duplication of data, wouldn't it only make sense that the foreign key's fields be searchable, as well? Otherwise, the only way to find records based on the foreign key would be to sort or write a custom interface. Thanks, Bret --~--~-~--~~~---~--~~ 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
It doesn't give me anything to go on: Page not found (404) Request Method: GET Request URL:http://gretschpages.com/admin/auth/user/1/ You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page. --~--~-~--~~~---~--~~ 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
On 12/4/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > When I go to the admin, under "Auth" and click "users" all is well. I'm > presented with a list of users. > > When I try to click one of the users - any of the users - it 404s. Even > if I click on my own user name. Try setting DEBUG=True and reading the 404 error page. 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: Dynamic includes in template?
On 12/4/06, matthew <[EMAIL PROTECTED]> wrote: > This is the bit that's not working (viewsurvey.html): > {% for question in questions %} > {% include 'questions/' + question.get_type_display() + '.html' %} > {% endfor %} > > Why can't I concatenate the strings and variable to include the > relevant template? The Django template language does not support arbitrary Python expressions; only the tags and syntax defined in the template documentation are allowed. Your best bet here is probably to write a template tag (the inclusion_tag shortcut is probably exactly the sort of thing you want here). -- "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 -~--~~~~--~~--~--~---
Dynamic includes in template?
Hi, Looking at the documentation, I see that you can do "include template_name" or "include 'template.html'". I'd like to combine these - concatenating a couple of strings and a variable to make the template name - but it's not working (no error, but no template included). This template displays a survey. Each survey question has a 'type' attribute with several choices defined in the model ("multiplechoice","matrix","ranking" etc). I'd like to loop through the list of questions and render each question using the appropriate template, which is determined by the type of question. So for example a 'multiplechoice' question corresponds to the 'questions/multiplechoice.html' template. This is the bit that's not working (viewsurvey.html): {% for question in questions %} {% include 'questions/' + question.get_type_display() + '.html' %} {% endfor %} Why can't I concatenate the strings and variable to include the relevant template? The model looks like this: class Question(models.Model): Types = ((0,"TrueFalse"), (1,"MultipleChoice")) type = models.IntegerField(choices=Types) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
graceful shopping cart questions
I downloaded and looked at the django-cart code and noted the views go cart = request.session.get('cart', None) or Cart() how can thre session pickle the cart and be accurate if it's stored in the database or am I confuised? is Django smart enough to know how that should work and retrive the new information etc? Feel free to make any comments. Would it be possible to make a list in the session that stores lists of items and quantities by reference to the item in the database? --~--~-~--~~~---~--~~ 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: Pagination variable problem with generic list and limited queryset
On Dec 3, 8:36 pm, "Silas" <[EMAIL PROTECTED]> wrote: > I have a problem with generic.list_detail.object_list, a limiting > queryset, and pagination variables. > > For some reason when I use the code below, results are restricted to > the sliced 100, but all the pagination variables show results as if the > slice wasn't there. > I don't have a solution, but I can explain the reason for this behaviour. - The ObjectPaginator uses the QuerySet.count() method in deriving the 'hits' count that is then used in all its paging calculations - The QuerySet.count() method does not take into account the slice offset and limit I suppose you could file this as a bug in ObjectPaginator -- if it were to base its hits on len(QuerySet), that would solve this problem. Not sure if there would be a performance issue from len() evaluating the QuerySet. --~--~-~--~~~---~--~~ 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: no-database models?
[EMAIL PROTECTED] wrote: > Russ, > > Because it seems like the cleanest way of pulling together a wide > variety of content that all pertains to a particular day, or list of > days. I would have used an "event" rather than a "day" to model this. You can still (sensibly imo) argue that these are different things that have time series relation and not the same thing that happens repeatedly. > The alternative, it seems to me, is running seperate queries on > Concerts, Meetings, DrinkSpecials, BallGames, etc., then passing all of > those to the template. And things get stickier still if I'm talking > about several days. If I could employ a one-to-many relationship > between the Day instance and all these other models, that's just one > queryset, and it's easier to slice and sort. event ... date type: fk event_type meta : one to many event_type: ... event_meta: ... event: fk event or you could use a generic table. They might give you relational heartburn, but they're designed for applying a relation to varying types (or disjoint types that wouldn't naturally have a common superclass) . The canonical usecase in django are applying comments to any model, or for tagging. If you like how the comment api works, they might be for you. cheers Bill --~--~-~--~~~---~--~~ 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 404s on users
I just know there's a simple explanation for this, but my brain is fried. My admin area decided today it was going to start throwing a 404 error for every user. When I go to the admin, under "Auth" and click "users" all is well. I'm presented with a list of users. When I try to click one of the users - any of the users - it 404s. Even if I click on my own user name. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Highload website database architecture
The postgres mailing list or IRC channel would generally be better, but here's some numbers that I got from last year's OSCON in Portland, OR from the Postgres geeks there. For a 2Gb RAM machine, a good starting rule of thumb: shared_buffers = 25000 work_mem = 16384 maintenance_work_mem = 16384 effective_cache_size = 82500 Those are just magic numbers I had in my notebook from that session, but maybe they'll be useful for you. -joe On 12/1/06, a <[EMAIL PROTECTED]> wrote: > > > Hi, > > I am building a web app backed by database postgresql and currently the > site is under a humongous torrent of hits. I have a question regarding > the database backend config. > > The database folder has a file called postgresql.cons where we can > specify no of active connections to the database -N which is currently > 1024 and also specify the shared buffers. Is there any thumbrule in > deciding the -N and also the no of shared buffers for my config of 4 > frontend servers and 1 database backend server. There is no global or > memcached mechanisms in use. > > Any pointers would be greatly appreciated. > > Thanx > a > > > > > --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Global Error Handeling and Strange Authentication issues
We have two problems that are similar, but would like handled in two different ways. I have been using django for a few months modifying and adding to an existing app and have a pretty good feel for how most of the framework fits together, but some parts still baffle me, like error handling (even after reading some of the django source) The first thing that I would like to do is something special when an error comes up (all except security errors, i would like to handle those differently, but it may fall along the same lines.) Right now when you are in debug mode, it takes over the entire screen with the wonderful traceback and other debugging info. This is great, except I loose all of my navigation framework. How can I get that wonderful traceback info without losing navigation? I use no frames for the navigation, they are part of the base templates. If I had access to the html of the error page, i would likely strip out the and tags and put it into my own error template that just populates the content block. Part two of this first problems (which I will probably be able to do more easily once i determine the first part) is to when not in debug mode (we could even create our own unique variable to use to determine this), but basically when we are in production mode, we want that entire traceback page, but not in a way a user can understand it. Something simple they can either download and save and send to use, or copy and paste into an e-mail address to us. I might just base64 it would be good enough and then do the reverse on our side to see what their problem was. We might also include some extra debugging information to try and tell what they were doing right before this (we have a bread crumb system already in place we can pull from) to help us debug the problem. Problem two is when clicking on some objects that should not have been shown (We are going to fix the show/not show part that are obvious, but there may be more subtle errors that are harder to catch). Anyway, the clickable link is there, but instead of raising a security traceback, it will do one of two things. 1. Send the user back to the logon page with no reason why they were sent there. They are then confused because typing in their correct username and password will send them right back here because /?next=problem/security/page. Oh, and they are actually still logged in because if you click back, or go to a page they have access to, all is good. 2. A page that just displays something like "you are not allowed to do that" (can't remember the exact wording) This is just about as bad since they have no opportunity to log it, they can use the back button, like they could above, but they also lose the navigation framework. For these errors, I am hoping to have a spot in the base template that can display an errors and basically send the user back to the page where they had the ability to click/post to the problem page and display and error on that page that doing that again will cause a security error with as much info as I can display to help them in that situation. I know about the process_exception middleware method, but it only handles view exceptions, not the selection of URLs or security problems. It looks like security errors are even swallowed by the URL handling code so I don't have any control. I could be misreading the code. Anyone have any ideas how I can solve even one of these problems? 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 -~--~~~~--~~--~--~---
using a global login form
Hello, I'm having the same problem as this thread: http://groups-beta.google.com/group/django-users/browse_thread/thread/b711b5c4579535c8/ Where to call set_test_cookie? Since a POST to authenticate can come from any page, I need to call set_test_cookie on any page. I'm using the django.contrib.auth.views.login, a pretty basic login setup. Where is the appropriate place for this or is there a better way? I figure I could stick it in one of my context processor functions but want to avoid the hack if possible. Thanks for your tips, -- Milan --~--~-~--~~~---~--~~ 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: Simple CAS 1.0 authentication
tonemcd wrote: > Again, thanks heaps for making this available - it's done the business > for me! Tone, Awesome! Glad it worked. :) Brian --~--~-~--~~~---~--~~ 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: Validation 3 steep complicate form
You may want to check out django.newforms which is going to be the replacement for forms and manipulators. According to a recent threads in the development forum it is already being used by in some production environments. The formal documentation is sparse but there is alot of detail in the code base under tests/regressiontests/forms/tests.py. 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM
> > > Talking through my hat?No, I think not -- I think that syntax > > (``queryset.groupby(field).max()``) > actually looks like the best proposal for aggregates I've seen thus far... > Sounds pretty good to me. Besides the usual min, max and such, I also like: queryset.groupby(field).stats() which would return a tuple with (min, max, average, stddev) for the specified field. > I'm taking this to django-dev for more discussion; it'll get seen by more the > right people there. > > Thoughts, anyone? > Add "improving aggregate support" to the Django Sprint planning for PyCon. I plan to participate and am willing to coordinate a team to do that. Hopefully that will encourage people to spend some time on the design ahead of time. I also promise to spend a day or two over the holidays looking over the design proposals and adding my thoughts. --~--~-~--~~~---~--~~ 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: Validation 3 steep complicate form
Hi, On 12/3/06, GvaderTh <[EMAIL PROTECTED]> wrote: > > Hello All. I read django documentation about forms, had seek internet > and didn't found solution for situation like this: I have order form > divided to 3 steeps, after every step should be validation and if > validation is succesfull, user can fill form for next-step. Form for > every step doesn't map to database table, or object, I think that only > filled succesfully 3 step, the result will be a new object. What is the > best way to do this? At the beggining I thought that after every step, > value after validation I will hold in session and at the end I made > final object. But for now I don't know how to write template for this > task, and how to do validation for this. Any help? Please > Thanks > G. > Since the first two forms doesn't map to a database object, you will need to create custom forms and manipulators. Take a look at: http://www.djangoproject.com/documentation/forms/#custom-forms-and-manipulators Although, the way to create and use custom forms is going to change soon. Just be aware of that. You can create three views, one for each step. In the first view, create a custom manipulator to handle and validate the data that is entered in that first view. If the data is correct, use sessions to store a flag that indicates that the user has entered the information correctly and redirect him to the next view. In the next view you would then check in the session that the flag for the previous view is set. If you will later need the supplied information then store it in the session too, do not use hidden fields to carry it over different views. Sessions documentation: http://www.djangoproject.com/documentation/sessions/ Regards, Jorge --~--~-~--~~~---~--~~ 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: Setting checkbox to check as default value
Hi Jeff, On 12/2/06, jeffhg58 <[EMAIL PROTECTED]> wrote: > I have a custom manipulator and I am trying to set the checkbox default > to checked. > > For example, my field name is: > > forms.CheckboxField(field_name="current"), Pass a 'checked_by_default' argument to the CheckboxField constructor, like this: forms.CheckboxField(field_name="current", checked_by_default=True), Regards, Jorge --~--~-~--~~~---~--~~ 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: Video stream uploading/playing
On 12/4/06, Pythoni <[EMAIL PROTECTED]> wrote: > > Eric, > Thanks a lot.Very good tutorial for me! > L. > Keep in mind that for larger files (I think over 10 megs), FileField causes very high CPU usage during upload. There is a patch somewhere in Trac that changes Django to store the file on disk during the upload, instead of RAM, which is supposed to help quite a bit. 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: Question concerning generic views or date based views in general
On 12/3/06, Oliver Andrich <[EMAIL PROTECTED]> wrote: > Hi, > > I am currently developing a small Django application for my personal use. > Now I like to have a date based archive page, and I thought that this > finally is a good thing to look into generic views. My requirements are, > that I can display the actually database item on the page and in a side bar > a list of years, which link to year based archives, and a list of months in > the current year. From reading the documentation about generic views, I > think I have understood, that I can have either a list of years or a list of > months, but not both. Is this correct? Well, the general operation of a generic view is to grab one "list" of things. Usually this is a list of items in a month, or items in a year, or items in a day, etc. However, you can pass extra information to the generic view with the 'extra_context' Take a look at this: http://awwca.ca/events/ Now, right now, there are no upcoming events, so it only shows all the past events. However, if there were upcoming events, they would be in the 'upcoming_events' variable in the context, passed to the template. You can take a look at the template code here: http://svn.jayparlar.com/website/trunk/awwca/templates/events/event_list.html And you can take a look at the urls.py that populates the context for the template here: http://svn.jayparlar.com/website/trunk/awwca/events/urls.py Also, if you want to have stuff in a sidebar, that's always there (no matter what page you're using), then you'd want something like template tags. Notice that on every page at awwca.ca, the right sidebar stuff is always there, and the information there is dynamic. Look at the "sidebar" div here: http://svn.jayparlar.com/website/trunk/awwca/templates/base.html, and notice that it does things like "{%random_thumbnail%}" and "{% upcoming_events %}" to populate the sidebar. > And besides generic views, I can also create the view myself. Is there a way > to select the years with entries from the database using the ORM? I can of > course use SQL, but I want to stick to the ORM and I want to learn a little > more about it, besides the basics I have used so far. Yep, the ORM can completely handle that. Check out the urls.py I pointed out above to see how I select upcoming events from the database, namely: def get_upcoming(): return Event.objects.filter(end_date__gte=datetime.now()).order_by('end_date') If you don't understand what's going on there, you'll need to read the documentation more. Hope this helps, 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: using manipulators without defining fields again
Milan Andric wrote: > I have a long application form for a workshop (name, employment, > resume, ... 65 fields). The user logs in to the site via > django.contrib.auth.view.login, standard django fare. Then the user is > allowed to apply for workshop xyz. If the user clicks save but does > not complete the form, errors are shown and the user gets a message > explaining the incomplete state of the form, but the form data is also > saved in the database, just flagged with complete = 0. Only when the > form validates does Application.complete field get set to 1 so > reviewers know to look at it. I think you don't even have to hack a manipulator... You just define all needed validators and then in a view you can do this: # get data and errors data = request.POST.copy() errors = manipulator.get_validation_errors(data) manipulator.do_html2python(data) # save data regardless of errors object = manipulator.save(data) # show results to a user if errors: object.complete = False object.save() else: return HttpResponseRedirect(...) > What other problems might I run into by disregarding > manipulator.get_validation_errors and saving anyway? This approach doesn't distinct between absent data (which is ok) and broken data (which is not). I could think of such a hack: you get standard validation errors then set all fields in the manipulator as not required and get validation errors one more time. This way you will get only critical errors: errors = manipulator.get_validation_errors(data) for field in manipulator.fields: field.is_required = False critical_errors = manipulator.get_validation_errors(data) --~--~-~--~~~---~--~~ 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: Video stream uploading/playing
Eric, Thanks a lot.Very good tutorial for me! L. --~--~-~--~~~---~--~~ 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM
On 12/4/06 5:57 AM, John Lenton wrote: > The "max", "min" and other such functions might be a little more > problematic, unless groupby returned, rather than a generic iterator, > a special "queryset group" and give _it_ the max/min/etc methods. This > way it would be clear that max() returns a tuple (value, queryset) (to > me, at least...). Also, ...groupby('foo').max() would return the same > result as max(...groupby('foo')), but less efficiently. > > Talking through my hat? No, I think not -- I think that syntax (``queryset.groupby(field).max()``) actually looks like the best proposal for aggregates I've seen thus far... I'm taking this to django-dev for more discussion; it'll get seen by more the right people there. Thoughts, anyone? 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: Fast fcgi on dreamhost --> shauwn of the dead, help me shoot zombies
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: > coulix napisał(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: Session problems
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 --~--~-~--~~~---~--~~ 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: Run your Django app with the CherryPy server
Congrats! Very good idea! Regards. Marcus On 12/3/06, Loïc (titoo) <[EMAIL PROTECTED]> wrote: > > Hello, > > For interested people, I have wrapped the WSGI CherryPy server to be > used with Django. With the same wrapper you can start several django > projects (one cherrypy instance per project) with a configuration file > for each project. You can ask it to serve the Django admin media files > or not, it can run as daemon or not. An example of /etc/init.d start > script is given. > > Download: http://xhtml.net/scripts/Django-CherryPy-server-DjangoCerise > > For a small historical presentation. I wanted a low memory > footprint/low CPU approach because my sever is a small fanless system. > So I contacted David Pratt[1], but he saddly had not the time to > maintain his stuff for a broad use. So I went to do it myself. When > CherryPy announced that they had renamed their WSGI server > implementation to be easier to use it, I motivate myself to "release" > my script with this updated version. > > Enjoy! And of course, feedback is welcome. > > Loïc d'Anterroches > > PS: It powers http://www.equilibreforet.fr/carnet/ behind NGINX. > > [1] > http://groups.google.com/group/django-developers/browse_thread/thread/7037d0dc1f9354df/bff630d839fad7a5#bff630d839fad7a5 > > > > > -- Marcus Mendes "A coragem é a forma de todas as virtudes em ponto de prova" C.S.Lewis __ linuxUser #311365 phones : 55 31 3495-6403 or 55 31 8801-3304 jabber : [EMAIL PROTECTED] // msn: [EMAIL PROTECTED] blog: mvmendes.wordpress.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: DB Syncing Models
Hello, This may be what you're looking for: python manage.py reset [appname] Which will regenerate all your application's tables with your new changes. Be warned, though, that command will delete all the existing rows in each table. Good luck, Darin On Dec 3, 2006, at 2:09 PM, marksibly wrote: > > Hi, > > What's the 'right' way to update the database when you change a model? > For example, when you add a new field? > > I initially thought 'manage.py syncdb' would detect and handle this > for > you, but it doesn't appear to. > > Currently, I'm using MySql to 'DROP TABLE' and then using 'manage.py > syncdb' again, but this seems a bit cumbersome. > > Bye! > Mark > > > > --~--~-~--~~~---~--~~ 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: Video stream uploading/playing
I found this. See if it is what you are looking for. http://blog.go4teams.com/archives/video-blogging-using-django-and-flashtm-video-flv/56 On Dec 2, 4:36 am, "Pythoni" <[EMAIL PROTECTED]> wrote: > Hi, > Has anyone thought /successfully implemented video stream (or movie) > uploading/playing feature on a website powered by Django? > > L. --~--~-~--~~~---~--~~ 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: Video stream or movie
I found this. See if it is what you are looking for. On Dec 2, 4:35 am, "Pythoni" <[EMAIL PROTECTED]> wrote: > Hi, > Has anyone thought /successfully implemented video stream (or movie) > uploading/playing feature on a website powered by Django? > > L. --~--~-~--~~~---~--~~ 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: no-database models?
[EMAIL PROTECTED] wrote: > We're driving right past each other on the information > superhighway. > Thanks for your advice, Russ. It still seems to me that a > many-to-many relationship between days and events would be desirable, > for the same reasons that all many-to-many relationships are desirable. > > In my case, I don't want to record minutes at a particular meeting > (for example) -- I just want to be able to publish the fact that the > meeting is happening tonight, as it does every third Saturday at 7 p.m. > For my purposes, it seems very unDRY to have to put a new record in the > database every time that third Saturday rolls around. > > Very best, > > Hank Sims Hank, I'm a little confused. Your example uses a ForeignKey to relate Meeting to MyDay but above you say you'd like a many-to-many relationship. Have you tried: class MyDay: def __init__(self, date): self.id = date.toordinal() self.date = date class Concert(models.Model): title = models.CharField(maxlength=50) description = models.CharField(maxlength=50) date = models.ManyToManyField(MyDay) class Meeting(models.Model): title = models.CharField(maxlength=50) description = models.CharField(maxlength=50) date = models.ManyToManyField(MyDay) Which *should* allow this in your templates: {% for concert in myday.concert_set %} {{ concert.title}} {{ concert.description }} {% endfor %} {% for meeting in myday.meeting_set %} {{ meeting.title}} {{ meeting.description }} {% endfor %} Or maybe I'm misunderstanding what you are trying to do? BTW, here is more info on M2M's: http://www.djangoproject.com/documentation/models/many_to_many/ -Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Apache ErrorDocument Question.
Thanks Waylan but... It appears that when I configure Apache to limit the request body, if a file is uploaded that exceeds the setting, Apache doesn't seem to pass on anything to mod_python and records an error in error.log. Thus the view never gets called so there is no opportunity to raise the error in the view. It seems that mod_python interferes with the mechanism that Apache uses when one configures the ErrorDocument setting. The user gets a message from the browser saying that the connection was dropped. Does anyone know how to get hold of this error message so that a *nice* message can be sent to the user? Are there any other options? --~--~-~--~~~---~--~~ 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: Apache ErrorDocument Question.
Thanks Waylan but... It appears that when I configure Apache to limit the request body, if a file is uploaded that exceeds the setting, Apache doesn't seem to pass on anything to mod_python and records an error in error.log. Thus the view never gets called so there is no opportunity to raise the error in the view. It seems that mod_python interferes with the mechanism that Apache uses when one configures the ErrorDocument setting. The user gets a message from the browser saying that the connection was dropped. Does anyone know how to get hold of this error message so that a *nice* message can be sent to the user? Are there any other options? --~--~-~--~~~---~--~~ 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: i18n & server_name
Ivan Sagalaev wrote: > Another way is to use 'sites' app and keep domain in a table separately > for each site. I thought about that, but this solution is not flexible as 'HTTP_HOST' variable - I need to add all hosts I want to use. --~--~-~--~~~---~--~~ 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: Suggestion: Aggregate/Grouping/Calculated methods in Django ORM
On 12/1/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: > > One way to think about the problem is to consider how you would write > the documentation for it. "Django implements an object based SQL > wrapper... except for the aggregations stuff, which you will need to > know SQL to use properly". If the documentation sounds like it will be > ugly, so is the implementation :-) > > So; lots to think about, but don't let that discourage you. As this > thread has shown, there is plenty of interest in having aggregates - > the discussion will probably be long, but if we can get something > productive out of it, Django will be all the better for it. Me myself, I think that the "group by" functionality isn't a problem; if you look at how itertools.groupby works, it would be both easy and natural (ie pythonic) to give querysets a groupby function with similar semantics and laziness. The "max", "min" and other such functions might be a little more problematic, unless groupby returned, rather than a generic iterator, a special "queryset group" and give _it_ the max/min/etc methods. This way it would be clear that max() returns a tuple (value, queryset) (to me, at least...). Also, ...groupby('foo').max() would return the same result as max(...groupby('foo')), but less efficiently. Talking through my hat? -- 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: High Load
[EMAIL PROTECTED] wrote: > We are running lighttpd with fastcgi in prefork mode. We tried using > threaded but django spits out an error about a weakly-referenced > object, related to sessions I believe, no longer existing. it's not related to this, by any chance: http://wolfram.kriesing.de/blog/index.php/2006/multithreading-with-mysqldb-and-weakrefs --~--~-~--~~~---~--~~ 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
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. so make sure that the (pagename, chunkname) combination is unique. why make things harder than they have to be ? --~--~-~--~~~---~--~~ 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
What web server are you using in development ? I suspect this might be a lighttpd / fastcgi problem. Have you tried Apache / mod_python ? Just as a reference I'm managing 90,000+ hits a day on one Apache on a UML virtual server, with the load rarely going above 2. With you setup and Django you should be able to take on the world :-) --~--~-~--~~~---~--~~ 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: Re: Singleton model instance
On 12/4/06, Phil Powell <[EMAIL PROTECTED]> wrote: > 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. So don't ever create more than one instance of it ;) Regardless of feelings about the Singleton pattern (I'm not a fan), though, this isn't really something that will have a clean solution in Django, if it has a solution at all; because Django model classes map to tables in a relational database, they carry with them the inherent idea of being able to create multiple instances (which would then correspond to multiple rows. You *might* be able to hack something together using one of the various attempts people have made at implementing Singleton in Python [1], but I personally wouldn't recommend it. [1] http://aspn.activestate.com/ASPN/search?query=singleton=0=0=PYTHONCKBK=Subsection -- "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: Simple CAS 1.0 authentication
Brian, Just a quick note to say *thankyou very much* for making this available. I installed it into one of my development sites over the weekend and it works like a charm. I only tried the middleware version (which is probably more appropriate for an authentication backend) and found it to work just fine. In the end, all I had to do to get CAS authentication operational on my site was to change one line in settings.py and two in urls.py (once I'd installed cas into django.contrib). If that doesn't show the power of middleware then I don't know what does ;) Again, thanks heaps for making this available - it's done the business for me! Cheers, Tone --~--~-~--~~~---~--~~ 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
On 04/12/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: > I'm not sure I get how a singleton would solve the "pages generated from > multiple chunks" problem. > > why not just use a model that holds (pagename, chunkname, chunk data) > triplets, and use a view that brings up all the chunks for a given page ? 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: Hiding Referrer URL
As this is handled by the browser - you might want to revert to Javascript. I think there is a plugin for JQuery which handles this. MerMer Siah wrote: > Hi, > > I need to hide referrer url on HttpResponseRedirect. I was expecting to > find something like ReferrerURL in HttpResponseRedirect.headers, but > did not. I was hopping to change the header information right before > HttpResponseRedirect sends the user to the other server to hide the > referrer URL, or even change it to somethings else. > > How can I accomplish that? > > Thanks, > Sia --~--~-~--~~~---~--~~ 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: How to default checkboxfield in customer manipulator
jeffhg58 wrote: > I am trying to set the checkboxfield default value to checked but not > sure how you do it. > > Here is my formfield for the checkbox > > forms.CheckboxField(field_name="current"), > > I tried ading checked="checked" but that did not work. It's a bit non-obvious... The actual data to display is provided by a method called `flatten_data` that is then used to create a form like this: data = manipulator.flatten_data() form = FormWrapper(manipulator, data, errors) (This is how generic views work and how custom views should be written). So you have to provide this method in your manipulator returning a dict with prefilled values: def flatten_data(self): return { 'current': True, } --~--~-~--~~~---~--~~ 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
Phil Powell wrote: > I want to have a series of pages, with certain areas of content which > are editable. I don't want to use flatpages, as I'd like the editable > content to be broken down into chunks, rather than one big lump of > content. > > Is there a way to easily set a model to have one singleton instance? > I've thought about adding some pre-save code to check and only allow > for one instance, but wondered if there was a more graceful way to do > this? I'm not sure I get how a singleton would solve the "pages generated from multiple chunks" problem. why not just use a model that holds (pagename, chunkname, chunk data) triplets, and use a view that brings up all the chunks for a given page ? --~--~-~--~~~---~--~~ 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: i18n & server_name
Alexander Solovyov wrote: > Sorry, I found answer - META['HTTP_HOST']. :) Documentation keeps > silence about this. :( Another way is to use 'sites' app and keep domain in a table separately for each site. --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Singleton model instance
Hi all, Apologies if this has been asked on the list before, but a search didn't throw up anything relevant. I want to have a series of pages, with certain areas of content which are editable. I don't want to use flatpages, as I'd like the editable content to be broken down into chunks, rather than one big lump of content. Is there a way to easily set a model to have one singleton instance? I've thought about adding some pre-save code to check and only allow for one instance, but wondered if there was a more graceful way to do this? -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: i18n & server_name
On 4 Дек., 10:47, "Alexander Solovyov" <[EMAIL PROTECTED]> wrote: > But I got problem - request.META['SERVER_NAME'] always set in Sorry, I found answer - META['HTTP_HOST']. :) Documentation keeps silence about this. :( --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
i18n & server_name
I'm writing multilanguage app, in which i18n happens when client enters certain domain, like in wikipedia. But I got problem - request.META['SERVER_NAME'] always set in ServerName Apache setting, not in queried domain name (which handled in Apache with ServerAlias *.domain.my). What can I do to resolve this trouble? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---