Re: Multiple one-to-one relationships for a single class
Hi Malcolm Thanks for the awesomely quick reply. I'll give the foreign key option a go for now and maybe dive deep later. I'm assuming that I could check for say an existing event detail record when I try and create a new one as well - probably cause less user angst. Thanks again Catriona On Aug 22, 2:42 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2007-08-21 at 21:21 -0700, Catriona wrote: > > Hello > > > Is it possible to have multiple one-to-one relationships for a single > > class or is there a better way to do it. > > Not at the moment, no. OneToOneFields assume they are going to be the > primary key, so you're restricted to a single one. This is something we > will fix in the future, since there are legitimate uses. > > If you wanted to dive deep, you could look in > django/db/models/fields/related.py and try to fix this yourself, > although I suspect it isn't completely trivial (it's not impossible, > just not a five minute job). > > > What I have is an event which has about 12 fields. Optionally any > > combination of a single weather record, a single event detail record, > > a single survey record and one of four event subclass records may be > > stored against this event. Each of these optional records has between > > 5 and 12 fields each. I could put everything in one big table with > > lots of nullable fields but that is not my preferred option. > > You can fake it with a ForeignKey, since that only allows one entry on > the source model's end. The slight drawback is that each target instance > (say, an event detail record) is not prohibited from being linked from > two different event models by the database. Some checking in the save() > method could fake this for you, though. > > Regards, > Malcolm > > -- > Borrow from a pessimist - they don't expect it > back.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Initial value for a choices field in admin?
Thanks Jake. It works like a charm. I thought I tried this before, so I obviously made some mistake. Thanks, Amit > > hi amit, > > Amit Ramon wrote: > > units = models.CharField(maxlength=2, choices=UNITS) > > > > When I try to create a new instance of this model in the admin, the initial > > value in the select list for the units field is a dashed line. What I'd like > > is to be able to define an initial value for this field, and have it already > > selected in the select list when I just enter the "add object" page. I've > > tried using the default keyword argument in various ways but to no avail. > > the 'default' keyword argument should work, but be sure to use the > stored-value (first) element from the stored/representation tuple you use. > > ie if your UNITS tuple is defined > > >>> UNITS = ( ('in', 'Inches'), ('cm', 'Centimeters'), ) > > you'll want to use > > >>> class MyModel(models.Model): > >>> units = models.CharField(maxlength=2, choices=UNITS, default='cm') > > -jake > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Multiple one-to-one relationships for a single class
On Tue, 2007-08-21 at 21:21 -0700, Catriona wrote: > Hello > > Is it possible to have multiple one-to-one relationships for a single > class or is there a better way to do it. Not at the moment, no. OneToOneFields assume they are going to be the primary key, so you're restricted to a single one. This is something we will fix in the future, since there are legitimate uses. If you wanted to dive deep, you could look in django/db/models/fields/related.py and try to fix this yourself, although I suspect it isn't completely trivial (it's not impossible, just not a five minute job). > What I have is an event which has about 12 fields. Optionally any > combination of a single weather record, a single event detail record, > a single survey record and one of four event subclass records may be > stored against this event. Each of these optional records has between > 5 and 12 fields each. I could put everything in one big table with > lots of nullable fields but that is not my preferred option. You can fake it with a ForeignKey, since that only allows one entry on the source model's end. The slight drawback is that each target instance (say, an event detail record) is not prohibited from being linked from two different event models by the database. Some checking in the save() method could fake this for you, though. Regards, Malcolm -- Borrow from a pessimist - they don't expect it back. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Multiple one-to-one relationships for a single class
Hello Is it possible to have multiple one-to-one relationships for a single class or is there a better way to do it. What I have is an event which has about 12 fields. Optionally any combination of a single weather record, a single event detail record, a single survey record and one of four event subclass records may be stored against this event. Each of these optional records has between 5 and 12 fields each. I could put everything in one big table with lots of nullable fields but that is not my preferred option. Any help would be appreciated. Thanks Catriona --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
r_f_d wrote: > As far as insert or update, just overide the save method within the > class. It is something that must be done for each class, but what I > have done (for essentially the same purpose) is override save() on > each model I need to log the action for like so: > > def save(): > # if id exists, this record has already been created > if foo.id: > # create the log entry for an update > else: > # create the log entry for an insert > super(foo, self).save() > This part is not entirely correct. Yes, it's true that if self.id (or whatever the primary key is) does not exist, then it's a create. However, just because self.id exists does not mean that it's an update. The Model class has a mechanism in save() that checks to make sure that the primary key exists in the DB. If it doesn't, it will do a create. Unfortunately, as it currently stands there's no way to distinguish this case without doing the SELECT on the PK yourself (the query or its results aren't accessible to user code in any way right now), which is why I recommended the post_save signal pending Trac ticket #4879's acceptance. gav --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
As far as insert or update, just overide the save method within the class. It is something that must be done for each class, but what I have done (for essentially the same purpose) is override save() on each model I need to log the action for like so: def save(): # if id exists, this record has already been created if foo.id: # create the log entry for an update else: # create the log entry for an insert super(foo, self).save() Do the same for delete() To make it easier I have abstracted my save and delete methods, they are defined as methods within my apps models.py and the individual model classes call them, passing (self) and getting back a 'model_instance' object for user with the super.save() -rfd On Aug 21, 1:20 pm, "Lic. José M. Rodriguez Bacallao" <[EMAIL PROTECTED]> wrote: > how can I know programatically if an operation in a model is an insert, > update or delete? > I just want to extend the admin log to log any action in my application > models. Right now, > admin app only log actions executed by itself. > > -- > Lic. José M. Rodriguez Bacallao > Cupet > - > Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo > mismo. > > Recuerda: El arca de Noe fue construida por aficionados, el titanic por > profesionales > - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: age in years calculation
Err, my bad. I wasn't thinking. I need to stop writing replies after having a few beers. ;) On Aug 21, 9:09 pm, Brian Rosner <[EMAIL PROTECTED]> wrote: > There isn't a solution to your particular problem. Your problem is > that you are accepting invalid data. Nobody can be born on a day that > doesn't exist. I'd recommend verifying that the data be entered into > the database is valid. > > On Aug 3, 5:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]> > wrote: > > > Hey Everyone, > > > does anyone have a good age in years calculation function for usage with > > datetime.date that returns the age in nr of years of a person? > > > We were using: > > > def get_age(self): > > now = datetime.today() > > birthday = datetime(now.year, self.birthday.month, self.birthday.day) > > return now.year - self.birthday.year - (birthday > now) > > > But the trouble is that this fails for people whose birthday falls on a > > leap-day! ( bday = 1980-02-29 => birthday this year doesn't exist :-) ) > > > For now I swaped to: > > > try: > > birthday = datetime(now.year, self.birthday.month, self.birthday.day) > > except ValueError: > > birthday = datetime(now.year, self.birthday.month, self.birthday.day-1) > > > But that seems such a hack :-)) > > > - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: age in years calculation
There isn't a solution to your particular problem. Your problem is that you are accepting invalid data. Nobody can be born on a day that doesn't exist. I'd recommend verifying that the data be entered into the database is valid. On Aug 3, 5:37 am, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > Hey Everyone, > > does anyone have a good age in years calculation function for usage with > datetime.date that returns the age in nr of years of a person? > > We were using: > > def get_age(self): > now = datetime.today() > birthday = datetime(now.year, self.birthday.month, self.birthday.day) > return now.year - self.birthday.year - (birthday > now) > > But the trouble is that this fails for people whose birthday falls on a > leap-day! ( bday = 1980-02-29 => birthday this year doesn't exist :-) ) > > For now I swaped to: > > try: > birthday = datetime(now.year, self.birthday.month, self.birthday.day) > except ValueError: > birthday = datetime(now.year, self.birthday.month, self.birthday.day-1) > > But that seems such a hack :-)) > > - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
On Tue, 2007-08-21 at 16:33 -0400, George Vilches wrote: > Lic. José M. Rodriguez Bacallao wrote: > > how can I vote? > > There's no official voting mechanism for the non-Django developers > right now, it's mostly just based on putting a comment on the Trac > ticket Please don't do this. It's just noise in the end. With thousands of people using Django, it's pretty much a given that any feature is going to have some non-zero amount of people wanting to use it for some purpose. Frankly, one person or six people or even 20 people saying they would use something isn't statistically representative. It's a self-selecting sample, for a start, and is a very small fraction of the user-base without reflecting the counter-arguments. The unintended downside is that lots of "I would use this" comments in Trac makes it harder to extract out the substantive technical comments about a ticket. That might sound harsh, but Trac is for tracking tickets, not as a voting mechanism or a place to resolve design discussions. I say this with all due respect, but as somebody who has to go through all the tickets that are filed and read the comments (and non-comments) and as somebody who often helps to make the decisions. You aren't helping yourselves by adding such comments and you're hurting others. Design discussions happen on django-dev, not in Trac. Thanks, Malcolm -- Quantum mechanics: the dreams stuff is made of. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ugettext vs. ugettext_lazy
On Tue, 2007-08-21 at 21:25 +0200, Tomas Kopecek wrote: > Malcolm Tredinnick napsal(a): > > makes 's1' a Unicode object. It's value will be based on the locale when > > it is executed and then never change, no matter what the locale is. So > > anything that is executed at *import* time should not be using > > ugettext(). Since it's a cause of great confusion for some people about > > what when particular lines are executed, I simplified a little in the > > docs and wrote "use ugettext_lazy() everywhere", since it's not actually > > harmful to do so. > > Oh, that's the paragraph I've been looking for. Note about *import* > time is crucial. I've should thought about it. Now it makes much more > sense. Everytime I've played with ugettext* I've used it inside > functions and so I didn't noticed this behaviour and everything looked > same for both of them. Maybe, it should be mentioned in documentation also. The whole i18n.txt document is on the table for a rewrite when I get some spare time. At the moment it's a bit of a mess. Explaining what functions to use when is one of the things I'm unhappy about, so, yes, I want to fix that. Regards, Malcolm -- If you think nobody cares, try missing a couple of payments. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mod_Python and Apache
On Aug 21, 5:43 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > The official mod_python mailing list details are atwww.modpython.org. > You posted to the mod_python Google group which no one uses. > > Also look through: > > http://blag.whit537.org/2007/07/freebsd-threads-apache-and-modwsgi.html > > and specifically the other pages it links to. You may need to work out > which threading library Python is wanting to use and which Apache may > be picking up. If they are different you may need to tweak system > config file to override which threading library is going to be used so > it is consistent and no possibility of conflict. > > You might also try and find a FreeBSD specific mailing list to raise > your problems. > > Also try mod_wsgi perhaps, but if it relates more to mixing Python and > Apache, then would expect you to see the same problem. > > Graham > > On Aug 22, 3:25 am, Sasha Weberov <[EMAIL PROTECTED]> wrote: > > > > > On Aug 20, 6:38 am, Graham Dumpleton <[EMAIL PROTECTED]> > > wrote: > > > > On Aug 20, 5:13 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: > > > > > On Aug 20, 12:13 am, Graham Dumpleton <[EMAIL PROTECTED]> > > > > wrote: > > > > > > On Aug 20, 3:01 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: > > > > > > > Is it normal to experience a sudden sharp spike in cpu and memory > > > > > > usage for about a minute or so after a start/stop and restart? I'm > > > > > > running the pre-fork mpm, FreeBSD 6.2, and latestmod_python. I've > > > > > > tried disableingmod_pythonand it went away, so it's clearly mod > > > > > > python. I know that the pre-fork mpm has dummy connections to signal > > > > > > processes to die off and that's evident in logs, can it be causing > > > > > > the > > > > > > spike because it's hitting " / "? I've tried the rewrites and all, > > > > > > but > > > > > > notta. > > > > > > > Any suggestions would be greatly appreciated. > > > > > > Do you see the spike as soon as you start Apache but before you even > > > > > try and access your Python web application, or does it only occur when > > > > > you first access the Python web application? If the latter, have you > > > > > tried a simple 'mptest' example as permod_pythondocumentation and > > > > > does it exhibit the same problem? Ie., eliminate it being anything to > > > > > do with Django, in which case you would be better off asking on the > > > > >mod_pythonmailing list. > > > > > > Other things to look at are whether your Python has been built to use > > > > > shared libraries or not. If it hasn't and yourmod_python.so is large > > > > > because it incorporates Python library, you will potentially be stuck > > > > > with private copy of Python library in every process and if you are > > > > > running with minimal memory on your system with lots of prefork > > > > > processes, you may well be running out of main memory and the box is > > > > > busily swapping to disk. How big are your Apache child processes on > > > > > initial startup and then subsequently after you have accessed your > > > > > Python web application? How big is yourmod_python.so module file. > > > > > > Graham > > > > > It happens as soon as Apache is started, or restarted. > > > average are 15-30mb. > > > > What other non standard Apache modules do you have loaded? That is > > > quite a lot of memory being used before anything actually happens, > > > although not entirely clear whether you are stating the whole virtual > > > memory of the processes or only resident memory. > > > No other non-standard modules. I'm looking at resident memory. > > > > How complicated is your Apache configuration. Do you do anything out > > > of the ordinary like define lots of VirtualHost containers? Do you use > > > PythonImport directive in your Apache configuration? > > > Not very complicated, only 2 vhosts, 1 php, and 1mod_python(Django) > > > > Do you know whether your Apache web server is compiled with --enable- > > > threads? Running: > > > > httpd -V > > > Server version: Apache/2.2.4 (FreeBSD) > > Server built: Jul 19 2007 23:34:23 > > Server's Module Magic Number: 20051115:4 > > Server loaded: APR 1.2.8, APR-Util 1.2.8 > > Compiled using: APR 1.2.8, APR-Util 1.2.8 > > Architecture: 32-bit > > Server MPM: Prefork > > threaded: no > > forked: yes (variable process count) > > Server compiled with > > -D APACHE_MPM_DIR="server/mpm/prefork" > > -D APR_HAS_SENDFILE > > -D APR_HAS_MMAP > > -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) > > -D APR_USE_FLOCK_SERIALIZE > > -D APR_USE_PTHREAD_SERIALIZE > > -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT > > -D APR_HAS_OTHER_CHILD > > -D AP_HAVE_RELIABLE_PIPED_LOGS > > -D DYNAMIC_MODULE_LIMIT=128 > > -D HTTPD_ROOT="/usr/local" > > -D SUEXEC_BIN="/usr/local/bin/suexec" > > -D DEFAULT_PIDLOG="/var/run/httpd.pid" > > -D DEFAULT_SCOREBOARD="/var/run/apache_runtime_status" > > -D DEFAULT_LOCKFILE="/var/run/accept.lock" > > -D DEFAULT_ERRORLOG="/var/log/httpd-error.log" > >
Re: GoFlow: a workflow engine for django
excellent! but almost us only read englist, pls translate you doc to englist! On 8月21日, 上午6时01分, MiloZ <[EMAIL PROTECTED]> wrote: > Hi, > I'm just starting a workflow engine for django, based on Zope2 > openflow product. > > Home:http://django-goflow.blogspot.com/(in french) > Dev trac:https://opensvn.csie.org/traccgi/openflow > > Take a look, your comments and ideas are welcome. > > Miloz --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: chinese django forum
Good! I am also a chineses, good work! On 8月22日, 上午12时15分, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > hi,list > I think there are many chinese django users,i think we can > exchange info herehttp://forum.devshare.org. > Make it the most popular django forum in china.Good luck all :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Tip:decorator and urls.py
I think do like below maybe more simple from django.shortcuts import render_to_response from django.template.context import RequestContext def template_name(func): def _template_name(request,template_name,*args,**keys): result=func(request,*args,**keys) if type(result)!=dict: return result return render_to_response( template_name, result, context_instance=RequestContext(request, result) ) return _template_name __ use like this @template_name def video(request,id): return { 'video':Video.objects.get(id=id) } 2006/12/29, limodou <[EMAIL PROTECTED]>: > > > -8<-- > > @template('template.html') > > def list(request): > > if success: > > #return HttpResponseRedirect('url') > > raise HttpRedirectException > > else: > > return errorinfo > > ->8-- > > I'm sorry, here has a bug, the > > raise HttpRedirectException > > should be: > > raise HttpRedirectException 'url' > > -- > I like python! > UliPad <>: http://wiki.woodpecker.org.cn/moin/UliPad > My Blog: http://www.donews.net/limodou > > > > -- 我的博客:http://zsp.javaeye.com/ -- 张沈鹏(ZhangShen Peng) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: using django components outside of django
On 8/21/07, Lee Connell <[EMAIL PROTECTED]> wrote: > I was wondering if it was easy and if there are examples of using > django's ORM and even the authentication system in contrib outside of > django, say in a twisted network application? http://groups.google.com/group/django-users/search?group=django-users=orm+outside+django_g=Search+this+group -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
using django components outside of django
I was wondering if it was easy and if there are examples of using django's ORM and even the authentication system in contrib outside of django, say in a twisted network 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Initial value for a choices field in admin?
hi amit, Amit Ramon wrote: > units = models.CharField(maxlength=2, choices=UNITS) > > When I try to create a new instance of this model in the admin, the initial > value in the select list for the units field is a dashed line. What I'd like > is to be able to define an initial value for this field, and have it already > selected in the select list when I just enter the "add object" page. I've > tried using the default keyword argument in various ways but to no avail. the 'default' keyword argument should work, but be sure to use the stored-value (first) element from the stored/representation tuple you use. ie if your UNITS tuple is defined >>> UNITS = ( ('in', 'Inches'), ('cm', 'Centimeters'), ) you'll want to use >>> class MyModel(models.Model): >>> units = models.CharField(maxlength=2, choices=UNITS, default='cm') -jake --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: index page
Rufman wrote: > do you by any chance know how the django admin page gets the help_text > from the model...e.i. how can i get the help_text without having to > define it again in my custom form? you can use something like: >>> modelinstance._meta.get_field('myfield').help_text where modelinstance is an instance of your model and myfield is the name of the field you want to inspect. is that what you're looking for? newforms form_for_model also brings the model's help_text options in: >>> import django.newforms as forms >>> ModelFormClass = forms.models.form_for_model(Model) >>> ModelFormClass.base_fields['myfield'].help_text -jake --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mod_Python and Apache
The official mod_python mailing list details are at www.modpython.org. You posted to the mod_python Google group which no one uses. Also look through: http://blag.whit537.org/2007/07/freebsd-threads-apache-and-modwsgi.html and specifically the other pages it links to. You may need to work out which threading library Python is wanting to use and which Apache may be picking up. If they are different you may need to tweak system config file to override which threading library is going to be used so it is consistent and no possibility of conflict. You might also try and find a FreeBSD specific mailing list to raise your problems. Also try mod_wsgi perhaps, but if it relates more to mixing Python and Apache, then would expect you to see the same problem. Graham On Aug 22, 3:25 am, Sasha Weberov <[EMAIL PROTECTED]> wrote: > On Aug 20, 6:38 am, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > > > On Aug 20, 5:13 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: > > > > On Aug 20, 12:13 am, Graham Dumpleton <[EMAIL PROTECTED]> > > > wrote: > > > > > On Aug 20, 3:01 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: > > > > > > Is it normal to experience a sudden sharp spike in cpu and memory > > > > > usage for about a minute or so after a start/stop and restart? I'm > > > > > running the pre-fork mpm, FreeBSD 6.2, and latestmod_python. I've > > > > > tried disableingmod_pythonand it went away, so it's clearly mod > > > > > python. I know that the pre-fork mpm has dummy connections to signal > > > > > processes to die off and that's evident in logs, can it be causing the > > > > > spike because it's hitting " / "? I've tried the rewrites and all, but > > > > > notta. > > > > > > Any suggestions would be greatly appreciated. > > > > > Do you see the spike as soon as you start Apache but before you even > > > > try and access your Python web application, or does it only occur when > > > > you first access the Python web application? If the latter, have you > > > > tried a simple 'mptest' example as permod_pythondocumentation and > > > > does it exhibit the same problem? Ie., eliminate it being anything to > > > > do with Django, in which case you would be better off asking on the > > > >mod_pythonmailing list. > > > > > Other things to look at are whether your Python has been built to use > > > > shared libraries or not. If it hasn't and yourmod_python.so is large > > > > because it incorporates Python library, you will potentially be stuck > > > > with private copy of Python library in every process and if you are > > > > running with minimal memory on your system with lots of prefork > > > > processes, you may well be running out of main memory and the box is > > > > busily swapping to disk. How big are your Apache child processes on > > > > initial startup and then subsequently after you have accessed your > > > > Python web application? How big is yourmod_python.so module file. > > > > > Graham > > > > It happens as soon as Apache is started, or restarted. > > average are 15-30mb. > > > What other non standard Apache modules do you have loaded? That is > > quite a lot of memory being used before anything actually happens, > > although not entirely clear whether you are stating the whole virtual > > memory of the processes or only resident memory. > > No other non-standard modules. I'm looking at resident memory. > > > > > How complicated is your Apache configuration. Do you do anything out > > of the ordinary like define lots of VirtualHost containers? Do you use > > PythonImport directive in your Apache configuration? > > Not very complicated, only 2 vhosts, 1 php, and 1mod_python(Django) > > > Do you know whether your Apache web server is compiled with --enable- > > threads? Running: > > > httpd -V > > Server version: Apache/2.2.4 (FreeBSD) > Server built: Jul 19 2007 23:34:23 > Server's Module Magic Number: 20051115:4 > Server loaded: APR 1.2.8, APR-Util 1.2.8 > Compiled using: APR 1.2.8, APR-Util 1.2.8 > Architecture: 32-bit > Server MPM: Prefork > threaded: no > forked: yes (variable process count) > Server compiled with > -D APACHE_MPM_DIR="server/mpm/prefork" > -D APR_HAS_SENDFILE > -D APR_HAS_MMAP > -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) > -D APR_USE_FLOCK_SERIALIZE > -D APR_USE_PTHREAD_SERIALIZE > -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT > -D APR_HAS_OTHER_CHILD > -D AP_HAVE_RELIABLE_PIPED_LOGS > -D DYNAMIC_MODULE_LIMIT=128 > -D HTTPD_ROOT="/usr/local" > -D SUEXEC_BIN="/usr/local/bin/suexec" > -D DEFAULT_PIDLOG="/var/run/httpd.pid" > -D DEFAULT_SCOREBOARD="/var/run/apache_runtime_status" > -D DEFAULT_LOCKFILE="/var/run/accept.lock" > -D DEFAULT_ERRORLOG="/var/log/httpd-error.log" > -D AP_TYPES_CONFIG_FILE="etc/apache22/mime.types" > -D SERVER_CONFIG_FILE="etc/apache22/httpd.conf" > > ^ No Doesn't look like it is. > > > > > Is your Python compiled with threads? You can tell by trying to import > > 'threading' from interpreter. > > > $ python > >
Re: Importing Excel/CVS into Database
On Aug 21, 8:37 pm, robo <[EMAIL PROTECTED]> wrote: > Have any of you guys imported excel/cvs by using Python/Django? I need > to import 1000 products for a shopping site and I'd like to learn the > fastest and easiest way to do so. I already did this, but in another way. 1. I write Models, 2. I parse line by line the csv file (using python library) 3. create for each line a Model Instance with the data extracted from the file I prefer, because I had to change some values, and I prefer to do this in python :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem using external CSS file with template
While I was writing reply to you Will, I've decided to try once more, just to make sure that I didn't make some stupid mistake, and surprisingly it worked! Only difference is that I've tried it on another computer. Now I know for sure that there is nothing wrong with Django or me. It's relief :) I suppose that it will be much easier now to figure it out why it didn't work on my development computer. Thanks for your help. Petar On Aug 21, 8:52 pm, Will McCutchen <[EMAIL PROTECTED]> wrote: > Hi, > > On Aug 21, 1:44 pm, arelenas <[EMAIL PROTECTED]> wrote: > > > I've set URLConf as described > > athttp://www.djangoproject.com/documentation/0.96/static_files/, > > but still nothing. It finds CSS file but styles won't apply. > > What does your URLConf look like? What is the URL you are using to > link to the CSS file in your template (ie, what replaces "XXX" in > )? > > Will. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Importing Excel/CVS into Database
Yes, I've done that. The following function read_excel_csv works with Excel CSV files saved on Mac (I can't remember exactly, but it might be that MS Office for Mac OS X saves CSV files using different separators than on Windows). The function reads the rows line by line, parses the cells of each row and passes the values in a list to your custom function. ### import csv def test(l): print l def read_excel_csv(filepath, function): f = open(filepath, "rb") line_list = "".join(f.readlines()).split("\r") reader = csv.reader(line_list, delimiter=";", doublequote=True) for value_list in reader: function(value_list) >>> read_excel_csv("/some/path/table.csv", test) ### Good luck! Aidas Bendoraitis aka Archatas On 8/21/07, olivier <[EMAIL PROTECTED]> wrote: > > > Have any of you guys imported excel/cvs by using Python/Django? I need > > to import 1000 products for a shopping site and I'd like to learn the > > fastest and easiest way to do so. > > > If you need to load data straight from the Excel, you can use xlrd, > which works great. > > http://www.lexicon.net/sjmachin/xlrd.htm > > Regards, > > Olivier > > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
On 8/21/07, George Vilches <[EMAIL PROTECTED]> wrote: > or in the mailing list saying that you would use this > functionality for such and such a reason. OK, I'll specify the reason We use web as administrative/configuration tool for non-web based back-office server and we need to synchronize its DB with Django database. We use post signals to maintain change log containing all records which has to be replicated. We'd appreciate if we could distinct between insert and update operations Thanks, Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
Lic. José M. Rodriguez Bacallao wrote: > how can I vote? There's no official voting mechanism for the non-Django developers right now, it's mostly just based on putting a comment on the Trac ticket or in the mailing list saying that you would use this functionality for such and such a reason. It's an informal system, it just helps the core developers gauge how much interest (for legitimate reasons or otherwise) there is in something. Doesn't ever mean it's worthwhile or will get accepted. :) gav --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
how can I vote? On 8/21/07, Peter Melvyn <[EMAIL PROTECTED]> wrote: > > > On 8/21/07, George Vilches <[EMAIL PROTECTED]> wrote: > > > http://code.djangoproject.com/ticket/4879 > > If you need that functionality, add a vote for it. :) > > Yes, I need such functionality :) > > Peter > > > > -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
On 8/21/07, George Vilches <[EMAIL PROTECTED]> wrote: > http://code.djangoproject.com/ticket/4879 > If you need that functionality, add a vote for it. :) Yes, I need such functionality :) Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Importing Excel/CVS into Database
> Have any of you guys imported excel/cvs by using Python/Django? I need > to import 1000 products for a shopping site and I'd like to learn the > fastest and easiest way to do so. If you need to load data straight from the Excel, you can use xlrd, which works great. http://www.lexicon.net/sjmachin/xlrd.htm Regards, Olivier --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ugettext vs. ugettext_lazy
Malcolm Tredinnick napsal(a): > makes 's1' a Unicode object. It's value will be based on the locale when > it is executed and then never change, no matter what the locale is. So > anything that is executed at *import* time should not be using > ugettext(). Since it's a cause of great confusion for some people about > what when particular lines are executed, I simplified a little in the > docs and wrote "use ugettext_lazy() everywhere", since it's not actually > harmful to do so. Oh, that's the paragraph I've been looking for. Note about *import* time is crucial. I've should thought about it. Now it makes much more sense. Everytime I've played with ugettext* I've used it inside functions and so I didn't noticed this behaviour and everything looked same for both of them. Maybe, it should be mentioned in documentation also. -- Tomas Kopecek e-mail: permonik at mesias.brnonet.cz ICQ: 114483784 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Importing Excel/CVS into Database
> Have any of you guys imported excel/cvs by using > Python/Django? I need to import 1000 products for a shopping > site and I'd like to learn the fastest and easiest way to do > so. I do this day in and day out :) I prefer tab-delimited because it's easy and clean, though Python's built-in "csv" module can ease the pain of working with csv (which I presume you mean, rather than CVS, which is the Concurrent Versioning System) I usually just write INSERT statements by hand, directly using the DB interface for my backend (PostgreSQL in this case) and then run a little Python code to iterate over the file and spew the data into the system: filename = 'foo.tab' for i, line in enumerate(open(filename)): if i == 0: continue # skip the header row (fieldname1, fieldname2, fieldname3 ... ) = line.rstrip('\n').split('\t') cursor.execute(""" INSERT INTO app_foo (f1, f3, f2) VALUES (%s, %s, %s) """, (fieldname1, fieldname3, fieldname2) ) You may have to do lookups into other tables, etc, but this is generally how I do it. Things can also get fancier if your input file can have the columns in any arbitrary order. The above simply From within a running Django app, you can make use of the ORM to ease some of the annoyances, but when bulk-loading the data repeatedly (several thousand rows of data, multiple times per day), I personally like the control of raw SQL to eke out the last bit of performance from my DB connection. I've seen some tools that try to ease this for you, but I've never been impressed by them, as I end up spending as much time fiddling with them as it would take me to bang out some python code to do the same thing. -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem using external CSS file with template
Hi, On Aug 21, 1:44 pm, arelenas <[EMAIL PROTECTED]> wrote: > I've set URLConf as described > athttp://www.djangoproject.com/documentation/0.96/static_files/, > but still nothing. It finds CSS file but styles won't apply. What does your URLConf look like? What is the URL you are using to link to the CSS file in your template (ie, what replaces "XXX" in )? Will. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem using external CSS file with template
I am trying to use external CSS in template using built-in Django web server but I'm experiencing some problems. I've set URLConf as described at http://www.djangoproject.com/documentation/0.96/static_files/, but still nothing. It finds CSS file but styles won't apply. When I try to use inline CSS everything works just fine. Please, can someone help me, I bumping my head with this for hours. :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Importing Excel/CVS into Database
On Tuesday 21 August 2007, robo wrote: > Have any of you guys imported excel/cvs by using Python/Django? Check out "pydoc csv". Python ships with a nice CSV-reader module. -- Kirk Strauser signature.asc Description: This is a digitally signed message part.
Importing Excel/CVS into Database
Hi, Have any of you guys imported excel/cvs by using Python/Django? I need to import 1000 products for a shopping site and I'd like to learn the fastest and easiest way to do so. Is there any free/shareware programs you guys would recommend? Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: insert or update
Lic. José M. Rodriguez Bacallao wrote: > how can I know programatically if an operation in a model is an insert, > update or delete? > I just want to extend the admin log to log any action in my application > models. Right now, > admin app only log actions executed by itself. Part of your question can be answered with the use of signals. See this page: http://code.djangoproject.com/wiki/Signals The ones that are most important to you are (pre|post)_save and (pre|post)_delete. With this, you can distinguish between an insert/update pair and a delete. However, part of your question, distinguishing between an insert and an update, isn't yet part of the Django core. You could try checking for the ID while you're in one of the signals, but that's not exactly reliable. This ticket would give a "created=True/False" on the post_save signal, which would allow you capture exactly the information you want: http://code.djangoproject.com/ticket/4879 If you need that functionality, add a vote for it. :) Anyway, with these bits, you should be able to add the signals in your app to catch all the changes, and then you could write them somewhere. Either hook into the Admin app and continue adding to the logger there, or start using an AuditTrail to track *all* changes and keep a full history of them. http://code.djangoproject.com/wiki/AuditTrail Good luck! gav --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
insert or update
how can I know programatically if an operation in a model is an insert, update or delete? I just want to extend the admin log to log any action in my application models. Right now, admin app only log actions executed by itself. -- Lic. José M. Rodriguez Bacallao Cupet - Todos somos muy ignorantes, lo que ocurre es que no todos ignoramos lo mismo. Recuerda: El arca de Noe fue construida por aficionados, el titanic por profesionales - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: In-line Comments
Don't know if you're only looking for a django solution, but if you just need something that (AFAIK) works, this might do it: http://www.futureofthebook.org/commentpress/ thin layer over Wordpress to allow comments similar to djangobook, but in the sidebar instead of fancy little popup windows. On Aug 18, 5:51 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > we're currently translating this book:www.producingoss.com > and I'm trying to find an in-line comment system similar to the one > used by the djangobook of the fsf for their licences. I read somewhere > that the code for that was in an unreleaseable state, but somewhere > else that they would be releasing it. > So the question is, if anybody is aware of an in-line comment system > we could use or build upon, otherwise I guess I'll try and do > something myself. > > Good book btw. and well worth reading and you are of course more than > welcome to participate in the translation. > > ciao > Manuel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Mod_Python and Apache
On Aug 20, 6:38 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Aug 20, 5:13 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: > > > > > > > On Aug 20, 12:13 am, Graham Dumpleton <[EMAIL PROTECTED]> > > wrote: > > > > On Aug 20, 3:01 pm, Sasha Weberov <[EMAIL PROTECTED]> wrote: > > > > > Is it normal to experience a sudden sharp spike in cpu and memory > > > > usage for about a minute or so after a start/stop and restart? I'm > > > > running the pre-fork mpm, FreeBSD 6.2, and latest mod_python. I've > > > > tried disableing mod_python and it went away, so it's clearly mod > > > > python. I know that the pre-fork mpm has dummy connections to signal > > > > processes to die off and that's evident in logs, can it be causing the > > > > spike because it's hitting " / "? I've tried the rewrites and all, but > > > > notta. > > > > > Any suggestions would be greatly appreciated. > > > > Do you see the spike as soon as you start Apache but before you even > > > try and access your Python web application, or does it only occur when > > > you first access the Python web application? If the latter, have you > > > tried a simple 'mptest' example as per mod_python documentation and > > > does it exhibit the same problem? Ie., eliminate it being anything to > > > do with Django, in which case you would be better off asking on the > > > mod_python mailing list. > > > > Other things to look at are whether your Python has been built to use > > > shared libraries or not. If it hasn't and your mod_python.so is large > > > because it incorporates Python library, you will potentially be stuck > > > with private copy of Python library in every process and if you are > > > running with minimal memory on your system with lots of prefork > > > processes, you may well be running out of main memory and the box is > > > busily swapping to disk. How big are your Apache child processes on > > > initial startup and then subsequently after you have accessed your > > > Python web application? How big is your mod_python.so module file. > > > > Graham > > > It happens as soon as Apache is started, or restarted. > average are 15-30mb. > > What other non standard Apache modules do you have loaded? That is > quite a lot of memory being used before anything actually happens, > although not entirely clear whether you are stating the whole virtual > memory of the processes or only resident memory. > No other non-standard modules. I'm looking at resident memory. > > How complicated is your Apache configuration. Do you do anything out > of the ordinary like define lots of VirtualHost containers? Do you use > PythonImport directive in your Apache configuration? > Not very complicated, only 2 vhosts, 1 php, and 1 mod_python (Django) > > Do you know whether your Apache web server is compiled with --enable- > threads? Running: > > httpd -V > Server version: Apache/2.2.4 (FreeBSD) Server built: Jul 19 2007 23:34:23 Server's Module Magic Number: 20051115:4 Server loaded: APR 1.2.8, APR-Util 1.2.8 Compiled using: APR 1.2.8, APR-Util 1.2.8 Architecture: 32-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_FLOCK_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/usr/local" -D SUEXEC_BIN="/usr/local/bin/suexec" -D DEFAULT_PIDLOG="/var/run/httpd.pid" -D DEFAULT_SCOREBOARD="/var/run/apache_runtime_status" -D DEFAULT_LOCKFILE="/var/run/accept.lock" -D DEFAULT_ERRORLOG="/var/log/httpd-error.log" -D AP_TYPES_CONFIG_FILE="etc/apache22/mime.types" -D SERVER_CONFIG_FILE="etc/apache22/httpd.conf" ^ No Doesn't look like it is. > > Is your Python compiled with threads? You can tell by trying to import > 'threading' from interpreter. > > $ python > Python 2.3.5 (#1, Mar 20 2005, 20:38:20) > [GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin > Type "help", "copyright", "credits" or "license" for more information. > > >>> import threading > I was able to type "import threading". Does that mean it's compiled with threads? I'm using Python 2.5. > FreeBSD still appears to have various problems with its threading when > using Apache. If Python is using threading and Apache isn't, there may > be a clash in terms of which threading libraries are used. I know > people who simply haven't been able to get threaded Apache to work at > all on FreeBSD. > I see, I don't believe I have anything threaded unless it's Python that is threaded. > You might want to take this whole issue over to the mod_python mailing > list as it would appear not to be Django specific, unless you are > using PythonImport to import a module which is in turn import Django > at Apache startup rather than first request. > I've tried and got no
Re: ImageField via admin
Hello Carl Karsten! On Tue, 21 Aug 2007 10:21:06 -0500 you wrote: > > Grigory Fateyev wrote: > > Hello Carl Karsten! > > On Mon, 20 Aug 2007 14:07:39 -0500 you wrote: > > > >>> settings.py:MEDIA_ROOT = BASE_DIR+'/media/' > >>> settings.py:MEDIA_URL = '/site_media/' > >>> urls.py:(r'^site_media/(?P.*)$', > >>> 'django.views.static.serve', {'document_root': > >>> settings.BASE_DIR+'/media/', 'show_indexes':True}), > >>> > >>> Revision: 5946 > >>> > >> I used your settings, no problem. > >> > >> Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) > >> > >> [EMAIL PROTECTED]:~/django/django_src$ svn up > >> Updated to revision 5988. > >> > >> Carl K > > > > That means you can add any object to Book class without problem? > > > > Thanks! > > yep. edit too. > > I suggest making a new site/project, add the model, make the few > changes to settings and run the dev server. > > Carl K Very funny, but new project with the only class "Book" return the same error: Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py" in get_response 77. response = callback(request, *callback_args, **callback_kwargs) File "/usr/lib/python2.4/site-packages/django/contrib/admin/views/decorators.py" in _checklogin 51. if 'post_data' in request.POST: File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in _get_post 136. self._load_post_and_files() File "/usr/lib/python2.4/site-packages/django/core/handlers/wsgi.py" in _load_post_and_files 114. self._post, self._files = http.parse_file_upload(self.environ['wsgi.input'], self.environ) File "/usr/lib/python2.4/site-packages/django/http/__init__.py" in parse_file_upload 71. raw_message = '\r\n'.join(['%s:%s' % pair for pair in header_dict.items()]) AttributeError at /admin/books/book/add/ '_fileobject' object has no attribute 'items' -- Всего наилучшего! Григорий greg [at] anastasia [dot] ru Письмо отправлено: 2007/08/21 20:43 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to make a mapping/alias db table? (many-to-many)
I've had 20 tabs open all day, all displaying django docs - but I can't work this out. A bookmark can have many categories, and a category can be in many bookmarks. So I just want a simple table that consists of category_id, bookmark_id >From the docs I thought Django would create this automatically but syncdb doesn't add it. How do I add categories to my bookmarks? Here are the models: class Category(models.Model): name = models.CharField(max_length=255) class Bookmark(models.Model): name = models.CharField(max_length=255) description = models.CharField(max_length=255) url = models.CharField(max_length=255) categories = models.ManyToManyField(Category) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
chinese django forum
hi,list I think there are many chinese django users,i think we can exchange info here http://forum.devshare.org. Make it the most popular django forum in china.Good luck all :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template within a Template?
Actually I need another clue... I'm getting very confused about how to structure my Python projects/ apps. In settings.py: TEMPLATE_DIRS = ( "C:/Python/my_templates", ) In my template dir: mylinks/ mylinks/base_site.html mylinks/bookmark_list.html (extends base_site) Now in bookmark_list.html I have to say extends mylinks/base_site.html for it to find everything. If I change the tempalte dir in settings.py to "C:/Python/ my_templates/mylinks" then it looks for the first template in: C:/ Python/my_templates/mylinks/mylinks/ Can someone please tell me a generic structure, or something? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Odd 404 error on Textdrive with Lighty
For prosperities sake I will finish out what was causing the issue. RajeshD pointed out that the media url was being mapped directly to lighty. Which it was. So I moved all static media to a dir called 'static' and removed the line in the lighty vhost that maps media to lighty. Now it all works beautifully. Thanks for the tip RajeshD! On 8/20/07, David Merwin <[EMAIL PROTECTED]> wrote: > Thanks again for all your help. That makes a ton of sense. > > Here is my vhost: http://dpaste.com/hold/17389/ > > Here is docs for this setup: http://textusers.com/wiki/Installing_Django_0.95 > > What do you think? > > Lemme know. > > Dave > > On 8/20/07, RajeshD <[EMAIL PROTECTED]> wrote: > > > > > > > > On Aug 20, 7:53 pm, "David Merwin" <[EMAIL PROTECTED]> wrote: > > > http://stpaulswired.org/media/audio/2007/aug/05/straight-from-t/is > > > teh main one and then derivitaves of the same: > > > > > > http://stpaulswired.org/media/audio/2007/aug/05/http://stpaulswired.org/media/audio/2007/aug/ > > > > > > Thanks so much for the help. > > > > It looks like, in your lighttpd config, /media/* is mapped directly to > > the filesystem. That's why it's not going through Django's URL config > > when you use the /media/* URLs. You should check your lighttpd config > > (or paste it, if you'd like some help with it.) > > > > > > > > > > > > > -- > Dave Merwin > http://www.purebluedesign.com > http://www.davemerwin.com > http://www.betachurch.org > cell: 541.335.1832 > My Profile: http://www.linkedin.com/in/merwin > -- Dave Merwin http://www.purebluedesign.com http://www.davemerwin.com http://www.betachurch.org cell: 541.335.1832 My Profile: http://www.linkedin.com/in/merwin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: tutorial
Check to make sure you're defining the __str__(self) on your poll object. That indicates that the object does not know how to turn itself into a string. (note that with trunk the best practice way to do this will be __unicode__ but with any of the static releases the new unicode method will not work. On 8/21/07, wiboc <[EMAIL PROTECTED]> wrote: > > I'm starting django and doing the tutorial. > > Whet trying the admin pages, the foreign-key poll in the class choises > shows not the reference but: > -, > poll object > poll object > > why doesn't this works? > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ImageField via admin
Grigory Fateyev wrote: > Hello Carl Karsten! > On Mon, 20 Aug 2007 14:07:39 -0500 you wrote: > >>> settings.py:MEDIA_ROOT = BASE_DIR+'/media/' >>> settings.py:MEDIA_URL = '/site_media/' >>> urls.py:(r'^site_media/(?P.*)$', >>> 'django.views.static.serve', {'document_root': >>> settings.BASE_DIR+'/media/', 'show_indexes':True}), >>> >>> Revision: 5946 >>> >> I used your settings, no problem. >> >> Python 2.5.1 (r251:54863, May 2 2007, 16:56:35) >> >> [EMAIL PROTECTED]:~/django/django_src$ svn up >> Updated to revision 5988. >> >> Carl K > > That means you can add any object to Book class without problem? > > Thanks! yep. edit too. I suggest making a new site/project, add the model, make the few changes to settings and run the dev server. Carl K --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template within a Template?
Thanks :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template within a Template?
> I want all of my "views" (HTML pages) to use a common header, footer > etc. > > What is the python/django way of achieving this? http://www.djangoproject.com/documentation/templates/#template-inheritance It's somewhat backwards from how other template-languages work that I've used, but it makes sense in the context and works well. Your base template is what everything has in common, and then you fill in the holes with specifics. To fill in holes with mixed content, it works well to use custom template tags to reduce redundant rendering code: http://www.djangoproject.com/documentation/templates_python/#writing-custom-template-tags "Writing your own template language extensions" sounds daunting, but the Django developers have really made it about as easy as it could possibly be...just follow the examples in the above link and, poof, you have a custom template tag. -tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template within a Template?
On 21-Aug-07, at 8:20 PM, b3n wrote: > What is the python/django way of achieving this? template inheritance -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Template within a Template?
I want all of my "views" (HTML pages) to use a common header, footer etc. What is the python/django way of achieving this? I need to know because if I have to change the header/footer, then I only want to have to do it one place, rather than editing every template file. I can't get my head around this, maybe because I'm so used to PHP. Thanks, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
tutorial
I'm starting django and doing the tutorial. Whet trying the admin pages, the foreign-key poll in the class choises shows not the reference but: -, poll object poll object why doesn't this works? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: In-line Comments
> So the question is, if anybody is aware of an in-line comment system > we could use or build upon, otherwise I guess I'll try and do > something myself. A good starting point: http://www.jackslocum.com/blog/2006/10/09/my-wordpress-comments-system-built-with-yahoo-ui-and-yahooext/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: quiz design
On Aug 19, 10:40 pm, "Ramdas S" <[EMAIL PROTECTED]> wrote: > Hi, > > Has anyone worked on a quiz/ multiple choice contest design using Django > using Newforms? Yes. http://popteen.com/feature/view/style/looks/what-s-your-sunbathing-style-/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FileField: changing file names
> dscn0001___.jpg > dscn0001.jpg > dscn0001_.jpg > > I could override the save() method to save the files under / > , but that would make the get_FOO_url and others fail. No it won't. As long as your ImageField ends up pointing to the correct relative path of your renamed image file (relative to settings.MEDIA_ROOT), all the get_FOO_* methods will 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: localflavor - UKPostcodeField
Thats a very valid point Malcolm and something I'll implement! On Aug 21, 12:22 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2007-08-21 at 02:20 -0700, MikeHowarth wrote: > > So really I'd be better off using: > > > from django.contrib.localflavor.uk import forms > > If, in the same file, you also do "import newforms as forms", things are > going to go pear-shaped pretty quickly, so be careful. > > My gut reaction, if I'm importing "extra" stuff like this and it's using > a common name, is to immediately, defensively alias it to something like > uk_forms so that even three months from now, I don't spend forever > trying to debug why "forms" doesn't contain what I expect it to. > > Malcolm > > -- > A clear conscience is usually the sign of a bad > memory.http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Database Fields
Thanks, Actually I was referring to the django admin tables as mentioned . I didn't define those models! None of these issues are a huge problem - but I'm a perfectionist ;) Ben, On Aug 17, 2:36 pm, Michal Ludvig <[EMAIL PROTECTED]> wrote: > b3n wrote: > > Thanks, > > > OK, but if a field value is only ever going to be 0 or 1, why make it > > signed? It's misleading. > > Signed is MySQL default. Use e.g. PositiveSmallIntegerField if you want > it unsigned. > > > And what is the purpose of INT(11), why should it be that instead of > > INT(10) ? > > Again, MySQL default for INT fields. The "11" is misleading, I agree, > but blame MySQL, not Django for that. Django only creates an INT field > and MySQL shows it as INT(11), that's all. For you it's only a visual > inconvenience, nothing performance related or things like that. > > > After looking at the created tables, I'm going off Django! =/ > > A bit unfair, Django just created whatever was specified in *your* > model. Suggested reading:http://www.djangoproject.com/documentation/model-api > > Michal --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: ugettext vs. ugettext_lazy
On Tue, 2007-08-21 at 00:09 +0200, Tomas Kopecek wrote: > Hello, > I've been playing with these functions and finally I've become totally > confused. > > I've expected that there would be some difference in behaviour, but I > was not able to create such use case in which these two functions > produces different results. More precisely, I haven't find place where > would be better to use ugettext_lazy. In documentation is said to use > this function in models.py everywhere. But for me it looks that ugettext > makes the same work. All text marked to translation is translated > accordingly to locale set by user via browser with both of them. There is quite a large difference. Noticing it would depend where you are using them. The difference is that ugettext() is a straight function call that returns the translation result immediately. Executing s1 = ugettext('redirect') makes 's1' a Unicode object. It's value will be based on the locale when it is executed and then never change, no matter what the locale is. So anything that is executed at *import* time should not be using ugettext(). Since it's a cause of great confusion for some people about what when particular lines are executed, I simplified a little in the docs and wrote "use ugettext_lazy() everywhere", since it's not actually harmful to do so. Have a look at the following fragment. Everywhere I am using _(), it is important to use ugettext_lazy, not ugettext: class Example(models.Model): name = models.CharField(_('Your name'), max_length = 100) class Meta: verbose_name = _('An example') Both of those lines are executed at import time. To see this in action, load a model like this into the Admin interface and view it. Now change your browser's locale and don't restart anything on the server. Reload the page. If you are using ugettext() and not the lazy variant, the displayed string will not change, because the function isn't called again. If you use ugettext_lazy, the displayed form is locale-aware (obviously if you are testing this, use some strings that are translated. I tend to use the string "redirect" a lot, because most locales have translated that one in Django's core). This test might need some persistence to replicate if you are using something like a multi-process web-server since you need to hit the same piece of code twice -- once to force the first translation and once to force it to be redisplayed to see the difference. The Django dev server is ideal for showing the effects, though, since it's single-threaded and only a single process. Other places where ugettext_lazy might be reqiured because the code is executed at import time are default arguments to views and form classes that you create at the module level somewhere. > Furthermore i was not able to use template strings and stay in __proxy__ > mode. anything like ugettext_lazy('xyz %s') % 'some_text' comes to > unicode string representation immediately. So, it looks there is no way > to use template strings with *_lazy. From my view it is little bit > painful to use it. Normally, you would be doing the substitution very close to where you are using the string. At least in the same execution thread and already in the right locale. So it doesn't typically matter that it now becomes a Unicode string. However full generality would be nice. Unfortunately, it's very hard to make something that understands the '%' operator and returns the right object so that it will retain it's laziness without breaking other usages. If you come up with a way to do that, feel free to submit a patch. If you really need a case where you need to use ugettext_lazy and apply a subsitution *and* have it only evaluated much later in another locale setting, you probably want to investigate the use of django.utils.functional.lazy(). You give it a function and a return type (or a number of return types) and it returns something that is only evaluated when used as one of those return types. This is exactly how ugettext_lazy() and friends are created. Again, if you come up with something that might have broad use, submit a patch. Our i18n support is driven by user requests. django.utils.translation.string_concat might also be useful in some cases (we use it internally for a few things): it provides a way to do the equivalent of ''.join([...]), but evaluated only when needed. Regards, Malcolm -- Two wrongs are only the beginning. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: db-api optimization
Yes sorry, In this example I didn't realize about that, but in my code I have Q objects. I wrote it very quick. On 21 ago, 10:27, Collin Grady <[EMAIL PROTECTED]> wrote: > That probably isn't what you want, though it will work (technically > speaking) > > The way you're doing it, that's going to chain the filters with AND, > not OR, so only things that match the title and description for all > words will show up. > > You probably want to build a Q object with | for an OR lookup > instead :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: index page
do you by any chance know how the django admin page gets the help_text from the model...e.i. how can i get the help_text without having to define it again in my custom 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
#4165: upload progress in safari
Hello, Has anyone gotten the file upload progress bar from ticket #4165 to work in safari? It works great in IE and FF, but so far no luck on safari. For some reason the xmlhttp requests get stuck on readyState 1 when a file upload is in progress. When I run them without a file upload, the readyStates reach 4 as expected. Does anyone have experience with xmlhttp and safari? Do mind that I'm testing with safari 3 for windows. Thanks, Simon --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: localflavor - UKPostcodeField
So really I'd be better off using: from django.contrib.localflavor.uk import forms On Aug 21, 9:35 am, Collin Grady <[EMAIL PROTECTED]> wrote: > The same question applies though :) > > You didn't import the "forms" bit, you imported the field directly, so > you should just be using it as UKPostcodeField :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: index page
thanks...worked like a charm On Aug 21, 10:18 am, MikeHowarth <[EMAIL PROTECTED]> wrote: > It really depends on how complicated you want to make it. > > However using generic views would easily suffice, just set up a > dictionary of the objects you need to pass in. Something like: > django.views.generic.simple.direct_to_template would do the job. > > On Aug 21, 9:12 am, Rufman <[EMAIL PROTECTED]> wrote: > > > hi > > > does anyone have a good idea how i could make an index page that > > combines different apps. e.g. the results of a poll is shown as well > > as a news feed next to it. > > > thanks > > > stephane rufer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: index page
thanks...worked like a charm On Aug 21, 10:18 am, MikeHowarth <[EMAIL PROTECTED]> wrote: > It really depends on how complicated you want to make it. > > However using generic views would easily suffice, just set up a > dictionary of the objects you need to pass in. Something like: > django.views.generic.simple.direct_to_template would do the job. > > On Aug 21, 9:12 am, Rufman <[EMAIL PROTECTED]> wrote: > > > hi > > > does anyone have a good idea how i could make an index page that > > combines different apps. e.g. the results of a poll is shown as well > > as a news feed next to it. > > > thanks > > > stephane rufer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Unicode question
On Mon, 2007-08-20 at 17:27 +, arthur debert wrote: > Hi Rob. > > After the unicode branch merge django expects and produces unicodes > objects throughout. > > A detail how to port guide is here: > http://code.djangoproject.com/wiki/UnicodeBranch#PortingApplicationsTheQuickChecklist > > In this specific case, you can call "lower" directly on your unicode > object: > "cur_month.lower()" instead of "str.lower(cur_month)" You should also read unicode.txt in the source distribution (online at http://www.djangoproject.com/documentation/unicode/ although it's not yet linked off the main documentation page). Regards, Malcolm -- Plan to be spontaneous - tomorrow. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: localflavor - UKPostcodeField
The same question applies though :) You didn't import the "forms" bit, you imported the field directly, so you should just be using it as UKPostcodeField :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: db-api optimization
That probably isn't what you want, though it will work (technically speaking) The way you're doing it, that's going to chain the filters with AND, not OR, so only things that match the title and description for all words will show up. You probably want to build a Q object with | for an OR lookup instead :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: localflavor - UKPostcodeField
Sorry that was a typo on my part Colin Should have read: forms.UKPostcodeField() Think its time for a coffee! On Aug 21, 9:19 am, Collin Grady <[EMAIL PROTECTED]> wrote: > You're importing UKPostcodeField - so why are you trying to use > models.UKPostcodeField ? :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: localflavor - UKPostcodeField
You're importing UKPostcodeField - so why are you trying to use models.UKPostcodeField ? :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: index page
It really depends on how complicated you want to make it. However using generic views would easily suffice, just set up a dictionary of the objects you need to pass in. Something like: django.views.generic.simple.direct_to_template would do the job. On Aug 21, 9:12 am, Rufman <[EMAIL PROTECTED]> wrote: > hi > > does anyone have a good idea how i could make an index page that > combines different apps. e.g. the results of a poll is shown as well > as a news feed next to it. > > thanks > > stephane rufer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: index page
Make template tags for your various apps, and use them on the index page :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Foreign Key chaining in templates
question.choice.all is wrong :) The default reverse relation name is FOO_set where FOO is the lower- case name of your model. So in your case, it would be question.choice_set.all --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Foreign Key chaining in templates
I am trying to build a simple single page quiz model, with multiple questions with three classes for quiz,questions and answers, and fourth (not included) to manage the scores as given below. class Quiz(models.Model): name = models.CharField(maxlength=200) pub_date = models.DateTimeField() quizmaster = models.ForeignKey(User) slug = models.SlugField(editable=False) class Question (models.Model): quiz = models.ForeignKey(Quiz) question = models.CharField(maxlength = 300) answer_explanation = models.TextField() level = models.CharField(maxlength = 32, choices=levels) class Choice (models.Model): question = models.ForeignKey(Question, edit_inline=models.TABULAR, num_in_admin=5) answer = models.CharField (maxlength=200, core = True) is_rightanswer = models.BooleanField() My question is in Views, how do I display all questions in a single page and then of course accept the answers, display the right ones, and indicate the wrong ones and so on. Since I followed the polls tutorial I managed to display the different quizzes with the following view def index(request): latest_quiz_list = Quiz.objects.all().order_by('-pub_date')[:5] return render_to_response('quiz1/index.html', {'latest_quiz_list': latest_quiz_list}, ) However I am unable to display the answers to the different questions. My detail function in views.py look like this def detail(request, slug): p=Quiz.objects.get(slug=slug) q=Question.objects.filter(quiz=p) return render_to_response('quiz1/detail.html', {'quiz': p, 'questions':q } ) Problem is the {% for loop does not accept choices. {% for choice in questions.choice.all %} {{ choice.answer }} {{ choice.answer}} {% endfor %} {% endfor %} I have used the above template in the loop and it does not work. I know I need to somehow chain each choice to the right question, but I am unable to. Thanks in advance K Mallory --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
localflavor - UKPostcodeField
Hi I came across localflavors and would like to use the UKPostcodeField for post code validation. However when I try to import this I'm getting ViewDoesNotExist errors. Within my forms.py I'm importing like so: from django.contrib.localflavor.uk.forms import UKPostcodeField I'm then referencing this within the class like so: models.UKPostcodeField() >From here I've also checking within the Django installation on my python path to ensure that this exists. But no joy! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Initial value for a choices field in admin?
Hello, In one of my models I have a choices field: class MyModel(models.Model): units = models.CharField(maxlength=2, choices=UNITS) When I try to create a new instance of this model in the admin, the initial value in the select list for the units field is a dashed line. What I'd like is to be able to define an initial value for this field, and have it already selected in the select list when I just enter the "add object" page. I've tried using the default keyword argument in various ways but to no avail. Googling also didn't help. I would appreciate any ideas. Thanks, Amit --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---