[highly recommended] Re: display module and template names in templates
Mike Ramirez wrote: > On Monday 10 August 2009 08:47:57 pm Mike Dewhirst wrote: >> If DEBUG is True I would like to include view.__name__ and the template >> filename somewhere in the rendered page. >> >> It would be nice to adjust the {% block title %} so the information >> appears in the top of the browser window-frame so it didn't upset an >> page layout stuff. >> >> Is there a reasonable way to do this? >> >> Thanks for any pointers. >> >> Mike >> > > I use the django debug toolbar for a lot of this info, been awhile since I > used it and I can't remember if the view function name is displayed but you > can be sure the matching view function is called for the url in question, I > usually keep the urls.py open when I'm working on a project/app. Mike - And Rob Hudson if you are listening :) That is a great piece of kit. I have commented out all panels except Header, RequestVars and Template for the time being and that tells me most of what I want to know. I think you're right that having the urls.py open too covers the rest of it. Wonderful :) Thanks Mike > > > http://rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/ > > Mike > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Timezones in Django
On Tue, 2009-08-11 at 00:08 -0400, Vitaly Babiy wrote: > Hey guys, > I am working on an application that needs to be timezone aware. Is > there support for this with in django I can't seem to find anything > except for a few third party packages. i am trying to find something > that is in django core. No. Django encourages the use of third-party applications. The problem in this area is MySQL. They apparently haven't discovered that the world has timezones yet and that any datetime without a timezone is broken, so they don't have a timezone-aware datetime field. Since MySQL is a fully supported database in Django, it makes having a timezone-aware field in core quite a tricky proposition. Not that that will prevent us eventually adding one, but it's not amazingly high priority as writing custom fields is pretty easy these days. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Timezones in Django
Hey guys, I am working on an application that needs to be timezone aware. Is there support for this with in django I can't seem to find anything except for a few third party packages. i am trying to find something that is in django core. Thanks, Vitaly Babiy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How do I show generic relationship items with my generic inline on Django Admin page?
Hi all, I've just finished reading through the docs, and following ubernostrum's blog post about generic inlines. Generic relationships and generic inlines are exactly what I'm looking for. They're working as intended, but is it possible for me to view existing related items when creating a new entry, which is part of the generic relationship, instead of always creating a new one? The blog post I'm referencing is here: http://www.b-list.org/weblog/2008/dec/04/generic-inlines/ For example, I've got RelatedLink setup as a generic relationship with any other model, per the blog post. I've got an Entry model setup using generic inlines to allow me to add new RelatedLinks for this Entry. Am I able to somehow view existing RelatedLinks, though, to select from as part of this collection of RelatedLinks? This would be the general purpose for this type of generic relationship, I'd think. How can I allow the admin page to show me these existing items? Thanks, Ryan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: adding a model to show up in admin
On Mon, 2009-08-10 at 20:43 -0700, zignorp wrote: > Hello, > I just added a model to models.py, > > class Topic (models.Model): > topic = models.CharField(max_length=180, blank=True, null=True) > > def __unicode__(self): > return self.topic > > I can see it in the model that's calling it: > class Film(models.Model): > topic = models.ManyToManyField(Topic, blank=True) > > but I can't see it in the admin. Did you add a call in your admins.py file to register Topic with the admin? Like you will have done for the Film model? Models don't automatically show up in the admin interface. The admin app needs to be told they exist. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: display module and template names in templates
On Monday 10 August 2009 08:47:57 pm Mike Dewhirst wrote: > If DEBUG is True I would like to include view.__name__ and the template > filename somewhere in the rendered page. > > It would be nice to adjust the {% block title %} so the information > appears in the top of the browser window-frame so it didn't upset an > page layout stuff. > > Is there a reasonable way to do this? > > Thanks for any pointers. > > Mike > I use the django debug toolbar for a lot of this info, been awhile since I used it and I can't remember if the view function name is displayed but you can be sure the matching view function is called for the url in question, I usually keep the urls.py open when I'm working on a project/app. http://rob.cogit8.org/blog/2008/Sep/19/introducing-django-debug-toolbar/ Mike -- Why was I born with such contemporaries? -- Oscar Wilde signature.asc Description: This is a digitally signed message part.
display module and template names in templates
If DEBUG is True I would like to include view.__name__ and the template filename somewhere in the rendered page. It would be nice to adjust the {% block title %} so the information appears in the top of the browser window-frame so it didn't upset an page layout stuff. Is there a reasonable way to do this? Thanks for any pointers. Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
adding a model to show up in admin
Hello, I just added a model to models.py, class Topic (models.Model): topic = models.CharField(max_length=180, blank=True, null=True) def __unicode__(self): return self.topic I can see it in the model that's calling it: class Film(models.Model): topic = models.ManyToManyField(Topic, blank=True) but I can't see it in the admin. I can save topics through the console: >> from films.models import Topic >>> p1 = Topic(topic='Arts') >>> p1.save() >>> topic_list = Topic.objects.all() >>> topic_list [] and then see the topic show up in a choice in the film admin, but I still don't see a separate topics admin. I hope this makes sense. These are what they look like when I run sqlall: CREATE TABLE "films_topic" ( "id" integer NOT NULL PRIMARY KEY, "topic" varchar(180) ) CREATE TABLE "films_film_topic" ( "id" integer NOT NULL PRIMARY KEY, "film_id" integer NOT NULL REFERENCES "films_film" ("id"), "topic_id" integer NOT NULL REFERENCES "films_topic" ("id"), UNIQUE ("film_id", "topic_id") ) ; And I can see them in the db. Any help would be greatly appreciated, Thanks, Wendy --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: overriding save()
Thanks Karen! I've been stumped on this for quite a while and really appreciate your help, you're the best. Cheers, J On Aug 10, 5:16 pm, Karen Traceywrote: > On Mon, Aug 10, 2009 at 3:07 PM, neridaj wrote: > > > when I do this it just creates a unix executable file of the same name > > selected from the drop down menu of users, i.e., if a user named > > testuser24 is selected from the user menu and there is a folder named > > testuser24 a unix executable is created named testuser24_. Does this > > have something to do with the instance parameter? > > No, you're not joining in the file name in what you are returning from your > upload_to. Callable upload_to needs to return the full path, so if the user > name part is a directory (folder) then you want to add in the file name > parameter (also passed into your callable) to what you are returning. > > (The added underscore behavior is the way the default storage backend avoids > a newly-uploaded file overwriting an existing one. When it comes time to > write the file to disk, if one with the specified name already exists, an > underscore is added and that name is tried, if that also already exists then > another underscore is added, etc.) > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: imitating a spreadsheet (kind of) with formsets
On Mon, 2009-08-10 at 19:07 -0700, Chris Curvey wrote: > What I want to do is have a series of forms, all next to each other in > table format, like this: > > Car Honda Toyota Chevy > Price $12,000$14,000 $10,000 > MPG 30 2826 > Color Blue Red Yellow > > (I'm sure that's going to look like crap in a proportional font.) But > the point is that Car, Price, MPG and Color are all labels, and > everything else (Honda, $12,000, 30, Blue, etc) is a form field. > > I can create the formset and use as_table() to get the forms > generated, but I seem to either get the label repeated for every form, > or not at all. Can someone point me in a direction to get the form > labels listed only once? At some point, when you're doing highly customised form layout, you have to switch from using the convenience methods for the simple cases and attend to all the little details yourself. This means laying out each form element appropriately. Maybe you write a template tag to do that, or maybe you can do it with some for-loops in the form. But as_table() and friends aren't designed for this kind of thing. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
imitating a spreadsheet (kind of) with formsets
What I want to do is have a series of forms, all next to each other in table format, like this: Car Honda Toyota Chevy Price $12,000$14,000 $10,000 MPG 30 2826 Color Blue Red Yellow (I'm sure that's going to look like crap in a proportional font.) But the point is that Car, Price, MPG and Color are all labels, and everything else (Honda, $12,000, 30, Blue, etc) is a form field. I can create the formset and use as_table() to get the forms generated, but I seem to either get the label repeated for every form, or not at all. Can someone point me in a direction to get the form labels listed only once? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dumping Large Databases
On Mon, 2009-08-10 at 17:02 -0700, Chris wrote: > I'm trying to dump a 3GB MySQL database using manage.py dumpdata, but > it's getting killed after 2 hours. Is there any way to get it to use > less memory/cpu so it doesn't get killed and completes the dump? Is there some particular reason you need to use dumpdata for this? At some point, using the database's native tools is going to be a lot more efficient and robust. Dumpdata is great for the sweet spot, but it isn't designed to completely replace all existing database tools. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple application instances?
On Mon, 2009-08-10 at 12:20 -0700, Andrin Riiet wrote: > In the django documentation -> URL dispatcher -> Defining URL > namespaces it reads "When you need to deploy multiple instances of a > single application, it can be helpful to be able to differentiate > between instances" > > I am unable to find any kind of documentation on how to "deploy > multiple instances of a single application". > > So how can I have multiple instances of one application? Have a look at how the admin application works. It isn't trivial to create an application that can be deployed multiple times, but fortunately, it's also not required very often. The admin is an example and I can think of a few other situations it might be required for, but generally you'll find that the same application instance can be used to handle things. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Passing optional URL params to reverse() function
On Mon, 2009-08-10 at 11:28 -0700, nabucosound wrote: > Hi all: > > I have a URLconf url entry like this: > > > url( > regex=r'^(?P\w+)/(?P[-\w]+)/$', > view='show_post', > name='show_post', > kwargs={'msg': None}, > ), > > > and I want to call it with HttpResponseRedirect and reverse(): > > > filters = {'category': post.category.name, 'slug': post.slug} > return HttpResponseRedirect(reverse('show_post', kwargs=filters)) > > > but I am getting this error: > > > NoReverseMatch at /commentposted/first-post/ > > Reverse for 'show_post' with arguments '()' and keyword arguments > '{'category': u'django', 'msg': 'Your comment has been posted', > 'slug': u'first-post'}' not found. > [...] > Is there any way to pass th reverse() function extra optional > parameters that the url define? Or am I crazy? No, you can't do that. By the way, the extra arguments you are passing in aren't *optional* -- they are simply not required. There is not situation in which they will be used to construct the URL. You can only pass in parameters that are present in the URL pattern. There are a bunch of technical reasons for this (including handling optional arguments and precise error reporting), so it's not an arbitrary decision. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: looping over forms in a formset
On Mon, 2009-08-10 at 08:59 -0700, bnl wrote: > hi folks > > I have a formset, which I want to display using a customised template > for the forms. > > This works: > > {{formset.mangement_form}} > {% for form in formset.forms %} > {{form}} > {% endfor %} > > The following displays ok, let's me edit one form, but then I can't > update it or add another, failling with a muMultiValueDictKeyError > at > "Key 'form-0-id' not found in 1.0 blew up with a keyerror). > > {{formset.management_forms}} > {% for form in formset.forms %} > {{form.title.errors}}{{form.title}} > etc looping over the fields in a nice way ... > {% endfor %} > > Looking at the posted form in an editor, I see the following (with > django 1.0) in the form that works: > > and > > in the one that doesn't. Since the one that doesn't work doesn't have any value associated with it, it won't be submitted as a form element (which is why you are not seeing it as a key in the form data). In other words, it's being rendered incorrectly. So it's working fine, given what is being rendered. > > Any idea what I'm doing wrong? need to do? The details are hidden in the line you have written as "looping over the fields in a nice way". Construct a small self-contained example of a form and formset class and show exactly how you are attempting to display the form fields and we might have some chance of spotting the problem. Work hard on removing every detail that isn't necessary -- removing form elements and formset details as much as possible until the error disappears. Ideally, you'll end up with a form with only one field and it will become apparent what the problem is. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: syncdb with ForeignKey to_field outputs statements in wrong order
On Mon, Aug 10, 2009 at 3:52 PM, physicsnickwrote: > > Hello, > > I'm trying to use ForeignKey on a specific indexed column using the > to_field attribute. Unfortunately syncdb seems to be outputting the > ADD CONSTRAINT statement before the CREATE INDEX on the to_field, so > mysql refuses to add the constraint and syncdb quits with an > exception. > > Here's a simple example: > > > from django.db import models > > class Author(models.Model): >code = models.CharField(max_length=10, db_index=True) >first_name = models.CharField(max_length=30) >last_name = models.CharField(max_length=40) > > class Book(models.Model): >title = models.CharField(max_length=100) >author = models.ForeignKey(Author, to_field='code') > > > Here, the Author class has an indexed 'code' column, a short > alphanumeric string that identifies it; we want the Book's foreign key > to use this rather than the numeric id. > > This is the output of "./manage.py sqlall books" using MySQL with > InnoDB default tables: > > > BEGIN; > CREATE TABLE `books_author` ( >`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, >`code` varchar(10) NOT NULL, >`first_name` varchar(30) NOT NULL, >`last_name` varchar(40) NOT NULL > ) > ; > CREATE TABLE `books_book` ( >`id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, >`title` varchar(100) NOT NULL, >`author_id` varchar(10) NOT NULL > ) > ; > ALTER TABLE `books_book` ADD CONSTRAINT `author_id_refs_code_36b0cc23` > FOREIGN KEY (`author_id`) REFERENCES `books_author` (`code`); > CREATE INDEX `books_author_code` ON `books_author` (`code`); > CREATE INDEX `books_book_author_id` ON `books_book` (`author_id`); > COMMIT; > > > This is not correct. The index on books_author(code) needs to be > created before the foreign key constraint is added, otherwise it will > fail because the target columns of foreign keys need to be indexed. > When I run syncdb, it fails with the following error (which you can > see if you just paste the above sql into a temporary database): > > _mysql_exceptions.OperationalError: (1005, "Can't create table > 'testfk.#sql-12a3_81' (errno: 150)") > > > In my case I need to run syncdb and wait for it to fail, then manually > create the index I need, then run syncdb again (and repeat, since I > have many foreign keys with custom columns). Or I need to not use > syncdb at all, and instead use the sqlall command and reorder the > statements myself. > > Is this a django bug? Am I doing something wrong? > Why are you specifying db_index=True instead of unique=True on these fields that are targets of foreign keys? They need to be unique if the many-to-one nature of ForeignKey is to be maintained. If you use unique=True I do not think you will encounter the problem you are seeing. (I think it is a bug that Django-level validation does not require that the to_field value be a field with unique=True.) Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Question about model and admin
About my problem: there are items (~100) and their prices. We would like store history of prices and analyse it later.. Every week we going add new prices on this items. my model: class Item(models.Model): id = models.AutoField(primary_key=True) name = models.CharField(max_length=200) ... def __unicode__(self): return self.name class UpdateDay(models.Model): day = models.DateField(primary_key=True, auto_now=False, auto_now_add=True) items = models.ManyToManyField(Item, through='Review') ... def __unicode__(self): return u'%s' % (self.day) class Review(models.Model): id = models.AutoField(primary_key=True) item = models.ForeignKey(Item) day = models.ForeignKey(UpdateDay) price = models.DecimalField(max_digits=7, decimal_places=2) ... def __unicode__(self): return self.price my admin.py: ... class ItemInline(admin.TabularInline): model = Review extra = Item.objects.count() class UpdateDayAdmin(admin.ModelAdmin): ... inlines = [ItemInline] class ItemAdmin(admin.ModelAdmin): ... admin.site.register(UpdateDay, UpdateDayAdmin) admin.site.register(Item, ItemAdmin) This is my current model. And this is my question: what i should modify to add this feature: if we'll try add new UpdateDay, system will auto-generate all Review- Item relationships on edit page? In current app we must create this relationships manually (its take a lot of time)... IMHO i should update my ItemInline class.. How?.. or not?.. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Generic view 'archive_year' produces blank HTML page
archive_year doesn't add a list of objects to the context by default. Instead, it adds date_list, a list of months that have objects available in the given year. To add object_list to the context, use the optional argument make_object_list=True when calling archive_year. For more info, look at the docs at http://docs.djangoproject.com/en/dev/ref/generic-views/#django-views-generic-date-based-archive-year Alasdair On Aug 11, 1:27 am, Matthewwrote: > I am using Django's generic views to create a blog site. The > templates I created, entry_archive_day, entry_archive_month, > entry_archive, and entry_detail all work perfectly, but > entry_archive_year does not. > > Instead, it is simply a blank page. It looks like it sees no objects > in 'object_list'. > > I know that 'archive' uses a 'latest' list instead of 'object_list', > but that's not the case with 'archive_year', correct? > > Thanks, > Matthew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
On Aug 11, 9:08 am, Jumpfroggywrote: > On Aug 10, 2:24 pm, dartdog wrote: > > > Big help!! Had just started getting using too much memory notices from > > Webfaction yesterday evening... > > Yeah, I didn't even pay attention till I hit about 120-140MB on my > 80MB plan and got everything turned off. Otherwise I would have just > let it grow, not paying attention. > > > The other item is using the crontab -e command from ssh to comment out > > apps you don't need to have running For some reason could not find > > that when I was looking for it and one of my sites just kept > > restarting after .stop, which I understand but did not know how to > > stop the behavior! > > Good catch! I noticed that they restart themselves, didn't bother > finding out why. > > Here's my complete writeup and > howto:http://forum.webfaction.com/viewtopic.php?pid=11096 > > Thanks to those in this thread for helping me make this work. FWIW, WebFaction is providing mod_wsgi 2.5 now. Got mail from Remi about it today. A few other comments about your post on WebFaction forums. Don't use 'processes=1' with WSGIDaemonProcess directive. The default is one process anyway, and using 'processes' option has side effect of setting wsgi.multiprocess to be true even if there is only one process. Yes, it may seem odd, but it is done that way to allow multiprocess to be flagged as true when using a cluster of machines with only one process on each server. When inactivity timeout expires, Django is technically restarted, it is actually shutdown. Although a new daemon process is started, that process isn't preloaded with anything and so is effectively an empty process. This is why on next request it has to load Django again. That is, lazily loads Django only when known it is required. I now understand what you meant about supervisor process. Though you were talking about separate supervisord application. :-( Only other thing is something I think I said before. That is that MinSpareThreads and MaxSpareThreads only make sense when multiples of ThreadsPerChild. This is because the number of threads in a process is fixed, it will not shutdown or start up threads within a process. These values are there used to govern number of active processes between limits as set down by StartServers and MaxClients/ ThreadsPerChild. In other words, granularity is actually at process level and not thread level. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: overriding save()
On Mon, Aug 10, 2009 at 3:07 PM, neridajwrote: > > when I do this it just creates a unix executable file of the same name > selected from the drop down menu of users, i.e., if a user named > testuser24 is selected from the user menu and there is a folder named > testuser24 a unix executable is created named testuser24_. Does this > have something to do with the instance parameter? > No, you're not joining in the file name in what you are returning from your upload_to. Callable upload_to needs to return the full path, so if the user name part is a directory (folder) then you want to add in the file name parameter (also passed into your callable) to what you are returning. (The added underscore behavior is the way the default storage backend avoids a newly-uploaded file overwriting an existing one. When it comes time to write the file to disk, if one with the specified name already exists, an underscore is added and that name is tried, if that also already exists then another underscore is added, etc.) Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
On Aug 11, 3:11 am, Jumpfroggywrote: > Wow, lots of good feedback here. Thanks! > > On Aug 9, 6:17 pm, Graham Dumpleton > wrote: > > > Replace use of mod_python with mod_wsgi. > > I'm using mod_wsgi for everything already, forgot to say. When I > researched, it seemed like the newer/better way to do django. > > > Ensure you use prefork MPM > > for Apache and delegate Django instances to run in mod_wsgi daemon > > mode process. > > Sorry, meant to say 'worker' rather than 'prefork'. DO NOT USE > > PREFORK. Hmmm, that was a bad stuff up. :-) > > I just started using the worker MPM for one of my apps. It didn't > seem to give any performance or memory savings, since my app is so > small/simple. I'll keep an eye on it for later. In WebFaction model possibly wouldn't as you tend to be running as much as possible in single process anyway to keep within your memory limits. > Using daemon mode gives me auto-reloading by touching the .wsgi file > (yay), but it uses more memory. Instead of supervisor (3MB) and > apache worker/WSGI/Django (16MB) processes, now I have supervisor > (3MB), apache worker (3MB), and wsgi/django (15MB). Not a huge gain, > but just a bit more. I'm willing to live with that for the auto- > reloading benefit, however. Why do you still need supervisor. Certainly not required for mod_wsgi. Am a bit confused. > > Having done that, you can use inactivity-timeout option > > for mod_wsgi daemon processes to have the process restarted and > > returned to low memory footprint idle process after no use for a > > while. > > This is exactly what I wanted!!! It's funny how when I finally read > the description for something, it matches exactly what I'm looking > for. I just didn't know where to look. I just tried it, and yes my > memory baloons up to 16MB, then comes back down later. The only > strange thing is that I set it to 10s (very short) to test out, but it > takes a while for the process to actually be reclaimed. If I put > inactivity-timeout=10, then load the page, then close the browser, > memory usage should be reclaimed in 10 seconds, right? It seems more > like 1 minute wait, which is fine but strange to me. Maybe there's > only polling at certain intervals (checks every 1 minute), so the > resolution isn't that fine. Maybe it's dependent on the deadlock > timeout? Don't know. Nothing to do with deadlock timeout. You should be able to set values less than 1 minute. I wouldn't recommend to short a timeout though as requests by same user within a browsing session are often reasonable time apart. If too short a timeout, then Django gets kicked out between requests and has to be reloaded every time, which would give CGI like performance. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
On Aug 11, 12:25 am, Dj Gilcreasewrote: > On Mon, Aug 10, 2009 at 6:43 AM, Graham > > Dumpleton wrote: > > These values for min and max threads are a bit dubious because you > > have a single process and that will have fixed 25 threads. Usually > > these are defined in multiples of ThreadsPerChild and not less like > > this. Possibly just means the values are ignored. > > The MaxClients (according to the Apache docs is #MaxServers * > #ThreadsPerChild) I just set it explicitly so I remember what it is, > though it is actually ignored It is not ignored. What you are describing is the fallback default behaviour if the directives are not defined. If the directives are defined they will take precedence. I would always add them all explicitly. > >> ThreadsPerChild 25 > >> MaxRequestsPerChild 5000 > > > Don't see much point for MaxRequestsPerChild. > > This just restarts the child after 5k requests, which helps clear out > some memory on occasion (I am still trying to get rrd or something run > on on Webfaction so I can actually map memory usage over time, and > start tuning Apache to my actual usage needs better) But if using daemon mode, MaxRequestsPerChild only applies to the main Apache server child processes. These are only serving up static files, if you aren't getting WebFaction nginx front end to handle them, and the task of proxying to mod_wsgi daemon processes. The processes therefore shouldn't grow memory. FWIW, if you are only running 5 threads in mod_wsgi daemon process and static files handled by nginx front end anyway, you could drop ThreadsPerChild to be a lower value and save more memory in main Apache server child processes as stack memory for extra threads you eliminate would no longer be allocated. Just remember to also drop MaxClients to match if you want to keep it done to a single process maximum, although if you don't I think Apache will complain that calculated maximum servers is greater than ServerLimit. > > If you application does leak Python objects due to inability to break > > reference count cycles, there shouldn't really be a need for maximum > > requests. > > Though my app does no leak, that I have noticed anyways, I figure a > maximum-requests would be good just in case I suddenly get a flood of > traffic, it will restart the daemon even if the hour of idle time has > not passed. The other one I forgot to mention is where specific requests have a large transient memory usage. This will bump out memory usage and once pushed out, doesn't come back. The big danger with using multithreading is where a URL with large transient memory requirement gets hit by multiple requests at the same time. I have been thinking for a while with a feature for mod_wsgi whereby you could using a directive specify a limit as to how many concurrent requests you want to allow to enter a specific URL or some subset of URLs. This would help in limiting such memory usage explosions. The only reason haven't added feature is that it could just as easily be done in WSGI middleware, however, in that case people have to implement it themselves and so more than likely they will not bother. Other than such an ability, only workaround at moment is to use maximum requests to recycle process often. In worst case may want to split application across multiple daemon process groups and delegate memory hungry URLs to daemon process group of their own and recycle that much much more often than bulk of application. Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question about request.user
I tested this again with IE and Firefox. On IE I logined as "peter" and then I logined as "john" on Firefox. Now I checked user in "peter" account with "request.user.username", and I got "john". Can anybody do this test on your machine? Thanks so much. On Aug 10, 2:48 pm, Davidwrote: > Hi Carlos, > > Thanks for your reply. I opened two broswers. I first logined as > "peter" and I left IE there; then I double-clicked IE icon on my > desktop to open a new one. On this new one I logined as "john". > > There is only one user table as I use > "django.contrib.auth.models.User". > > any more ideas? > > On Aug 10, 2:33 pm, "Carlos A. Carnero Delgado" > > > > wrote: > > Hi, > > > On Mon, Aug 10, 2009 at 4:46 PM, David wrote: > > > Why request.user.username did not bind to "john" in this scenario? > > > Anybody knows what caused such a problem? And any ideas how to fix > > > it? > > > Are you using the same web browser? Maybe two tabs? > > > HTH, > > Carlos.- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question about URLs
> If i have a URL such as: > > (r'^(?P\w+)/blog/', include('foo.urls.blog')), > > what are the whats the purpose of the w and the +? i'm having some > problems with 2 of my urls and i think it may have something to do > with this. You'll want to read up on regular expressions. There are a number of good tutorials and books on the subject. In short, in this case the "\w" is "any 'word' character" (usually [a-zA-Z0-9_] and if the regexp is compiled with unicode support, I believe it supports unicode "letter/digit" type characters). Note that this *doesn't* include things like the minus sign, the "@", and a variety of other characters you might wish to include in a username. The "+" is the "one-or-more of the previous atom [the '\w']" repetition operator. So your regexp is "one or more 'word' characters, followed by a slash, followed by the literal 'blog', followed by another slash". Regexps are very powerful, though the regexp-reversing code in Django doesn't gracefully handle some of the more complex cases because it's a non-trivial problem. -tkc --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Generic view 'archive_year' produces blank HTML page
I am using Django's generic views to create a blog site. The templates I created, entry_archive_day, entry_archive_month, entry_archive, and entry_detail all work perfectly, but entry_archive_year does not. Instead, it is simply a blank page. It looks like it sees no objects in 'object_list'. I know that 'archive' uses a 'latest' list instead of 'object_list', but that's not the case with 'archive_year', correct? Thanks, Matthew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-cms-2.0 problem
Okay, that's probably what got both of us. Thanks! On Aug 10, 4:09 pm, Matthias Kestenholzwrote: > On Tue, Aug 11, 2009 at 1:01 AM, odonnell wrote: > > > I'll try starting with the example project this time, maybe something > > in there is different than starting a project with django-admin.py > > startproject. > > The standard django project skeleton does not have > django.core.context_processors.request in its > TEMPLATE_CONTEXT_PROCESSORS list. > > The traceback you sent in the other thread never touches the > django-cms2 code itself. It seems that you overwrote > TEMPLATE_CONTEXT_PROCESSORS with a list containing only the request > context processor, and left out the auth context processor which is > required by the admin interface (it's not the only one that's > required...) > > Matthias > > --http://spinlock.ch/pub/feincms/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-cms-2.0 problem
Thanks, everything works when you start with the sample project. On Aug 10, 3:43 pm, Karl Bowdenwrote: > On Mon, Aug 10, 2009 at 9:22 PM, Rob B (uk) wrote: > > > Trying to get a default install of : > >http://github.com/digi604/django-cms-2.0/ > > up and running on my dev but I'm getting this error when trying to log > > into admin > >http://dpaste.com/77696/ > > > Any ideas? > > Good morning Rob, > > I just got an instance of django-cms-2.0 from git running yesterday. > And I must say I'm quite impressed. > > I did run into a few hiccups on the way, but never say the error you > are receiving. > > I am using Django-1.1 and started with the example project > django-cms-2.0/example/. I needed to disable 'south' and 'reversion' > to be able to run syncdb to a sqlite db and add pages respectively. > > Any more details about your dev platform? > > - Karl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-cms-2.0 problem
On Tue, Aug 11, 2009 at 1:01 AM, odonnellwrote: > > I'll try starting with the example project this time, maybe something > in there is different than starting a project with django-admin.py > startproject. > The standard django project skeleton does not have django.core.context_processors.request in its TEMPLATE_CONTEXT_PROCESSORS list. The traceback you sent in the other thread never touches the django-cms2 code itself. It seems that you overwrote TEMPLATE_CONTEXT_PROCESSORS with a list containing only the request context processor, and left out the auth context processor which is required by the admin interface (it's not the only one that's required...) Matthias -- http://spinlock.ch/pub/feincms/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
On Aug 10, 2:24 pm, dartdogwrote: > Big help!! Had just started getting using too much memory notices from > Webfaction yesterday evening... Yeah, I didn't even pay attention till I hit about 120-140MB on my 80MB plan and got everything turned off. Otherwise I would have just let it grow, not paying attention. > The other item is using the crontab -e command from ssh to comment out > apps you don't need to have running For some reason could not find > that when I was looking for it and one of my sites just kept > restarting after .stop, which I understand but did not know how to > stop the behavior! Good catch! I noticed that they restart themselves, didn't bother finding out why. Here's my complete writeup and howto: http://forum.webfaction.com/viewtopic.php?pid=11096 Thanks to those in this thread for helping me make this work. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django comments honeypot hide
Any reason not to just hide it with CSS? Something like: #honeypotField { display: none; } Assuming that the field's ID is set to "honeypotField"? (Alternatively, if you're not using an external stylesheet, you could use: style = "display: none;" as a property of the item.) Adam On Aug 10, 10:31 am, Alessandro Ronchiwrote: > I need to hide the django-comments honeypot in my comment form, but It's > visible to the user. > > Is there a way to do that in an easy way? > > -- > Alessandro Ronchi > > SOASI > Sviluppo Software e Sistemi Open Sourcehttp://www.soasi.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-cms-2.0 problem
I'll try starting with the example project this time, maybe something in there is different than starting a project with django-admin.py startproject. On Aug 10, 3:43 pm, Karl Bowdenwrote: > On Mon, Aug 10, 2009 at 9:22 PM, Rob B (uk) wrote: > > > Trying to get a default install of : > >http://github.com/digi604/django-cms-2.0/ > > up and running on my dev but I'm getting this error when trying to log > > into admin > >http://dpaste.com/77696/ > > > Any ideas? > > Good morning Rob, > > I just got an instance of django-cms-2.0 from git running yesterday. > And I must say I'm quite impressed. > > I did run into a few hiccups on the way, but never say the error you > are receiving. > > I am using Django-1.1 and started with the example project > django-cms-2.0/example/. I needed to disable 'south' and 'reversion' > to be able to run syncdb to a sqlite db and add pages respectively. > > Any more details about your dev platform? > > - Karl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-cms-2.0 problem
I just had the same problem and I've isolated the issue, sort of. I commented out all the stuff to do with CMS in settings.py and urls.py, except the line "django.core.context_processors.request", in TEMPLATE_CONTEXT_PROCESSORS. The issue still persisted. When I commented that out, too, I was able to access the admin properly, except CMS wasn't available because I commented it out. Maybe this will help someone smart figure this out? On Aug 10, 4:22 am, "Rob B (uk)"wrote: > Trying to get a default install of :http://github.com/digi604/django-cms-2.0/ > up and running on my dev but I'm getting this error when trying to log > into adminhttp://dpaste.com/77696/ > > 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-cms-2.0 problem
Holy shit! I just posted the EXACT SAME PROBLEM two seconds ago. On Aug 10, 3:43 pm, Karl Bowdenwrote: > On Mon, Aug 10, 2009 at 9:22 PM, Rob B (uk) wrote: > > > Trying to get a default install of : > >http://github.com/digi604/django-cms-2.0/ > > up and running on my dev but I'm getting this error when trying to log > > into admin > >http://dpaste.com/77696/ > > > Any ideas? > > Good morning Rob, > > I just got an instance of django-cms-2.0 from git running yesterday. > And I must say I'm quite impressed. > > I did run into a few hiccups on the way, but never say the error you > are receiving. > > I am using Django-1.1 and started with the example project > django-cms-2.0/example/. I needed to disable 'south' and 'reversion' > to be able to run syncdb to a sqlite db and add pages respectively. > > Any more details about your dev platform? > > - Karl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-cms-2.0 problem
On Mon, Aug 10, 2009 at 9:22 PM, Rob B (uk)wrote: > > Trying to get a default install of : > http://github.com/digi604/django-cms-2.0/ > up and running on my dev but I'm getting this error when trying to log > into admin > http://dpaste.com/77696/ > > Any ideas? Good morning Rob, I just got an instance of django-cms-2.0 from git running yesterday. And I must say I'm quite impressed. I did run into a few hiccups on the way, but never say the error you are receiving. I am using Django-1.1 and started with the example project django-cms-2.0/example/. I needed to disable 'south' and 'reversion' to be able to run syncdb to a sqlite db and add pages respectively. Any more details about your dev platform? - Karl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Trouble installing Django-CMS 2
Hello everyone, I'm having quite a lot of pain installing django-cms 2.0, which is available at http://github.com/digi604/django-cms-2.0/tree/master. When I visit /admin/, I get a "TemplateSyntaxError at /admin/" with the subtitle "Caught an exception while rendering: u'user' ." I suck at reading tracebacks, so I was hoping someone could help me figure out what's wrong. The traceback is below. I should clarify that the error is only thrown when you are logged-in. Thanks, Chris Environment: Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.2 pre-alpha SVN-11429 Python Version: 2.5.1 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.admin', 'django.contrib.admindocs', 'cms', 'cms.plugins.text', 'cms.plugins.picture', 'cms.plugins.link', 'cms.plugins.file', 'cms.plugins.snippet', 'cms.plugins.googlemap', 'mptt', 'publisher'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'cms.middleware.page.CurrentPageMiddleware', 'cms.middleware.user.CurrentUserMiddleware') Template error: In template /Library/Python/2.5/site-packages/django/contrib/admin/ templates/admin/index.html, error at line 56 Caught an exception while rendering: u'user' 46 : {% endif %} 47 : 48 : {% endblock %} 49 : 50 : {% block sidebar %} 51 : 52 : 53 : {% trans 'Recent Actions' %} 54 : {% trans 'My Actions' %} 55 : {% load log %} 56 : {% get_admin_log 10 as admin_log for_user user %} 57 : {% if not admin_log %} 58 : {% trans 'None available' %} 59 : {% else %} 60 : 61 : {% for entry in admin_log %} 62 : 63 : {% if entry.is_deletion %} 64 : {{ entry.object_repr }} 65 : {% else %} 66 : {{ entry.object_repr }} Traceback: File "/Library/Python/2.5/site-packages/django/core/handlers/base.py" in get_response 92. response = callback(request, *callback_args, **callback_kwargs) File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py" in wrapper 196. return self.admin_view(view, cacheable)(*args, **kwargs) File "/Library/Python/2.5/site-packages/django/views/decorators/ cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py" in inner 186. return view(request, *args, **kwargs) File "/Library/Python/2.5/site-packages/django/views/decorators/ cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "/Library/Python/2.5/site-packages/django/contrib/admin/sites.py" in index 374. context_instance=context_instance File "/Library/Python/2.5/site-packages/django/shortcuts/__init__.py" in render_to_response 20. return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) File "/Library/Python/2.5/site-packages/django/template/loader.py" in render_to_string 108. return t.render(context_instance) File "/Library/Python/2.5/site-packages/django/template/__init__.py" in render 178. return self.nodelist.render(context) File "/Library/Python/2.5/site-packages/django/template/__init__.py" in render 779. bits.append(self.render_node(node, context)) File "/Library/Python/2.5/site-packages/django/template/debug.py" in render_node 71. result = node.render(context) File "/Library/Python/2.5/site-packages/django/template/ loader_tags.py" in render 97. return compiled_parent.render(context) File "/Library/Python/2.5/site-packages/django/template/__init__.py" in render 178. return self.nodelist.render(context) File "/Library/Python/2.5/site-packages/django/template/__init__.py" in render 779. bits.append(self.render_node(node, context)) File "/Library/Python/2.5/site-packages/django/template/debug.py" in render_node 71. result = node.render(context) File "/Library/Python/2.5/site-packages/django/template/ loader_tags.py" in render 97. return compiled_parent.render(context) File "/Library/Python/2.5/site-packages/django/template/__init__.py" in render 178. return self.nodelist.render(context) File "/Library/Python/2.5/site-packages/django/template/__init__.py" in render 779. bits.append(self.render_node(node, context)) File "/Library/Python/2.5/site-packages/django/template/debug.py" in render_node 71. result = node.render(context) File "/Library/Python/2.5/site-packages/django/template/
Two user authentication systems
I have a budgeting application I created at inzolo.com. I want to create an affiliate program to offer commissions to those who refer paying users to the site. I will basically have a different login and just for affiliates. I'm wondering how to best handle this situation. Can I copy the auth.user module to essentially have another table in the database? I don't know that that is the best solution though. Should I use the existing mod auth and use groups and a one-to-one model for additional user settings? Just wondering if anyone has done something like this and how you solved this issue. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Question about URLs
If i have a URL such as: (r'^(?P\w+)/blog/', include('foo.urls.blog')), what are the whats the purpose of the w and the +? i'm having some problems with 2 of my urls and i think it may have something to do with this. Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: SPAM/FRAUD WARNING: Do NOT open the email with subject "Django enquiry"
David Ross @ Wolfeon wrote: > I received an email a few minutes ago with the subject "Django > enquiry." My email address in relation to django was phished from > djangopeople or the mailing list. Confirmed -- I received the same email, clearly from djangopeople (I registered there as "djangopeople" at the same domain as this email is from, just like this comes from "django.users@" which helps with the spam control). Headers: Return-path:Envelope-to: djangopeo...@[redacted] Delivery-date: Mon, 10 Aug 2009 15:26:24 -0500 Received: from semexpert2.fleetservers.net ([200.85.152.250]) by vesta.site5.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.69) (envelope-from ) id 1MabRm-0003xX-C3 for djangopeo...@[redacted]; Mon, 10 Aug 2009 15:26:24 -0500 Received: from localhost ([127.0.0.1] helo=semexpert2.outmailing.com) by semexpert2.fleetservers.net with esmtpa (Exim 4.67) (envelope-from ) id 1MabUn-0003AJ-2t for djangopeo...@[redacted]; Mon, 10 Aug 2009 17:29:29 -0300 Date: Mon, 10 Aug 2009 17:29:29 -0300 To: djangopeo...@[redacted] From: Lin Yang Subject: Django enquiry Message-ID: X-Priority: 3 X-Mailer: PHPMailer [version 4.0.2] X-Fid: eGZpZC1kamFuZ29wZW9wbGVAdGltLnRoZWNoYXNlcy5jb20tNDY4Mi0xNjc2LTQwNw== MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="b1_afb591b2079ef7fd22db84766e9f11bd" X-Spam-Status: No, score=1.8 X-Spam-Score: 18 X-Spam-Bar: + X-Spam-Flag: NO Amusingly, they can't even competently spam plain-text users: --b1_afb591b2079ef7fd22db84766e9f11bd Content-Type: text/plain; charset = "iso-8859-1" Content-Transfer-Encoding: 8bit This is a message in multipart MIME format. Your mail client should not be displaying this. Consider upgrading your mail client to view this message correctly. The image bug, FWIW, requests from semexpert2.outmailing.com -tkc --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
Brill thanks. Its actaully working! Getting a the IDs with the template: {% for user_set in online_users %} {{ user_set }} {% empty %} To list the usernames instead of the ID will I need to update the view or is there a clever trick with the template? On Aug 10, 11:02 pm, Daniel Rosemanwrote: > On Aug 10, 10:45 pm, "Rob B (uk)" wrote: > > > Im reading through loads of python / django tutorials atm, hopefully > > some of it will stick! > > > I added what you suggested and now I'm getting the error "type object > > 'OnlineUsers' has no attribute 'get_online_user_ids'" > > view -http://dpaste.com/77965/ > > middleware (name OnlineUsers) -http://dpaste.com/77967/ > > What am I doing wrong now? > > > Thanks R > > You've imported get_online_user_ids directly, so you don't in fact > need to use OnlineUsers again to call it - in this case Python think > you're talking about a class method of the OnlineUsers middleware > class which you also import (really it's best to keep class names > different from the modules they live in). > > So you just need to do: > { 'profile_list': Profile.objects.all(), 'online_users': > get_online_user_ids() } > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
On Aug 10, 10:45 pm, "Rob B (uk)"wrote: > Im reading through loads of python / django tutorials atm, hopefully > some of it will stick! > > I added what you suggested and now I'm getting the error "type object > 'OnlineUsers' has no attribute 'get_online_user_ids'" > view -http://dpaste.com/77965/ > middleware (name OnlineUsers) -http://dpaste.com/77967/ > What am I doing wrong now? > > Thanks R You've imported get_online_user_ids directly, so you don't in fact need to use OnlineUsers again to call it - in this case Python think you're talking about a class method of the OnlineUsers middleware class which you also import (really it's best to keep class names different from the modules they live in). So you just need to do: { 'profile_list': Profile.objects.all(), 'online_users': get_online_user_ids() } -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to skip this field?
Great. Thanks Daniel! On Aug 10, 3:04 pm, Daniel Rosemanwrote: > On Aug 10, 10:58 pm, David wrote: > > > > > > > Hello, > > > When I use the following code, > > > > > > > {{ form.as_table }} > > > > > . > > > It prints all form fields with corresponding values on a user's > > monitor. Now that in that form there is a field "username", for some > > reasons I can not show this information to that user even though this > > is his/her username. So, is there any way to skip printing this > > field? > > > Any suggestions? > > > Thanks. > > Use 'exclude' in the form's Meta > class.http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a... > -- > DR.- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
SPAM/FRAUD WARNING: Do NOT open the email with subject "Django enquiry"
I received an email a few minutes ago with the subject "Django enquiry." My email address in relation to django was phished from djangopeople or the mailing list. There is a 1x1 image contained in the email which is possibly used for verifying addresses. Don't take the spam seriously, the domain is not even 2 months old, the contact page lists two addresses, wanting a FT person for Spain, and low pay reek of work fraud. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
syncdb with ForeignKey to_field outputs statements in wrong order
Hello, I'm trying to use ForeignKey on a specific indexed column using the to_field attribute. Unfortunately syncdb seems to be outputting the ADD CONSTRAINT statement before the CREATE INDEX on the to_field, so mysql refuses to add the constraint and syncdb quits with an exception. Here's a simple example: from django.db import models class Author(models.Model): code = models.CharField(max_length=10, db_index=True) first_name = models.CharField(max_length=30) last_name = models.CharField(max_length=40) class Book(models.Model): title = models.CharField(max_length=100) author = models.ForeignKey(Author, to_field='code') Here, the Author class has an indexed 'code' column, a short alphanumeric string that identifies it; we want the Book's foreign key to use this rather than the numeric id. This is the output of "./manage.py sqlall books" using MySQL with InnoDB default tables: BEGIN; CREATE TABLE `books_author` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `code` varchar(10) NOT NULL, `first_name` varchar(30) NOT NULL, `last_name` varchar(40) NOT NULL ) ; CREATE TABLE `books_book` ( `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY, `title` varchar(100) NOT NULL, `author_id` varchar(10) NOT NULL ) ; ALTER TABLE `books_book` ADD CONSTRAINT `author_id_refs_code_36b0cc23` FOREIGN KEY (`author_id`) REFERENCES `books_author` (`code`); CREATE INDEX `books_author_code` ON `books_author` (`code`); CREATE INDEX `books_book_author_id` ON `books_book` (`author_id`); COMMIT; This is not correct. The index on books_author(code) needs to be created before the foreign key constraint is added, otherwise it will fail because the target columns of foreign keys need to be indexed. When I run syncdb, it fails with the following error (which you can see if you just paste the above sql into a temporary database): _mysql_exceptions.OperationalError: (1005, "Can't create table 'testfk.#sql-12a3_81' (errno: 150)") In my case I need to run syncdb and wait for it to fail, then manually create the index I need, then run syncdb again (and repeat, since I have many foreign keys with custom columns). Or I need to not use syncdb at all, and instead use the sqlall command and reorder the statements myself. Is this a django bug? Am I doing something wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
paginator for 0.96?
is there any other examples of how to use the paginator in 0.96 other than this: http://www.djangoproject.com/documentation/0.96/models/pagination/#sample-usage I'm looking more specifically for template side use so I can see how to work it. Thanks in advance, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
FK problem: can it point to an object which hasn't been saved yet?
Hi, I have the following problem: I have a hierarchy of models, each one with a FK pointing to its "father" class. Something like: class Model1(models): data ... class Model2(models): data ... father = models.ForeignKey(Model1) class Model3(models): data ... father = models.ForeignKey(Model2) and so on... I want to load a file with object data, in the file we have all kinds of objects (Model1s, Model2s, etc). When I load it, I want to display all the objects into a form, so the user can modified them before commiting them. How can I correctly display in the form the "father" property if the father doesn't exist in the db?, it only exist like an unsaved model. I tried with something like objModel1 = Model1(data = ...) Model2Form( instance = Model2(data = ... , father = objModel1.id) But the form's select-box for the "father" appears empty. Thanks -- George Laskowsky Ziguilinsky --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Is it possible to skip this field?
On Aug 10, 10:58 pm, Davidwrote: > Hello, > > When I use the following code, > > > > {{ form.as_table }} > > > . > > It prints all form fields with corresponding values on a user's > monitor. Now that in that form there is a field "username", for some > reasons I can not show this information to that user even though this > is his/her username. So, is there any way to skip printing this > field? > > Any suggestions? > > Thanks. Use 'exclude' in the form's Meta class. http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Is it possible to skip this field?
Hello, When I use the following code, {{ form.as_table }} . It prints all form fields with corresponding values on a user's monitor. Now that in that form there is a field "username", for some reasons I can not show this information to that user even though this is his/her username. So, is there any way to skip printing this field? Any suggestions? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
Im reading through loads of python / django tutorials atm, hopefully some of it will stick! I added what you suggested and now I'm getting the error "type object 'OnlineUsers' has no attribute 'get_online_user_ids'" view - http://dpaste.com/77965/ middleware (name OnlineUsers) - http://dpaste.com/77967/ What am I doing wrong now? Thanks R On Aug 10, 8:32 pm, Daniel Rosemanwrote: > On Aug 10, 7:10 pm, "Rob B (uk)" wrote: > > > Thanks Daniel. > > Im still quite new to python / django and not sure how to pass > > OnlineUsers.get_online_user_ids() into the context. My view to list > > all profiles looks like this: > > def profile_list(request): > > > return render_to_response('profile_list.html', > > > { 'profile_list': Profile.objects.all > > () }, context_instance=RequestContext(request)) > > You pass it exactly as you are passing the list of profile objects: > { 'profile_list': Profile.objects.all(), > 'online_users': OnlineUsers.get_online_user_ids() } > > You really need to read an introductory Python tutorial - you must at > least know how to define variables like dictionaries, and how to call > functions. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question about request.user
Hi Carlos, Thanks for your reply. I opened two broswers. I first logined as "peter" and I left IE there; then I double-clicked IE icon on my desktop to open a new one. On this new one I logined as "john". There is only one user table as I use "django.contrib.auth.models.User". any more ideas? On Aug 10, 2:33 pm, "Carlos A. Carnero Delgado"wrote: > Hi, > > On Mon, Aug 10, 2009 at 4:46 PM, David wrote: > > Why request.user.username did not bind to "john" in this scenario? > > Anybody knows what caused such a problem? And any ideas how to fix > > it? > > Are you using the same web browser? Maybe two tabs? > > HTH, > Carlos. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Testing code that uses geopy
I have written some unit tests that test various parts of code that utilize geopy for determining geo locations. Should I be running my tests using the geocoder class, or should I create a mock class that does not actually ping any services? If creating a mock class is recommended should I specify the geocoder class in settings, then overwrite that when my test run? Is all of this silly to even be worried about, should I be wanting to hit the geocode service on every test. Thanks in advance for any insight. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Question about request.user
Hi, On Mon, Aug 10, 2009 at 4:46 PM, Davidwrote: > Why request.user.username did not bind to "john" in this scenario? > Anybody knows what caused such a problem? And any ideas how to fix > it? Are you using the same web browser? Maybe two tabs? HTH, Carlos. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Question about request.user
hello, Here is what I met. I logined into my Django application online with a username "peter". Then I logined with another username "john". All seemed fine. Now I printed user name in "john" account, and it gave "peter". I used following code. if request.user.is_authenticated(): print request.user.username Why request.user.username did not bind to "john" in this scenario? Anybody knows what caused such a problem? And any ideas how to fix it? Thanks so much. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django comments honeypot hide
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 xhtml: html: Luke Seelenbinder luke.seelenbin...@gmail.com http://www.google.com/profiles/luke.seelenbinder -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEARECAAYFAkqAgj8ACgkQXQrGVCncjPz8FACffs+kJ757sMZIB2MEiuLX7V9P LIQAnj/o4jNup6x9CJ4o7yrVfUm/J6pD =kMMm -END PGP SIGNATURE- On Mon, Aug 10, 2009 at 10:31 AM, Alessandro Ronchiwrote: > I need to hide the django-comments honeypot in my comment form, but It's > visible to the user. > > Is there a way to do that in an easy way? > > -- > Alessandro Ronchi > > SOASI > Sviluppo Software e Sistemi Open Source > http://www.soasi.com > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Contact form
Ok thanks, i'll have a look at the setup then. On 10 Aug, 20:29, Daniel Rosemanwrote: > On Aug 10, 8:23 pm, When ideas fail wrote: > > > > > Hi, i've created a contact fom based on the one in the docs but i > > don't know what to put as the action in the form element as part of > > template. I've got this template: > > > > > {{ form.as_p }} > > > > > > > but presuambly the data is being handled by the view. I'd appreciate > > any help, i tried it without an action and i got a 'Exception Value: > > (10061, 'Connection refused') ' error. > > > Could someone please help? > > > Thanks > > > I've included a copy of the view below > > --- > > - > > > def contact_me(request): > > if request.method == 'POST': > > form = ContactForm(request.POST) > > if form.is_valid(): > > subject = form.cleaned_data['subject'] > > message = form.cleaned_data['message'] > > sender = form.cleaned_data['sender'] > > cc_myself = form.cleaned_data['cc_myself'] > > > recipients = ['andrewkenyon...@gmail.com'] > > if cc_myself: > > recipients.append(sender) > > > from django.core.mail import send_mail > > send_mail(subject, message, sender, recipients) > > return HttpResponseRedirect('/thanks/') > > > else: > > form = ContactForm() > > > return render_to_response('blogSite/contact_me.html', {'form': > > form, }) > > An empty string, or alternatively "." , is the correct thing to put. > Action is misleadingly named - it's actually just a URL. So this means > that the URL to POST to is the same one that originally rendered the > view. > > Your form is acting correctly - the 'connection refused' error is > presumably coming from the send_mail function inside your view, > perhaps you haven't got the mail settings correct. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multiple application instances?
In the django documentation -> URL dispatcher -> Defining URL namespaces it reads "When you need to deploy multiple instances of a single application, it can be helpful to be able to differentiate between instances" I am unable to find any kind of documentation on how to "deploy multiple instances of a single application". So how can I have multiple instances of one application? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Any solution as DjangoKit but for windows ?!
Hello , i have been searching for a week now about a solution making it easy to deploy django projects as desktop application , somehow i found some detailed articles and tutorials ( 3 ) for making this happen for windows , but with DjangoKit its pretty much easier and simpler , the question is as in this message subject , any solution like DjangoKit but for windows ?! I came cross dbuilder.py http://www.methods.co.nz/django/dbuilder.html but somehow , no much details or tutorials more than the manual ! . Also i tried to check the blogs stream and check if anyone tried it before and no luck so far . The other question : is there any other successful tryout for deploying django projects on windows other than silverstripe`s ?! with tutorials explanation if possible ?! Best regards : H M --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Contact form
On Aug 10, 8:23 pm, When ideas failwrote: > Hi, i've created a contact fom based on the one in the docs but i > don't know what to put as the action in the form element as part of > template. I've got this template: > > > {{ form.as_p }} > > > > but presuambly the data is being handled by the view. I'd appreciate > any help, i tried it without an action and i got a 'Exception Value: > (10061, 'Connection refused') ' error. > > Could someone please help? > > Thanks > > I've included a copy of the view below > --- > - > > def contact_me(request): > if request.method == 'POST': > form = ContactForm(request.POST) > if form.is_valid(): > subject = form.cleaned_data['subject'] > message = form.cleaned_data['message'] > sender = form.cleaned_data['sender'] > cc_myself = form.cleaned_data['cc_myself'] > > recipients = ['andrewkenyon...@gmail.com'] > if cc_myself: > recipients.append(sender) > > from django.core.mail import send_mail > send_mail(subject, message, sender, recipients) > return HttpResponseRedirect('/thanks/') > > else: > form = ContactForm() > > return render_to_response('blogSite/contact_me.html', {'form': > form, }) An empty string, or alternatively "." , is the correct thing to put. Action is misleadingly named - it's actually just a URL. So this means that the URL to POST to is the same one that originally rendered the view. Your form is acting correctly - the 'connection refused' error is presumably coming from the send_mail function inside your view, perhaps you haven't got the mail settings correct. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Contact form
Hi, i've created a contact fom based on the one in the docs but i don't know what to put as the action in the form element as part of template. I've got this template: {{ form.as_p }} but presuambly the data is being handled by the view. I'd appreciate any help, i tried it without an action and i got a 'Exception Value: (10061, 'Connection refused') ' error. Could someone please help? Thanks I've included a copy of the view below def contact_me(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): subject = form.cleaned_data['subject'] message = form.cleaned_data['message'] sender = form.cleaned_data['sender'] cc_myself = form.cleaned_data['cc_myself'] recipients = ['andrewkenyon...@gmail.com'] if cc_myself: recipients.append(sender) from django.core.mail import send_mail send_mail(subject, message, sender, recipients) return HttpResponseRedirect('/thanks/') else: form = ContactForm() return render_to_response('blogSite/contact_me.html', {'form': form, }) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
On Aug 10, 7:10 pm, "Rob B (uk)"wrote: > Thanks Daniel. > Im still quite new to python / django and not sure how to pass > OnlineUsers.get_online_user_ids() into the context. My view to list > all profiles looks like this: > def profile_list(request): > > return render_to_response('profile_list.html', > > { 'profile_list': Profile.objects.all > () }, context_instance=RequestContext(request)) > You pass it exactly as you are passing the list of profile objects: { 'profile_list': Profile.objects.all(), 'online_users': OnlineUsers.get_online_user_ids() } You really need to read an introductory Python tutorial - you must at least know how to define variables like dictionaries, and how to call functions. -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
help with excel exports
Hi all - I'm pushing content to a template which i have built to properly organize the data for an excel spreadsheet. I'm generating the response in my view as such: response = render_to_response("spreadsheet.html", { 'tms': tms, }) response['Content-Type'] = 'application/vnd.ms-excel' response['Content-Disposition'] = 'attachment;filename=biblio- export.xls' response['Charset']='UTF-8' return response This works great with one exception. It saves the file to the person's last saved location... in my case it's the desktop, in other cases it's /downloads etc Is there a way to force the SAVE option so that when they click SAVE, the user can determine where to put the file? My testing so far indicates this is not browser independent --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: overriding save()
when I do this it just creates a unix executable file of the same name selected from the drop down menu of users, i.e., if a user named testuser24 is selected from the user menu and there is a folder named testuser24 a unix executable is created named testuser24_. Does this have something to do with the instance parameter? class Listing(models.Model): user = models.ForeignKey(User) name = models.CharField(max_length=50) order = models.ForeignKey('Order') def overwrite_upload_to(self, name): user_dir_path = os.path.join('listings', self.user.username) return user_dir_path zipfile = models.FileField(upload_to=overwrite_upload_to) On Aug 9, 8:35 pm, Karen Traceywrote: > On Sun, Aug 9, 2009 at 10:23 PM, neridaj wrote: > > > It was suggested to me in an earlier post, to override save, and > > though I've read the documentation for upload_to before I guess I > > don't quite know how to implement it without an example. Due to my > > lack of experience I don't know how to address the 'instance' and > > 'filename' arguments required by the callable, is this even close? > > > class Listing(models.Model): > > user = models.ForeignKey(User) > > name = models.CharField(max_length=50) > > order = models.ForeignKey('Order') > > > def overwrite_upload_to(self, name): > > user_dir_path = os.path.join(settings.MEDIA_ROOT, 'listings', > > self.user.username) > > return user_dir_path > > Don't add in MEDIA_ROOT yourself. The return value from a callable > upload_to (just as if it were a simple string) is appended to your > MEDIA_ROOT setting. So you don't need to add it in yourself. > > > > > zipfile = models.FileField(upload_to=overwrite_upload_to(self, > > name)) > > Don't include the parens and parameters. Just pass the callable: > > zipfile = models.FileField(upload_to=overwrite_upload_to) > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: dynamic inserting items to template
2009/8/10 elminio: > > Hello, > Is it possible to insert to the template for example 10 checkboxes > > I know syntax of iterating through objects in list and do some task > for each item but Im interested in normal for loop > like > > for i in xrang(10): > insert checkbox > > thanks for reply > > You can create a template tag to do the work for you and pass the number of items you want as a parameter. You can also create using javascript and use a django template variable to set the counter. -- Antoni Aloy López Blog: http://trespams.com Site: http://apsl.net --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Passing optional URL params to reverse() function
Hi all: I have a URLconf url entry like this: url( regex=r'^(?P\w+)/(?P[-\w]+)/$', view='show_post', name='show_post', kwargs={'msg': None}, ), and I want to call it with HttpResponseRedirect and reverse(): filters = {'category': post.category.name, 'slug': post.slug, 'msg': msg} return HttpResponseRedirect(reverse('show_post', kwargs=filters)) but I am getting this error: NoReverseMatch at /commentposted/first-post/ Reverse for 'show_post' with arguments '()' and keyword arguments '{'category': u'django', 'msg': 'Your comment has been posted', 'slug': u'first-post'}' not found. Request Method: GET Request URL:http://localhost:8000/commentposted/first-post/?c=8 Exception Type: NoReverseMatch Exception Value: Reverse for 'show_post' with arguments '()' and keyword arguments '{'category': u'django', 'msg': 'Your comment has been posted', 'slug': u'first-post'}' not found. Is there any way to pass th reverse() function extra optional parameters that the url define (msg param in this case)? Or am I crazy? Thanks in advance! Hector --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Passing optional URL params to reverse() function
Hi all: I have a URLconf url entry like this: url( regex=r'^(?P\w+)/(?P[-\w]+)/$', view='show_post', name='show_post', kwargs={'msg': None}, ), and I want to call it with HttpResponseRedirect and reverse(): filters = {'category': post.category.name, 'slug': post.slug} return HttpResponseRedirect(reverse('show_post', kwargs=filters)) but I am getting this error: NoReverseMatch at /commentposted/first-post/ Reverse for 'show_post' with arguments '()' and keyword arguments '{'category': u'django', 'msg': 'Your comment has been posted', 'slug': u'first-post'}' not found. Request Method: GET Request URL:http://localhost:8000/commentposted/first-post/?c=8 Exception Type: NoReverseMatch Exception Value: Reverse for 'show_post' with arguments '()' and keyword arguments '{'category': u'django', 'msg': 'Your comment has been posted', 'slug': u'first-post'}' not found. Is there any way to pass th reverse() function extra optional parameters that the url define? Or am I crazy? Thanks in advance! Hector --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
Big help!! Had just started getting using too much memory notices from Webfaction yesterday evening... The other item is using the crontab -e command from ssh to comment out apps you don't need to have running For some reason could not find that when I was looking for it and one of my sites just kept restarting after .stop, which I understand but did not know how to stop the behavior! On Aug 10, 12:11 pm, Jumpfroggywrote: > Wow, lots of good feedback here. Thanks! > > On Aug 9, 6:17 pm, Graham Dumpleton > wrote: > > > Replace use of mod_python with mod_wsgi. > > I'm using mod_wsgi for everything already, forgot to say. When I > researched, it seemed like the newer/better way to do django. > > > Ensure you use prefork MPM > > for Apache and delegate Django instances to run in mod_wsgi daemon > > mode process. > > Sorry, meant to say 'worker' rather than 'prefork'. DO NOT USE > > PREFORK. Hmmm, that was a bad stuff up. :-) > > I just started using the worker MPM for one of my apps. It didn't > seem to give any performance or memory savings, since my app is so > small/simple. I'll keep an eye on it for later. > > Using daemon mode gives me auto-reloading by touching the .wsgi file > (yay), but it uses more memory. Instead of supervisor (3MB) and > apache worker/WSGI/Django (16MB) processes, now I have supervisor > (3MB), apache worker (3MB), and wsgi/django (15MB). Not a huge gain, > but just a bit more. I'm willing to live with that for the auto- > reloading benefit, however. > > > Having done that, you can use inactivity-timeout option > > for mod_wsgi daemon processes to have the process restarted and > > returned to low memory footprint idle process after no use for a > > while. > > This is exactly what I wanted!!! It's funny how when I finally read > the description for something, it matches exactly what I'm looking > for. I just didn't know where to look. I just tried it, and yes my > memory baloons up to 16MB, then comes back down later. The only > strange thing is that I set it to 10s (very short) to test out, but it > takes a while for the process to actually be reclaimed. If I put > inactivity-timeout=10, then load the page, then close the browser, > memory usage should be reclaimed in 10 seconds, right? It seems more > like 1 minute wait, which is fine but strange to me. Maybe there's > only polling at certain intervals (checks every 1 minute), so the > resolution isn't that fine. Maybe it's dependent on the deadlock > timeout? Don't know. > > > Note, just ensure you don't keep loading mod_python after having > > switched to mod_wsgi as mod_python will still consume some extra > > memory when not in use. > > Yeah, never touched mod_python, so no problem here. > > On Aug 10, 6:44 am, Dj Gilcrease wrote: > > > I just went though this process on Webfaction as well, so here is my > > apache conf, it might help... > > Thanks for the post, good to see another webfaction user here. It > always helps to see other people's real-world configs, since examples > usually leave out the key bits. > > On Aug 10, 10:25 am, Dj Gilcrease wrote: > > > >> MaxRequestsPerChild 5000 > > > Don't see much point for MaxRequestsPerChild. > > This just restarts the child after 5k requests, which helps clear out > > some memory on occasion (I am still trying to get rrd or something run > > on on Webfaction so I can actually map memory usage over time, and > > start tuning Apache to my actual usage needs better) > > I experimented with using this as a dumb alternative to inactivity- > timeout. Set MaxRequestsPerChild to 1, means the WSGI process will > restart after each HTTP request. Very slow, but gives immediate > memory savings. Only viable if the MEDIA_URL is set to a separate, > static server (which webfaction recommends and makes easy). However, > inactivity-timeout is still better. > > > >> WSGIPythonOptimize 1 > > > Am dubious that turning on optimisation helps and can cause problems > > > if set to '2' as doc strings will be stripped. > > I doubt it is much improvement, but I just turned it on as a test and > > did read that 2 is a bad idea which is why I stuck with 1 > > I'd love to see some benchmarks for this config with real apps. The > docs make sense... don't expect magic switches to help if you haven't > optimized your code, so I really shouldn't even worry about this > option yet. > > > >> > > >> ServerName demo.digitalxero.net > > >> DocumentRoot /home/digitalxero/webapps/wsgi/demo > > >> WSGIDaemonProcess demo.digitalxero.net threads=5 > > >> maximum-requests=1 inactivity-timeout=3600 > > >> display-name=wsgi:demo_site > > > > That is 1 hour for inactivity timeout. They possibly want something > > > less than that. > > > Ya, I picked an hour for starters and will drop it down or increase it > > as my needs dictate (one I get something to monitory usage better
Re: Default value for fields
On Mon, Aug 10, 2009 at 2:13 PM, ankit raiwrote: > check ur db table ,is null=true present.And in ur model write > revision = models.IntegerField(default=0,balnk=true,null=true) > and if u donont want to change the value from 0 at all then there is no > need to diplay it in fields > null=True should not be present. AG doesn't want null values allows but rather wants them to be set to a default value. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Default value for fields
check ur db table ,is null=true present.And in ur model write revision = models.IntegerField(default=0,balnk=true,null=true) and if u donont want to change the value from 0 at all then there is no need to diplay it in fields On Mon, Aug 10, 2009 at 11:29 PM, AGwrote: > > I have a field: > revision = models.IntegerField(default=0) > on a model. > > I assumed that if I set a default value for a field, I am free to > create an object that does not set 'revision', and save it. > However, this produces an IntegrityError: > IntegrityError: XXX.revision may not be NULL > > When I check the get_default value for this field, I get 0. Why is > this field not set during a 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Default value for fields
On Mon, Aug 10, 2009 at 1:59 PM, AGwrote: > > I have a field: > revision = models.IntegerField(default=0) > on a model. > > I assumed that if I set a default value for a field, I am free to > create an object that does not set 'revision', and save it. > However, this produces an IntegrityError: > IntegrityError: XXX.revision may not be NULL > > When I check the get_default value for this field, I get 0. Why is > this field not set during a save()? > How exactly are you creating the object that does not set revision? I cannot recreate the IntegrityError except by explicitly setting revision to None, which is different from not specifying it. If it is not specified, it will be set to the default value, at least in my testing. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: user online
Thanks Daniel. Im still quite new to python / django and not sure how to pass OnlineUsers.get_online_user_ids() into the context. My view to list all profiles looks like this: def profile_list(request): return render_to_response('profile_list.html', { 'profile_list': Profile.objects.all () }, context_instance=RequestContext(request)) On 9 Aug, 22:16, Daniel Rosemanwrote: > On Aug 9, 10:07 pm, "Rob B (uk)" wrote: > > > Im using this middleware to try and display a list ofonlineuser on > > my site.http://dpaste.com/77464/ > > > Im just not sure how to pass it to my view and template. Any ideas? > > > Middleware found > > @http://groups.google.com/group/django-users/browse_thread/thread/6f5f... > > > Thanks > > Jeremy explains how to do it in the message you link to: > "You'll want to use OnlineUsers.get_online_user_ids() wherever you > need > the list of IDs. " > > ie import the OnlineUsers module in your view and pass > OnlineUsers.get_online_user_ids() into the context. > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Default value for fields
I have a field: revision = models.IntegerField(default=0) on a model. I assumed that if I set a default value for a field, I am free to create an object that does not set 'revision', and save it. However, this produces an IntegrityError: IntegrityError: XXX.revision may not be NULL When I check the get_default value for this field, I get 0. Why is this field not set during a 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: need help with model design and table relationship
Here is the solution. There is no need in Many-to-many here. In people table I've set corp's unique number as a ForeignKey to Corp's table. In a template: {% for i in result %} {% for persons in i.dolgnost_set.all %} {{ person.field1 }} where Dolgnost - a table with people. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
Wow, lots of good feedback here. Thanks! On Aug 9, 6:17 pm, Graham Dumpletonwrote: > Replace use of mod_python with mod_wsgi. I'm using mod_wsgi for everything already, forgot to say. When I researched, it seemed like the newer/better way to do django. > Ensure you use prefork MPM > for Apache and delegate Django instances to run in mod_wsgi daemon > mode process. > Sorry, meant to say 'worker' rather than 'prefork'. DO NOT USE > PREFORK. Hmmm, that was a bad stuff up. :-) I just started using the worker MPM for one of my apps. It didn't seem to give any performance or memory savings, since my app is so small/simple. I'll keep an eye on it for later. Using daemon mode gives me auto-reloading by touching the .wsgi file (yay), but it uses more memory. Instead of supervisor (3MB) and apache worker/WSGI/Django (16MB) processes, now I have supervisor (3MB), apache worker (3MB), and wsgi/django (15MB). Not a huge gain, but just a bit more. I'm willing to live with that for the auto- reloading benefit, however. > Having done that, you can use inactivity-timeout option > for mod_wsgi daemon processes to have the process restarted and > returned to low memory footprint idle process after no use for a > while. This is exactly what I wanted!!! It's funny how when I finally read the description for something, it matches exactly what I'm looking for. I just didn't know where to look. I just tried it, and yes my memory baloons up to 16MB, then comes back down later. The only strange thing is that I set it to 10s (very short) to test out, but it takes a while for the process to actually be reclaimed. If I put inactivity-timeout=10, then load the page, then close the browser, memory usage should be reclaimed in 10 seconds, right? It seems more like 1 minute wait, which is fine but strange to me. Maybe there's only polling at certain intervals (checks every 1 minute), so the resolution isn't that fine. Maybe it's dependent on the deadlock timeout? Don't know. > Note, just ensure you don't keep loading mod_python after having > switched to mod_wsgi as mod_python will still consume some extra > memory when not in use. Yeah, never touched mod_python, so no problem here. On Aug 10, 6:44 am, Dj Gilcrease wrote: > I just went though this process on Webfaction as well, so here is my > apache conf, it might help... Thanks for the post, good to see another webfaction user here. It always helps to see other people's real-world configs, since examples usually leave out the key bits. On Aug 10, 10:25 am, Dj Gilcrease wrote: > >> MaxRequestsPerChild 5000 > > Don't see much point for MaxRequestsPerChild. > This just restarts the child after 5k requests, which helps clear out > some memory on occasion (I am still trying to get rrd or something run > on on Webfaction so I can actually map memory usage over time, and > start tuning Apache to my actual usage needs better) I experimented with using this as a dumb alternative to inactivity- timeout. Set MaxRequestsPerChild to 1, means the WSGI process will restart after each HTTP request. Very slow, but gives immediate memory savings. Only viable if the MEDIA_URL is set to a separate, static server (which webfaction recommends and makes easy). However, inactivity-timeout is still better. > >> WSGIPythonOptimize 1 > > Am dubious that turning on optimisation helps and can cause problems > > if set to '2' as doc strings will be stripped. > I doubt it is much improvement, but I just turned it on as a test and > did read that 2 is a bad idea which is why I stuck with 1 I'd love to see some benchmarks for this config with real apps. The docs make sense... don't expect magic switches to help if you haven't optimized your code, so I really shouldn't even worry about this option yet. > >> > >> ServerName demo.digitalxero.net > >> DocumentRoot /home/digitalxero/webapps/wsgi/demo > >> WSGIDaemonProcess demo.digitalxero.net threads=5 > >> maximum-requests=1 inactivity-timeout=3600 > >> display-name=wsgi:demo_site > > > That is 1 hour for inactivity timeout. They possibly want something > > less than that. > > Ya, I picked an hour for starters and will drop it down or increase it > as my needs dictate (one I get something to monitory usage better then > guessing) Their default DJango installs are either mod_python or mod_wsgi. The mod_wsgi is embedded mode, and has no inactivity-timeout and is StartServers 2, so by default one Django app takes 3MB + 16MB + 16MB of memory (35MB) out of your allotted 80MB. That means only 2.5 django apps before you run out of memory. They have a "how to save memory with django" howto, but it doesn't have any of these settings. I'll try to send it updates, they'll probably appreciate it. > > If you application does leak Python objects due to inability to break > > reference count cycles, there shouldn't really be a need for maximum > >
Re: Custom manager and delete()
I manage to do row delete operations. Not very nice, since there's no delete-related, no signalst etc. I don't think delete can be fixed for multiple databases without modifying Django source or without duplicating code. Since delete_objects function uses the global connection variable. Would be nice if it wouldn't use global "connection". --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
RE: Admin Panel and ManyToMany
Sorry guys, I've found what to do and it's in the tutorial. InlineAdmin, tut. From: jlebr...@hotmail.com To: django-users@googlegroups.com Subject: Admin Panel and ManyToMany Date: Mon, 10 Aug 2009 14:05:31 +0100 Hi All, I'm trying to add a manytomany field so that it shows up on the admin panel for the model, but it does not look like it's working. The relationship is done via a through model. I want a list of the many items belonging to my model. Thanks, Joseph Windows Live Messenger: Happy 10-Year Anniversary—get free winks and emoticons. Get Them Now _ Celebrate a decade of Messenger with free winks, emoticons, display pics, and more. http://clk.atdmt.com/UKM/go/157562755/direct/01/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom manager and delete()
Just as a follow-up. I ended up switching to Elixir to handle my multiple legacy databases, while keeping django to handle the main system. The syntax is very similar, and it provides some additional flexibility that allows me to deal with those legacy DB's (like dealing with non-indexed tables). I hope to revert back to full django ORM, once it has multi-db support. Michael. Adi Andreias wrote: > Hello, > > Anyone can give us a hint with this? > I have the same problem: with a custom manager (for a 2nd database) > SELETs and INSERTs are working, but not the DELETE operation. > Seems like DELETE references a global connection variable (to the main > database). > > Thanks > > > michael wrote: > >> Hi, >> >> [Sorry, if this has been asked before] >> I defined a model using a custom manager. However, this custom manager >> is not used when I call "delete()" method on an instance object. The >> reason >> I use a custom manager is because the model represents objects in >> another >> legacy database (different from the normal database used by django). >> So >> I'm basically trying to emulate multi-db support. >> >> Obviously, as delete() uses the default manager, it fails as the >> corresponding >> table is not in that database. >> >> Is there a workaround for this, or do I have to overload delete() in >> my model >> and use raw SQL? >> >> Thanks, >> Michael. >> > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: IE problems w. admin save
I am having similar problems with IE using formsets and the admin functionality. I tend to believe it is an issue with IE but I haven't been able to determine what the issue is. On Mon, Aug 10, 2009 at 10:42 AM, Jesper Rasmussenwrote: > > Hi there, > > I'm developing a simple Django system (Sqlite) -- using Firefox > everything works. > > When using IE (7) the save button on the admin pages workes strangely: > If there is some error in the entered data it just displays a blank > page, if no errors is made it displays an "Internet Explorer cannot > display the webpage" page ... but on reload it displays the proper > page. > > Could this be tied to the database not being done updating before the > data is being read? > > Cheers, > Jesper Rasmussen > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Dynamic Auth Backend and subdomains
no clues or unclear ? :) On Aug 9, 1:44 am, coulixwrote: > Hello Pony Wizards, > > I am facing a use case where my authentication process is variable > depending on the request.subdomain catched by a custom > GetSubdomainMiddleware. > > AAA.example.com/login > BBB.example.com/login > > In this case my subdomain is "AAA", I have the domain name in a model > which also has the URL to use for the authentication of the user. This > URL could bewww.AAA.com/session/create/ > > I want my authbackend to make a POST (username, pass) to this URL and > get a JSON response containing the user details or a fail > (authentication fail). This part is fine and the example given in > django for auth backend is perfect. > > The problem is that auth backend handling is usually done by adding an > entry in settings AUTHENTICATION_BACKENDS. > > Could i set somehow my custom auth backend with URL as a parameter on > an anonymous user knowing his subdomain ? > > Should i just go the easy way and handle it with a view ? > > Thanks, > Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How do I sort a ManyToManyField in Django admin?
I currently have the following models: class Image(models.Model): alt_name = models.CharField(max_length=200) def __unicode__(self): return self.alt_name class Album(models.Model): images = models.ManyToManyField(Image, blank=True) class AlbumAdmin(admin.ModelAdmin): model = Album filter_horizontal = ('images',) admin.site.register(Album, AlbumAdmin) The above work fine in the admin where I can see a list of images. However, I want to sort this list by the Image.alt_name. How do I do that? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to manually set FileField path
Hi, I need to set the content of a FileField manually, ie not using the admin screens. The instance of the model that contains the FileField already exists, but has the FileField is currently none. I know the local path for the file, but just can't work out how to update the FileField so I can save the object. Thanks for any help Jo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Django: Add SET DATESTYLE
On Mon, Aug 10, 2009 at 12:00 PM, Bdfywrote: > > How to add a phrase "SET DATESTYLE =" bla-bla-bla "" for everyone SQL > query ? > Why do you think you want to do that? The Django ORM takes the date(time) values coming from the database and converts them do Python date(time) objects. You can then control how they are formatted for output using Python date formatting mechanisms. If you are using forms, the widgets for date and time allow you to specify the format for output. Similarly for input, you have control over what formats are accepted. The format that is used for communication between the database and the Django ORM should not matter to your code at all. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: looping over forms in a formset
Why I didn't find this before? It seems Paul had the same problem, and one has to loop over the hidden fields in each form ... {% for hid in form.hidden_fields %} {{hid}}{% endfor %} On Aug 10, 4:59 pm, bnlwrote: > hi folks > > I have a formset, which I want to display using a customised template > for the forms. > > This works: > > {{formset.mangement_form}} > {% for form in formset.forms %} > {{form}} > {% endfor %} > > The following displays ok, let's me edit one form, but then I can't > update it or add another, failling with a muMultiValueDictKeyError > at > "Key 'form-0-id' not found in 1.0 blew up with a keyerror). > > {{formset.management_forms}} > {% for form in formset.forms %} > {{form.title.errors}}{{form.title}} > etc looping over the fields in a nice way ... > {% endfor %} > > Looking at the posted form in an editor, I see the following (with > django 1.0) in the form that works: > > and > > in the one that doesn't. > > Any idea what I'm doing wrong? need to do? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django: Add SET DATESTYLE
How to add a phrase "SET DATESTYLE =" bla-bla-bla "" for everyone SQL query ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
looping over forms in a formset
hi folks I have a formset, which I want to display using a customised template for the forms. This works: {{formset.mangement_form}} {% for form in formset.forms %} {{form}} {% endfor %} The following displays ok, let's me edit one form, but then I can't update it or add another, failling with a muMultiValueDictKeyError at "Key 'form-0-id' not found in and in the one that doesn't. Any idea what I'm doing wrong? need to do? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
IE problems w. admin save
Hi there, I'm developing a simple Django system (Sqlite) -- using Firefox everything works. When using IE (7) the save button on the admin pages workes strangely: If there is some error in the entered data it just displays a blank page, if no errors is made it displays an "Internet Explorer cannot display the webpage" page ... but on reload it displays the proper page. Could this be tied to the database not being done updating before the data is being read? Cheers, Jesper Rasmussen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom model field and Django-admin -- error
Excellent that it was reported, but bad that it's not considered a 'bug' -- Any suggestions on how to use date_hierarchy (and probably others) with my field? On Aug 10, 8:04 am, Alex Gaynorwrote: > On Mon, Aug 10, 2009 at 8:45 AM, BenW wrote: > > > Hello, > > > I'm working with a legacy database that stores datetimes as unsigned > > ints. Rather than do the conversion with properties on the model I've > > written a custom Field 'UnixDateTimeField': > > > class UnixDateTimeField(models.DateTimeField): > > > __metaclass__ = models.SubfieldBase > > > def get_internal_type(self): > > return 'PositiveIntegerField' > > > def to_python(self, value): > > if value is None or isinstance(value, datetime): > > return value > > if isinstance(value, date): > > return datetime(value.year, value.month, value.day) > > return datetime.fromtimestamp( float(value) ) > > > def get_db_prep_value(self, value): > > return int( time.mktime( value.timetuple() ) ) > > > def value_to_string(self, obj): > > value = self._get_val_from_obj(obj) > > return self.to_python(value).strftime('%Y-%m-%d %H:%M:%S') > > > class MyModel(models.Model): > > time = UnixDateTimeField() > > > # This Works: > >>> MyModel.objects.filter(time__lte=datetime.now()) > > [, , etc..] > > > # This works: > >>> MyModel.objects.all()[0].time > > datetime.datetime(2009, 8, 10, 6, 40, 7) > > > # Doesn't work: > >>> MyModel.objects.all().values('time') > > [{'time': 1249911607L}, {'time': 1249911607L}, {'time': > > 1249911607L}, ...] > > > The same thing happens in the Admin when I specify date_hierarchy in > > my ModelAdmin a one of these fields. Why are the standard accessor > > methods (namely 'to_python()') not being called here? How can I make > > the custom Field more robust? > > > Thank you, > > > Ben > > This looks like ticket #9619:http://code.djangoproject.com/ticket/9619 > > Alex > > -- > "I disapprove of what you say, but I will defend to the death your > right to say it." -- Voltaire > "The people's good is the highest law." -- Cicero > "Code can always be simpler than you think, but never as simple as you > want" -- Me --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom model field and Django-admin -- error
Alex Gaynor wrote: > On Mon, Aug 10, 2009 at 8:45 AM, BenWwrote: > >> Hello, >> >> I'm working with a legacy database that stores datetimes as unsigned >> ints. Rather than do the conversion with properties on the model I've >> written a custom Field 'UnixDateTimeField': >> >> class UnixDateTimeField(models.DateTimeField): >> >>__metaclass__ = models.SubfieldBase >> >>def get_internal_type(self): >>return 'PositiveIntegerField' >> >>def to_python(self, value): >>if value is None or isinstance(value, datetime): >>return value >>if isinstance(value, date): >>return datetime(value.year, value.month, value.day) >>return datetime.fromtimestamp( float(value) ) >> >>def get_db_prep_value(self, value): >>return int( time.mktime( value.timetuple() ) ) >> >>def value_to_string(self, obj): >>value = self._get_val_from_obj(obj) >>return self.to_python(value).strftime('%Y-%m-%d %H:%M:%S') >> >> class MyModel(models.Model): >>time = UnixDateTimeField() >> >> # This Works: >> MyModel.objects.filter(time__lte=datetime.now()) >> [, , etc..] >> >> # This works: >> MyModel.objects.all()[0].time >> datetime.datetime(2009, 8, 10, 6, 40, 7) >> >> # Doesn't work: >> MyModel.objects.all().values('time') >> [{'time': 1249911607L}, {'time': 1249911607L}, {'time': >> 1249911607L}, ...] >> >> The same thing happens in the Admin when I specify date_hierarchy in >> my ModelAdmin a one of these fields. Why are the standard accessor >> methods (namely 'to_python()') not being called here? How can I make >> the custom Field more robust? >> >> Thank you, >> >> Ben >> > > This looks like ticket #9619: http://code.djangoproject.com/ticket/9619 > > Alex > > Beside that - I would like to see the UnixDateTimeField in django by default - it's not uncommon to use unix timestamps for applications which do support quite alot of databases, especially when mssql is one of them. Cheers, Jean --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Custom model field and Django-admin -- error
On Mon, Aug 10, 2009 at 8:45 AM, BenWwrote: > > Hello, > > I'm working with a legacy database that stores datetimes as unsigned > ints. Rather than do the conversion with properties on the model I've > written a custom Field 'UnixDateTimeField': > > class UnixDateTimeField(models.DateTimeField): > > __metaclass__ = models.SubfieldBase > > def get_internal_type(self): > return 'PositiveIntegerField' > > def to_python(self, value): > if value is None or isinstance(value, datetime): > return value > if isinstance(value, date): > return datetime(value.year, value.month, value.day) > return datetime.fromtimestamp( float(value) ) > > def get_db_prep_value(self, value): > return int( time.mktime( value.timetuple() ) ) > > def value_to_string(self, obj): > value = self._get_val_from_obj(obj) > return self.to_python(value).strftime('%Y-%m-%d %H:%M:%S') > > class MyModel(models.Model): > time = UnixDateTimeField() > > # This Works: >>> MyModel.objects.filter(time__lte=datetime.now()) > [, , etc..] >>> > > # This works: >>> MyModel.objects.all()[0].time > datetime.datetime(2009, 8, 10, 6, 40, 7) >>> > > # Doesn't work: >>> MyModel.objects.all().values('time') > [{'time': 1249911607L}, {'time': 1249911607L}, {'time': > 1249911607L}, ...] >>> > > The same thing happens in the Admin when I specify date_hierarchy in > my ModelAdmin a one of these fields. Why are the standard accessor > methods (namely 'to_python()') not being called here? How can I make > the custom Field more robust? > > Thank you, > > Ben > > > This looks like ticket #9619: http://code.djangoproject.com/ticket/9619 Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." -- Voltaire "The people's good is the highest law." -- Cicero "Code can always be simpler than you think, but never as simple as you want" -- Me --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
bidirectional m2m in admin page
Suppose I have a model: - class Person(models.Model): name = models.CharField(max_length=max) class Group(models.Model): name = models.CharField(max_length=max) persons = models.ManyToManyField(Person) How should I handle this in admin page? The Group admin-change-page has automaticaly a persons m2m field, what is ok, but if I try append the reverse dircection. like this: --- class GroupInline(admin.TabularInline): model = Group class PersonAdmin(admin.ModelAdmin): inlines = [ GroupInline, ] - I've got an error message: --- Exception Value: has no ForeignKey to -- What is the solution? How can I have both dircetion fields in admin page? To define an empty intermediate model does'nt like me. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Django comments honeypot hide
I need to hide the django-comments honeypot in my comment form, but It's visible to the user. Is there a way to do that in an easy way? -- Alessandro Ronchi SOASI Sviluppo Software e Sistemi Open Source http://www.soasi.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
On Mon, Aug 10, 2009 at 6:43 AM, Graham Dumpletonwrote: > These values for min and max threads are a bit dubious because you > have a single process and that will have fixed 25 threads. Usually > these are defined in multiples of ThreadsPerChild and not less like > this. Possibly just means the values are ignored. The MaxClients (according to the Apache docs is #MaxServers * #ThreadsPerChild) I just set it explicitly so I remember what it is, though it is actually ignored >> ThreadsPerChild 25 >> MaxRequestsPerChild 5000 > > Don't see much point for MaxRequestsPerChild. This just restarts the child after 5k requests, which helps clear out some memory on occasion (I am still trying to get rrd or something run on on Webfaction so I can actually map memory usage over time, and start tuning Apache to my actual usage needs better) >> WSGIPythonOptimize 1 > > Am dubious that turning on optimisation helps and can cause problems > if set to '2' as doc strings will be stripped. I doubt it is much improvement, but I just turned it on as a test and did read that 2 is a bad idea which is why I stuck with 1 >> >> ServerName demo.digitalxero.net >> DocumentRoot /home/digitalxero/webapps/wsgi/demo >> WSGIDaemonProcess demo.digitalxero.net threads=5 >> maximum-requests=1 inactivity-timeout=3600 >> display-name=wsgi:demo_site > > That is 1 hour for inactivity timeout. They possibly want something > less than that. Ya, I picked an hour for starters and will drop it down or increase it as my needs dictate (one I get something to monitory usage better then guessing) > If you application does leak Python objects due to inability to break > reference count cycles, there shouldn't really be a need for maximum > requests. Though my app does no leak, that I have noticed anyways, I figure a maximum-requests would be good just in case I suddenly get a flood of traffic, it will restart the daemon even if the hour of idle time has not passed. I run 5 sites right now and none of them get much more then 10 visitors an hour on average, and what prompted my investigations is I was continually sitting at 95mb of ram usage (my account is supposed to be limited to 80) and I was using the default apache build the WF provided, which is prefork MPM and mod_python. Now I seem to be averaging 36mb and 55 max > Sorry, meant to say 'worker' rather than 'prefork'. DO NOT USE > PREFORK. Hmmm, that was a bad stuff up. :-) ahh ok, good to know my own testing concluded corectly --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: slug regular expression: which should I use
Thanks Eric, that does answer my question. On Aug 10, 3:03 pm, Eric Abrahamsenwrote: > On Aug 10, 2009, at 1:56 PM, J0hnsmith wrote: > > > > > Which should I use to match a slug made using slugify? > > > (?P[a-zA-Z0-9-]+) > > > or > > > (?P[\w-]+) > > They're not exactly the same. Most of the time \w is alphanumeric (ie > equivalent to your first regex) but Django compiles the > RegexURLPattern with the UNICODE flag, which means that \w will match > the numbers, plus anything that could be considered a Unicode > character. At least, that's my understanding. > > Hope that answers your question, > Eric > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Running django tests
Indeed it helped. Thanks a lot, Karen. 2009/8/10 Karen Tracey: > 2009/8/10 Filip Gruszczyński >> >> Hi! >> >> I would like to run django source code tests, but as soon as I do it >> (after specifying the settings file), I get all kinds of exceptions. >> Any idea, what am I doing wrong? I post the exceptions below. >> >> grusz...@gruszczy-laptop:~/django/tests# PYTHONPATH=.. > > You appear to be on a Unix-y platform so you'll need to export PYTHONPATH: > > export PYTHONPATH=.. > > so that the setting will be inherited by the runtests script. > >> >> grusz...@gruszczy-laptop:~/django/tests# ./runtests.py --settings=settings >> Error while importing defer: File "./runtests.py", line 134, in >> django_tests >> mod = load_app(model_label) >> File "/var/lib/python-support/python2.6/django/db/models/loading.py", >> line 72, in load_app >> mod = __import__(app_name, {}, {}, ['models']) >> File "/root/django/tests/modeltests/defer/models.py", line 6, in >> from django.db.models.query_utils import DeferredAttribute >> ImportError: cannot import name DeferredAttribute > > Notice you are running the tests in /root/django/tests/ but the Django code > that has been found is /var/lib/python-support/python2.6/django. > > This is a symptom of your PYTHONPATH setting not working, and all the import > errors are likely due to your trying to run new tests against an old level > of the code. DeferredAttributed no doubt didn't exist in > django.db.models.query_utils in whatever version of Django you have > installed in /var/lib/python-support. > > Fix the PYTHONPATH setting and things should go better. > > Karen > > > > -- Filip Gruszczyński --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Custom model field and Django-admin -- error
Hello, I'm working with a legacy database that stores datetimes as unsigned ints. Rather than do the conversion with properties on the model I've written a custom Field 'UnixDateTimeField': class UnixDateTimeField(models.DateTimeField): __metaclass__ = models.SubfieldBase def get_internal_type(self): return 'PositiveIntegerField' def to_python(self, value): if value is None or isinstance(value, datetime): return value if isinstance(value, date): return datetime(value.year, value.month, value.day) return datetime.fromtimestamp( float(value) ) def get_db_prep_value(self, value): return int( time.mktime( value.timetuple() ) ) def value_to_string(self, obj): value = self._get_val_from_obj(obj) return self.to_python(value).strftime('%Y-%m-%d %H:%M:%S') class MyModel(models.Model): time = UnixDateTimeField() # This Works: >> MyModel.objects.filter(time__lte=datetime.now()) [, , etc..] >> # This works: >> MyModel.objects.all()[0].time datetime.datetime(2009, 8, 10, 6, 40, 7) >> # Doesn't work: >> MyModel.objects.all().values('time') [{'time': 1249911607L}, {'time': 1249911607L}, {'time': 1249911607L}, ...] >> The same thing happens in the Admin when I specify date_hierarchy in my ModelAdmin a one of these fields. Why are the standard accessor methods (namely 'to_python()') not being called here? How can I make the custom Field more robust? Thank you, Ben --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Using django.root in mod_python
Hello, All my previous projects I've deployed them on the root of a web address. Now I have to deploy two in the same address eg: http://myserver.com/proj1 http://myserver.com/proj2 I'm using django.root to set the correct root (with works fine). I just have two questions: 1 - all the media are relative do /media/... is there a template variable with I can put there (I don't want to hardcode /proj1/ media/...) 2 - LOGIN_URL = '/auth/login' do I have to hardcode LOGIN_URL = '/ proj1/auth/login' or is there a solution? Regards, Luis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Admin Panel and ManyToMany
Hi All, I'm trying to add a manytomany field so that it shows up on the admin panel for the model, but it does not look like it's working. The relationship is done via a through model. I want a list of the many items belonging to my model. Thanks, Joseph _ Windows Live Messenger: Happy 10-Year Anniversary—get free winks and emoticons. http://clk.atdmt.com/UKM/go/157562755/direct/01/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Running django tests
2009/8/10 Filip Gruszczyński> > Hi! > > I would like to run django source code tests, but as soon as I do it > (after specifying the settings file), I get all kinds of exceptions. > Any idea, what am I doing wrong? I post the exceptions below. > > grusz...@gruszczy-laptop:~/django/tests# PYTHONPATH=.. You appear to be on a Unix-y platform so you'll need to export PYTHONPATH: export PYTHONPATH=.. so that the setting will be inherited by the runtests script. > > grusz...@gruszczy-laptop:~/django/tests# ./runtests.py --settings=settings > Error while importing defer: File "./runtests.py", line 134, in > django_tests >mod = load_app(model_label) > File "/var/lib/python-support/python2.6/django/db/models/loading.py", > line 72, in load_app >mod = __import__(app_name, {}, {}, ['models']) > File "/root/django/tests/modeltests/defer/models.py", line 6, in >from django.db.models.query_utils import DeferredAttribute > ImportError: cannot import name DeferredAttribute Notice you are running the tests in /root/django/tests/ but the Django code that has been found is /var/lib/python-support/python2.6/django. This is a symptom of your PYTHONPATH setting not working, and all the import errors are likely due to your trying to run new tests against an old level of the code. DeferredAttributed no doubt didn't exist in django.db.models.query_utils in whatever version of Django you have installed in /var/lib/python-support. Fix the PYTHONPATH setting and things should go better. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ModelForm validation
On Mon, Aug 10, 2009 at 6:09 AM, nostradamnitwrote: > > I have a form that inherits from ModelForm, and in my view, > form.is_valid returns true, then save() bombs out with validation > errors?!? > is_valid is a method. If you are checking it "if form.is_valid:" that is always going to return True because it always exists. You need to actually call the method: "if form.is_valid():" Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Styling a formset
Hello I'm trying to add some css styling to fields in a formset but there aren't an good classes to work with. Each field has a id which could be used for styling but it has it's index embedded in it. For example: id="id_educationequipment_set-0-id" That's not very helpful for CSS... I'd need to repeat my CSS styles for every possible index! Can anyone suggest a way to add extra css markers to use? This seems like adding some additional classes would work nicely: class="field_column1 field_educationequipment_set" Any advice greatly appreciated. cheers, Oliver --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Backend Neutral DictCursor
You can get a backend neutral database cursor with django.db.connection.cursor(). However, any results executed are returned as nameless lists. Is there a way to get results returned as dictionaries, via DictCursor? MySQL uses MySQLdb.cursors.DictCursor and PostgreSQL uses psycopg2.extras.DictCursor, but I'd rather avoid having to code around each specific backend. Regards, Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How do I minimize memory usage with WSGI and Apache?
On Aug 10, 8:44 pm, Dj Gilcreasewrote: > On Sun, Aug 9, 2009 at 4:17 PM, Graham > > Dumpleton wrote: > > On Aug 10, 6:07 am, Jumpfroggy wrote: > >> I'm hosting a bunch of django apps on a shared host with 80MB of > >> application memory (Webfaction in this case). I've got a bunch of > >> apps that are very infrequently used, but need to be online. I've > >> already changed the httpd.conf: > > I just went though this process on Webfaction as well, so here is my > apache conf, it might help > > LoadModule rewrite_module modules/mod_rewrite.so > LoadModule wsgi_module modules/mod_wsgi.so > LoadModule deflate_module modules/mod_deflate.so > KeepAlive Off > Timeout 300 > ServerLimit 1 > StartServers 1 > MaxClients 25 > MinSpareThreads 2 > MaxSpareThreads 4 These values for min and max threads are a bit dubious because you have a single process and that will have fixed 25 threads. Usually these are defined in multiples of ThreadsPerChild and not less like this. Possibly just means the values are ignored. > ThreadsPerChild 25 > MaxRequestsPerChild 5000 Don't see much point for MaxRequestsPerChild. > WSGIPythonOptimize 1 Am dubious that turning on optimisation helps and can cause problems if set to '2' as doc strings will be stripped. > > ServerName demo.digitalxero.net > DocumentRoot /home/digitalxero/webapps/wsgi/demo > WSGIDaemonProcess demo.digitalxero.net threads=5 > maximum-requests=1 inactivity-timeout=3600 > display-name=wsgi:demo_site That is 1 hour for inactivity timeout. They possibly want something less than that. If you application does leak Python objects due to inability to break reference count cycles, there shouldn't really be a need for maximum requests. > WSGIScriptAlias / /home/digitalxero/webapps/wsgi/demo/django.wsgi > ErrorLog /home/digitalxero/webapps/wsgi/demo/error.log > > > ... > > > Replace use of mod_python with mod_wsgi. Ensure you use prefork MPM > > Why prefork, in my testing I found that the worker MPM used less > memory in the long run, it uses a little bit more during idle time, > but scales better Sorry, meant to say 'worker' rather than 'prefork'. DO NOT USE PREFORK. Hmmm, that was a bad stuff up. :-) Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---