Re: A ManyToMany Field question.
class user(models.Model): username = models.CharField(max_length=50) class group(models.Model): groupname = models.CharField(max_length=50) users = models.ManyToManyField(user) groups = models.ManyToManyField('self') there are my models. I have no idea to get a complete group list in such models, anyone give me a suggestion. example: user U1 belong group G1 and group G1 belong G2, I want get G1 and G2 via U1. like this def get_all_groups(user): return all_groups >>>get_all-groups(U1) [G1, G2] that all. Thank. On Tue, Feb 10, 2009 at 12:18 PM, khsingwrote: > Alex, thanks, now it work. > > now have a new problem is may a group can contain itself, this will be a loop. > > how to avoid this condition? > > > > On Tue, Feb 10, 2009 at 11:28 AM, Alex Gaynor wrote: >> >> >> On Mon, Feb 9, 2009 at 10:18 PM, khsing wrote: >>> >>> I want design a group that can contain other groups, and one group can >>> belong many groups. >>> >>> I write such code below, but not right. >>> >>> class Group(models.Model): >>>groups = models.ManyToManyField(Group) >>> >>> any suggestion? >>> >>> or how to design such a group. >>> >>> thanks. >>> >>> -- >>> A man live in jail and want to break. >>> http://blog.khsing.net >>> >>> >> >> To have a relationship with oneself you do >> >> ManyToManyField("self") >> >> -- >> "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 >> >> >> >> > > > > -- > A man live in jail and want to break. > http://blog.khsing.net > -- A man live in jail and want to break. http://blog.khsing.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 -~--~~~~--~~--~--~---
Re: comparisons with java framework
Russ Magee , I've got a question personally to you. Why do we need to use make ? Why this build can't be done without make but only with python ? A lot of companies try to avoid using make and moving projects to python as build tool. On Feb 11, 1:59 am, Russell Keith-Mageewrote: > On Tue, Feb 10, 2009 at 8:41 PM, igorlash wrote: > > > The django community should allow to download html version of > > documentation to make this project more attractive , I'm sure it > > doesn't take a lot of time to generate it on configured environment. > > You're sure, are you? Have you actually written the infrastructure to do this? > > > But a lot of time can be saved on django users' side. More over it can > > be critical on making decision between this or other framework. > > In your opinion. Personally, I doubt that any serious comparison > between Django and another framework hinges on the availability of a > downloadable documentation. > > Let's break this down. We have finite resources, so you have a choice between: > > 1) Good documentation that is only available online > > 2) A slightly worse product, and slightly worse documentation that is > available as a downloadable package. > > This sounds extreme, but it is the real situation. Any resources we > spend on building the tools to support an automated documentation > package are resources we don't spend working on Django itself. > > You apparently would prefer option 2. That's your choice. However, > Django has decided to choose option 1. > > If you feel that the availability of a downloadable documentation > package is a valuable resource, you are free to set up the > infrastructure to manage this process yourself. If you can provide > concrete evidence that there is a massive demand for this service, we > will obviously reconsider our opinion. In the meantime, we provide the > tools to enable you to build your own offline documentation. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problems with djangosearch setup
SEARCH_ENGINE is not able to find solr. i think some thing wrong in your configuration or try to change the case SOLR 'Solr' some thing like that On Feb 11, 6:15 am, Shantpwrote: > Hi > > I've installed Java, Tomcat and Solr. I followed the directions and > got pysolr as well. I put the djangosearch app on my python path and > put it in the installed_apps in my settings.py. > > http://code.google.com/p/djangosearch/source/browse/branches/soc-new-... > > In the read me it says to put this in my settings.py file: > > SEARCH_ENGINE="solr" > > I did this and when I run a shell to do a test query I get an error > saying "ImportError: No module named solr" > > Did anyone successfully setup this app? Why is it giving this error? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Save Local image with model
Hi, I've a model with imagefield which I am easily able to save using request.FILES. I have some images which are already uploaded (on the server at a known path), I want to save them with the model. When i save the model, the save method also creates thumbnails, which is why I want to save the uploaded files with the model through the model's save method. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Associating content with multiple sites
lets assume all in lowercase expo/expoapp/models.py class events(models.Model): title = models.CharField(max_length = 50) summary = models.CharField(max_length = 100) description = models.CharField(max_length = 300) event_type = models.ForeignKey(event_type) start_date = models.DateField() end_date = models.DateField() contact_detail = models.CharField(max_length = 100) booking_url = models.URLField(max_length = 50) venue = models.CharField(max_length = 100, blank = True) address = models.CharField(max_length = 100, blank = True) foodie/foodieapp/models.py class events(models.Model): title = models.CharField(max_length = 50) summary = models.CharField(max_length = 100) description = models.CharField(max_length = 300) event_type = models.ForeignKey(event_type) start_date = models.DateField() end_date = models.DateField() contact_detail = models.CharField(max_length = 100) booking_url = models.URLField(max_length = 50) venue = models.CharField(max_length = 100, blank = True) address = models.CharField(max_length = 100, blank = True) we have same structure events class in both sites. Both sites use the same events database, and an events is associated with one or more sites It lets the site producers edit all events -- on both sites -- in a single interface (the Django admin). so my doubt is: Is it necessary to write events class in both application and if it is not then where should i keep events class in which app. if it should be in both sites then how may i proceed ahead? If i keep events class in both models.py then i will face this problem No, that would mean for app a and b you will get tables: a_eventtype and b_eventtype. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: I may have found a bug in inlineformset_factory vicinity
On Tue, Feb 10, 2009 at 5:37 PM, Skylarwrote: > > I get rendered > Id also > User > This is a rather huh?-inducing start to a bug report. Without context, those two outputs look perfectly fine. It really helps if you start with what you are doing at a high level, the code you are using to attempt to achieve that, what you expected the result of running the code to be, and what you got instead. You started at the end of that and worked backwards, leaving out what you expected and what you are doing at a high level. > > ### The mostly relevent part of views.py: > > from django.forms.models import inlineformset_factory > @login_required > def pickup(request): >try: >profile = request.user.get_profile() >except: >return HttpResponseRedirect('/profile/') > >PickUpFormSet = inlineformset_factory(UserProfile, > AuthorizedPickUpPerson, max_num=5, fields=('name', 'relationship', > 'phone')) Ah, so maybe the issue is you did not specify the id and user fields in the form, therefore weren't expecting them to be rendered? If so, why couldn't you have mentioned that instead of asking people to trawl through a page of code trying to guess what it was you were trying to report? If not, I'm still lost as to what your issue is, because I stopped guessing at this point and am proceeding on the assumption that you don't expect those fields to be in the form since you did not explicitly list them. Without actually digging into the formset code, I have a feeling those fields (primary key and fk to parent model) are always included as hidden fields in the inline formset forms. They're needed for properly keeping track of things, so even if you don't explicitly list them, they will be there. They will be hidden, though, and you would see that by checking the output of as_p(), for instance, on one of these forms. So then the question is why are the labels appearing on your form? > >if request.method == "POST": >formset = PickUpFormSet(request.POST, instance=profile ) >if formset.is_valid(): >instances = formset.save(commit=False) >for instance in instances: >instance.user = profile() >instance.save() >return HttpResponseRedirect('/') > >else: >formset = PickUpFormSet(instance=profile, ) > >context = {'formset':formset, 'profile':profile,} >return render_to_response('pickup.html', context, > context_instance=RequestContext(request)) > > ###Rendering to this template: > > >{{ formset.management_form }} > >{% for form in formset.forms %} >{% for field in form %} >{{ field.label_tag }}: {{ field }} >{% if field.help_text %} >{{ field.help_text }}{% endif %} >{% if field.errors %}{{ field.errors }}{% endif %} >{% endfor %} >{% endfor %} > > > > You have your own field-by-field rendering but do not check the is_hidden attribute for a field before rendering the field label. See its description at the end of the attribute list discussed here: http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-the-form-s-fields See also the discussion of looping over hidden and visible fields here: http://docs.djangoproject.com/en/dev/topics/forms/#looping-over-hidden-and-visible-fields 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: executing raw sql results in traceback
On Tue, Feb 10, 2009 at 10:28 PM, Bobby Robertswrote: > > hi gang. For various reasons i've decided to use a raw sql statement > in my view. Following the example located at > http://docs.djangoproject.com/en/dev/topics/db/sql/, I have a view > which looks like this: > > > def searchform(request): > from django.db import connection > ... > # a massive sql statement is dynamically built here. called sqlall > (used below) > > try: >#setup recordset >cursor=connection.cursor() >cursor.execute (sqlall) >tms=cusor.fetchall() #this will be pushed back to the template > except IndexError: >#nothing found so redirect to "no results page" >return HttpResponseRedirect ('/search/results/none/') > > ... > > > When I assert the sqlall variable, the sql statement executes > perfectly in phpmyadmin. However, Django throws the following > traceback: > > not enough arguments for format string > > I have no idea what this error means and why it's not working... any > ideas? (Aside: That's not a traceback, it's a (partial) error message. A traceback includes an error message but also identifies the line of code causing the error, including file name and line number, plus similar for all the code up the call stack. It is much more informative than just the error message, and it's usually a good idea to include the whole traceback instead of just the error message in posts asking for help.) This is the kind of thing that can cause the error message you are reporting: Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40) [GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> "%s %s" % ('hi',) Traceback (most recent call last): File "", line 1, in TypeError: not enough arguments for format string >>> I specified a string with two %s placeholders but only one object to take their place, so Python raises an error that there are not enough arguments for my format string. Since you left out all the stuff that has anything to do with creating the sql statement I'm not sure what you are doing to cause this, though I notice you are not passing any parameter argument list to your execute() call. Are there no parameters that need to be substituted into your dynatmically-generated sql statement? 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 ModelChoiceField and handling form submission
> The issue is you are passing the kwarg "user" after the arg. Since user is > the first param when you pass request.POST as the first arg it assumes it is > user. Reorganize your arguments in some(make user first, or pass > request.POST as a kwarg) way. > > Alex Thanks, Alex. That was a huge help. Passing request.POST as kwarg solved the issue: form = SystemAlertForm(data=request.POST, user=request.user, instance=alert) I really appreciate your help, and such a quick response. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: KML geodjango plz help!
On Feb 10, 6:06 pm, arbiwrote: > I am a newb in Django/GeoDjango. > I am making the tutorial here :http://code.djangoproject.com/wiki/GeoDjango > and I use mySQL as a database. The project is to store places in a > database, then to display it on a OpenLayer Map (like Google Maps) > > Does any one know how to solve this problem of "KML stored procedure > not available" ? mysql does not support kml, see http://geodjango.org/docs/db-api.html#kml You must use postgresql for kml support. In case you don't know there is a geodjango mailing list. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: version control convention?
Serdar T. wrote: > Is it better to create repositories at a site-, project- or app-level? > Technically, you can do all three. Definitely put all of your re-usable apps into their own repository. I always put my projects into their own repository, but I don't necessarily include apps that I'm using in them that come from somewhere else. I do have a couple of repos that are just projects and have no apps in them. The apps are expected to be on the python path at runtime. There are a couple of times when you really don't need your app to be re-usable. It's fine to create a project and an app that will always and forever live in the same version controlled repo. Another common practice is to take advantage of version control systems features of being able to reference external repositories. svn has an "external" option, and git has something called submodules. I'm not super familiar with other version control systems, but I'm sure there are equivalents in most popular ones. Generally speaking, when you are writing an app, the repo should have a layout that looks something like this: /docs/ /appname/ /readme.txt /authors.txt /setup.py ...etc... This is a fairly common in practice. The idea is that a lot of those things don't belong in with your python code, so they live one level up. Django itself follows this convention, as do most python projects. When you want to track a whole site, you can add projects and/or apps as submodules/externals. Generally speaking, a single site could/should be a single Django project, and making this distinction doesn't come up terribly often in the configurations I've seen. Hopefully this was helpful and happy coding! Jeff Anderson signature.asc Description: OpenPGP digital signature
Re: date error
thank you Mr Morales it 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 -~--~~~~--~~--~--~---
executing raw sql results in traceback
hi gang. For various reasons i've decided to use a raw sql statement in my view. Following the example located at http://docs.djangoproject.com/en/dev/topics/db/sql/, I have a view which looks like this: def searchform(request): from django.db import connection ... # a massive sql statement is dynamically built here. called sqlall (used below) try: #setup recordset cursor=connection.cursor() cursor.execute (sqlall) tms=cusor.fetchall() #this will be pushed back to the template except IndexError: #nothing found so redirect to "no results page" return HttpResponseRedirect ('/search/results/none/') ... When I assert the sqlall variable, the sql statement executes perfectly in phpmyadmin. However, Django throws the following traceback: not enough arguments for format string I have no idea what this error means and why it's not working... 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 -~--~~~~--~~--~--~---
Problems with djangosearch setup
Hi I've installed Java, Tomcat and Solr. I followed the directions and got pysolr as well. I put the djangosearch app on my python path and put it in the installed_apps in my settings.py. http://code.google.com/p/djangosearch/source/browse/branches/soc-new-backends/doc/README.txt In the read me it says to put this in my settings.py file: SEARCH_ENGINE="solr" I did this and when I run a shell to do a test query I get an error saying "ImportError: No module named solr" Did anyone successfully setup this app? Why is it giving this error? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Stupid Newbie ManyToManyField Contains question
Hmm... That sort of works, but not quite. If I use the filter method, it won't properly set the jumbledname on the first save. However, if I go back in and save the instance again a second time, it will properly set jumbledname. If I had it to guess, (after looking at the Django documentation) it's because the filter method uses a SQL like statement (rather than just evaluating the post data) which probably means it has to look at the database first...in other words, the first save changes the lastname field, and the second save looks at that field and changes jumbledname accordingly. (This is a guess, but based on the behavior, I think it's the right one). Any ideas as to how I might modify it? Thank you for everything, bkev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Bizarre sqlite3 / apache2 behaviour
Thanks a lot Jeff. I figured out the problem which was a bit more complicated than that but basically was also what you said. I downloaded the sqlite3 client and that helped too. What throw me off (among other things) is that in Linux you only need executable permissions to a directory and write permissions to a file to modify it and for apache/sqlite3 you also need write permissions to the directory, not sure why and especially since the other files (owned by root, in the same directory) are accessed by apache without problems and no temporary files etc are created. Also the examples and solutions from people in the web where they gave all kinds of permissions to the main code directory (where the database file was) and file didn't make sense to me from a security standpoint; I think a better solution is to put the sqlite file in a separate directory (just for that file), that way we don't have to lower the security of the rest of the project. Regards On Feb 10, 3:12 pm, Jeff FWwrote: > You need to make sure that the user apache is running as (usually > "apache") has write access to the database file *and* the directory > that the database file is in. > > The development server would work because *you* probably have write > access to those paths. > > As for the sqlite3 version, run python, then: > > >>> import sqlite3 > >>> sqlite3.version > > -Jeff > > On Feb 9, 12:10 pm,lazyant wrote: > > > Hello, > > > I installed yesterday Django 1.0.2 (current downloadable version) on a > > new Ubuntu 8.10 machine with python 2.5.2. I wrote a toy application > > and it works and shows fine with both the built-in development server > > and Apache 2 (2.2.9). The database is sqlite3, it came with python > > (btw, how do I get the sqlite3 version from python/the Linux command > > line?). > > > Anyways, yesterday everything was working fine, including the admin > > application served by Apache. Today I only worked on templates, > > restarting apache frequently (I know about setting MaxRequestsPerChild > > 1 but anyways) but after a while I went to the admin application > > (served by apache) and I got an error: "OperationalError: attempt to > > write a readonly database", which is strange since it was working > > before and I haven't made today any changes to file or directory > > permissions or fiddled with the settings file. > > > I looked up this error and I only see tips regarding permissions > > problems, bad path in the setting file or perhaps a sqlite version > > issue. I think none of that applies to me (since it was working > > yesterday) but I double-checked just in case. > > > I tried different things for troubleshooting, including dropping the > > data with "manage.py sqlclear" and renaming the db file and re- > > creating it with "manage.py reset" and "manage.py syncdb" (I suspected > > perhaps the file was corrupted), but nothing I tried worked. I also > > checked the server (it wasn't rebooted recently etc). > > > Here's a twist: if I start the development server and I log in, then > > the admin app in apache works fine (!), I can edit & save records etc. > > As soon as I log out of the development server, then apache gives me > > the readonly error. > > > I'm ruling out client-side issues (cookies etc) since I tried with > > different browsers and computers, deleting session and cookies etc. > > > Any ideas? > > > 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: where's our poll app?
On Tuesday 10 February 2009, djandrow wrote: > Did you create the models and is the database correctly configured in > settings.py? I added 'phhsite.polls', the server is seeing it now. Thanks :-) stayed tuned - I'm an old pythonisto in more ways than one, but just a django noob cheers tj --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
On Tue, Feb 10, 2009 at 8:41 PM, igorlashwrote: > > The django community should allow to download html version of > documentation to make this project more attractive , I'm sure it > doesn't take a lot of time to generate it on configured environment. You're sure, are you? Have you actually written the infrastructure to do this? > But a lot of time can be saved on django users' side. More over it can > be critical on making decision between this or other framework. In your opinion. Personally, I doubt that any serious comparison between Django and another framework hinges on the availability of a downloadable documentation. Let's break this down. We have finite resources, so you have a choice between: 1) Good documentation that is only available online 2) A slightly worse product, and slightly worse documentation that is available as a downloadable package. This sounds extreme, but it is the real situation. Any resources we spend on building the tools to support an automated documentation package are resources we don't spend working on Django itself. You apparently would prefer option 2. That's your choice. However, Django has decided to choose option 1. If you feel that the availability of a downloadable documentation package is a valuable resource, you are free to set up the infrastructure to manage this process yourself. If you can provide concrete evidence that there is a massive demand for this service, we will obviously reconsider our opinion. In the meantime, we provide the tools to enable you to build your own offline documentation. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: where's our poll app?
Did you create the models and is the database correctly configured in settings.py? On 10 Feb, 22:55, Tim Johnsonwrote: > It's not displayed on the admin index page. > > From the Tutorial > at:http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02 > > Name of the project is phhsite > from phhsite ran python manage.py startapp polls > directory was created. > Then created the admin file > Restarted the server by first pressing Ctrl-C > then invoking python manage.py runserver > No sign of any application call polls. > polls/admin.py looks like this: > ##--- > from phhsite.polls.models import Poll > from django.contrib import admin > > admin.site.register(Poll) > ## added the following as a test > 1 / 0 > ## the 1 / 0 is deliberate, > ## If django found this file, I should have seen an error > > Using python 2.5 on kubuntu 7.10 > What have I overlooked? > Thanks > 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 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 display the human readable name of a choice?
On Tue, Feb 10, 2009 at 6:39 PM, Kevin Audlemanwrote: > > Thanks Alex, however this is a solution at the View level, and I'm > using a view that I didn't write. Is there also a way to do this at > the template level? > > Thanks again, > Kevin > > On Feb 10, 1:24 pm, Alex Gaynor wrote: > > On Tue, Feb 10, 2009 at 4:23 PM, Kevin Audleman < > kevin.audle...@gmail.com>wrote: > > > > > > > > > > > > > Hi everyone, > > > > > I've set up a model that has a state field with the input set to a > > > list of states, > > > > > state = models.CharField(max_length=100, blank=True, > > > choices=US_STATE_LIST) > > > > > The drop-down on the edit form works great, displaying 'Alabama' and > > > storing AL in the database. However when I view it, I see AL. How do I > > > get django to display the human readable name? > > > > > I would prefer to do this on the template level, as I'm using a view > > > from a contributed app that I can't modify. > > > > > Thanks, > > > Kevin > > > > http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddo... > > > > 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 > > > Yes, the same thing works {{ model.get_FIELD_display }}. 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 display the human readable name of a choice?
Thanks Alex, however this is a solution at the View level, and I'm using a view that I didn't write. Is there also a way to do this at the template level? Thanks again, Kevin On Feb 10, 1:24 pm, Alex Gaynorwrote: > On Tue, Feb 10, 2009 at 4:23 PM, Kevin Audleman > wrote: > > > > > > > Hi everyone, > > > I've set up a model that has a state field with the input set to a > > list of states, > > > state = models.CharField(max_length=100, blank=True, > > choices=US_STATE_LIST) > > > The drop-down on the edit form works great, displaying 'Alabama' and > > storing AL in the database. However when I view it, I see AL. How do I > > get django to display the human readable name? > > > I would prefer to do this on the template level, as I'm using a view > > from a contributed app that I can't modify. > > > Thanks, > > Kevin > > http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddo... > > 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Best way to deal with dictionaries of lists (equivalent of SQL GROUP BY)
I'm looking at the documentation here: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#regroup And am looking for the best practices way to deal with doing that from within the manager. This seems like a common issue: 1. I have two models, one foreign keys to the other (comments -> bookmarks) 2. I want, for each bookmark, to list each comment_description. This would be the dictionary (or I could use a queryset, or a list, or ideally a dictionary of lists, or whatever is considered best practice) [{'comment_id': 1, 'bookmark_id': 1, 'comment_description': u'Bookmark1 Description'}, {'comment_id': 2, 'bookmark_id': 1, 'comment_description': u'Bookmark1 Another Description'}, {'id': 3, 'comment_id': 2, 'comment_description': u'Bookmark2 Description'}] I want: bookmark_id 1, comment_descriptions "Bookmark1 Description","Bookmark1 Another Description" bookmark_id 2, comment_descriptions "Bookmark2 Description" The Python docs are really tough to navigate and while the Django docs are excellent, I can't find the standard solution for this. I know it must come up all the time (as it would with PHP). Thanks, Adam --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
On Wed, Feb 11, 2009 at 6:52 AM, Greg Ewingwrote: > > Alex Gaynor wrote: > >> As I said above, a checkout of the django source includes all the docs, >> which can be built into nice HTML just as online with the sphinx module >> for python. It takes all of 30 seconds. > > Only if you have all the necessary tools and dependencies > installed and working, which not everybody does, especially > on Windows. Well... there's your problem right there. :-) > Besides which, you're *already* building the html yourself > for the web site, so why not make it easily available? Refusing > to do so seems pointlessly obstructive. Yes. We want to make sure you never get any work done. We want to put roadblocks on your road to world domination. Seriously - dial down the rhetoric a bit. If you are unhappy with the service you have received, we will happily give you a 100% refund of your purchase price. We already provide up-to-date generated HTML documenation. We just don't provide it in a nice tarball to download. If you can't install Sphinx and build the documentation yourself, then how about using wget or any one of the several thousand site mirroring tools that are in existence? Building the infrastructure to handle automatic downloads is not a 0 effort activity. Someone needs to write the code, and someone needs to maintain it. Unfortunately (for you), in the opinion of the core developers, this simply isn't worth the effort. While there is an occasional (and usually very vocal) request for downloadable documentation, in our estimation this is a very small group. We can spend our time trying to satisfy this group, or we can spend our time improving Django - for example, by adding aggregates and query expression to the ORM. We have decided to do the latter. Also - one of the benefits of using ReST as a source format is that it is actually human readable. If you put the ducks in a row to use Sphinx, and you can't find a site mirroring tool, you can still read the raw ReST sources. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
KML geodjango plz help!
Hi all! I am a newb in Django/GeoDjango. I am making the tutorial here : http://code.djangoproject.com/wiki/GeoDjango and I use mySQL as a database. The project is to store places in a database, then to display it on a OpenLayer Map (like Google Maps) The problem is that I get a : Exception Type: ImproperlyConfigured Exception Value: KML stored procedure not available. Does any one know how to solve this problem of "KML stored procedure not available" ? I have no hairs anymore. thx a lot Arbi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
where's our poll app?
It's not displayed on the admin index page. >From the Tutorial at: http://docs.djangoproject.com/en/dev/intro/tutorial02/#intro-tutorial02 Name of the project is phhsite from phhsite ran python manage.py startapp polls directory was created. Then created the admin file Restarted the server by first pressing Ctrl-C then invoking python manage.py runserver No sign of any application call polls. polls/admin.py looks like this: ##--- from phhsite.polls.models import Poll from django.contrib import admin admin.site.register(Poll) ## added the following as a test 1 / 0 ## the 1 / 0 is deliberate, ## If django found this file, I should have seen an error Using python 2.5 on kubuntu 7.10 What have I overlooked? Thanks 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 django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Json Serialization / Form Validation error
Thank you all for posting this. You saved me probably hours of head scratching. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Cookie authentication
Hello everybody, I still haven't found any solution for this problem, although it seems quite simple and common... any idea ? Thank you ! On 26 jan, 13:15, Sylvainwrote: > Hello everybody, > > I'm trying to create a cookie-based authentication so that the users > don't have to login each time they visit the website. I'm already > using django.contrib.auth to log the users in and it works pretty well > with a custom authentication backend (because I'm importing the users > from another database). I thought I could create another > authentication backend to log the users in by using cookies. > > So I created a second authentication backend to handle this and added > it to my AUTHENTICATION_BACKENDS setting. Now I have : > > AUTHENTICATION_BACKENDS = ( > 'myproject.apps.users.models.Authentication', > 'myproject.apps.users.models.CookieAuthentication', > ) > > In the cookie, 2 main informations are stored : the user id and a hash > of its password and a salt. So my CookieAuthentication.authenticate() > method takes 2 arguments : the user id and the user's password hash. > The big problem is that Django's default authentication behaviour is > to take a username and a raw password, and my authentication method > should take a user id and a password hash. So for the moment I'm > passing the user id as the "username" parameter and the password hash > as the "password" parameter. But this leads to a couple of problems : > > - If a user fails his authentication with the Authentication backend, > the CookieAuthentication backend will be tried. Since the > Authentication backend takes the username as the username argument and > not the user id, the CookieAuthentication will crash. For the moment I > added a "if isinstance()..." to test the type of the username variable > but I don't think it's very clean. > > - I can't pass more information to the > CookieAuthentication.authenticate() method like the duration of the > session (which depends on whether the user choosed to remember his > connection or not) and other stuff like that which are cookie- > dependent. > > - It's not clean at all because if a user has the name of the id of > another user (for example a user named "314"), if the user tries to > log in normally (using the login form) and it fails, the cookie > authentication method will be used and if the password hash is the > same as the user "314", the user will be authenticated. I know the > chances are near 0%, but that's just to show that it's not very clean. > > Any idea on how to implement that in a clean way ? > > 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: Another thread about static content
I've move it just to the apache2.2 file so my conf is now: Options Indexes FollowSymLinks SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE akonline.settings PythonOption django.root /akonline PythonDebug On PythonPath "['C:/Program Files/Apache2.2'] + sys.path" Order Allow,Deny Allow from all SetHandler None Alias /media/ "C:/Program Files/Apache2.2/akonline/templates/blogSite/ media/" SetHandler None But i'm still having the same problems Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
On Tue, Feb 10, 2009 at 4:52 PM, Greg Ewingwrote: > > Alex Gaynor wrote: > > > As I said above, a checkout of the django source includes all the docs, > > which can be built into nice HTML just as online with the sphinx module > > for python. It takes all of 30 seconds. > > Only if you have all the necessary tools and dependencies > installed and working, which not everybody does, especially > on Windows. > > Besides which, you're *already* building the html yourself > for the web site, so why not make it easily available? Refusing > to do so seems pointlessly obstructive. > > -- > Greg > > > > I don't mean to be rude, but the development tools needed(Sphinx) aren't particularly difficult to install, and really are a valuable resource to have. Prebuilding the docs means that either the developers need to remember to build the docs before each checkin, or a post-commit hook needs to be added to build them(assuming this is possible) both of which incur additional overhead on the django developers to the benefit of the subset of the community that both doesn't have constant access to the internet(not an unreasonable situation) and who don't have Sphinx installed(which I would consider unreasonable for someone who knows they can't access the web docs). These are just my thoughts, I'm not a core dev, but I'd rather they spent their time working on Django than remembering to rebuild the docs and fiddling with SVN post commit hooks. 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Another thread about static content
So would it be best to move my project somewhere else? On 10 Feb, 21:48, Ramiro Moraleswrote: > On Tue, Feb 10, 2009 at 7:40 PM, djandrow wrote: > > > Hello all, > > > I know theres alot of threads like this out there but I'm still > > struggling. I've got a simple html template which i access through a > > view: > > > > > > > > > > the template is in C:/Program Files/Apache2.2/htdocs/akonline/ > > templates/blogSite > > and the image is then in blogSite/media > > > then in my conf I have: > > > > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE akonline.settings > > PythonOption django.root /akonline > > PythonDebug On > > PythonPath "['C:/Program Files/Apache2.2/htdocs'] + sys.path" > > > > > > blogSite/media/"> > > Order Allow,Deny > > Allow from all > > SetHandler None > > > > > Alias /media/ "C:/Program Files/Apache2.2/htdocs/akonline/templates/ > > blogSite/media/" > > > > > SetHandler None > > > > > I'm using mod_python and Windows XP, I have the same setup (with > > different locations and directories) on my linux host and it works > > fine. So whats going on. I would be grateful for any help. > > Problem with this is how doas Apache what rule should it apply when > it come to server something under /akonline or /media > The one set by the > > DocumentRoot C:/Program Files/Apache2.2/htdocs > > directive ? or the one set by the Alias or Location > blocks/directives above?. > > It is really better for you and for anybody trying to help > you if you follow some basic common sense practices > because it isn't very practical having to set up > a test Django app under one's Apache document root > just to reproduce your setup. > > -- > Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
Alex Gaynor wrote: > As I said above, a checkout of the django source includes all the docs, > which can be built into nice HTML just as online with the sphinx module > for python. It takes all of 30 seconds. Only if you have all the necessary tools and dependencies installed and working, which not everybody does, especially on Windows. Besides which, you're *already* building the html yourself for the web site, so why not make it easily available? Refusing to do so seems pointlessly obstructive. -- 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 -~--~~~~--~~--~--~---
Re: Stupid Newbie ManyToManyField Contains question
On Tue, Feb 10, 2009 at 4:48 PM, bkevwrote: > > Hmm...It is just a normal python string, but when I try 'Smith' in > self.lastname, I get a "ManyRelatedManager is not iterable" error. Any > ideas? > > Thanks again, > -bkev > > > Sorry I'm an idiot, I read lastname in the wrong place, what you'll want to do for a manytomany is something like if self.lastname.filter(lastname__contains="Smith")[:1]: 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Stupid Newbie ManyToManyField Contains question
Hmm...It is just a normal python string, but when I try 'Smith' in self.lastname, I get a "ManyRelatedManager is not iterable" error. Any ideas? Thanks again, -bkev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Another thread about static content
On Tue, Feb 10, 2009 at 7:40 PM, djandrowwrote: > > Hello all, > > I know theres alot of threads like this out there but I'm still > struggling. I've got a simple html template which i access through a > view: > > > > > > the template is in C:/Program Files/Apache2.2/htdocs/akonline/ > templates/blogSite > and the image is then in blogSite/media > > then in my conf I have: > > >SetHandler python-program >PythonHandler django.core.handlers.modpython >SetEnv DJANGO_SETTINGS_MODULE akonline.settings >PythonOption django.root /akonline >PythonDebug On >PythonPath "['C:/Program Files/Apache2.2/htdocs'] + sys.path" > > > blogSite/media/"> >Order Allow,Deny >Allow from all >SetHandler None > > > Alias /media/ "C:/Program Files/Apache2.2/htdocs/akonline/templates/ > blogSite/media/" > > >SetHandler None > > > I'm using mod_python and Windows XP, I have the same setup (with > different locations and directories) on my linux host and it works > fine. So whats going on. I would be grateful for any help. Problem with this is how doas Apache what rule should it apply when it come to server something under /akonline or /media The one set by the DocumentRoot C:/Program Files/Apache2.2/htdocs directive ? or the one set by the Alias or Location blocks/directives above?. It is really better for you and for anybody trying to help you if you follow some basic common sense practices because it isn't very practical having to set up a test Django app under one's Apache document root just to reproduce your setup. -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Another thread about static content
Hello all, I know theres alot of threads like this out there but I'm still struggling. I've got a simple html template which i access through a view: the template is in C:/Program Files/Apache2.2/htdocs/akonline/ templates/blogSite and the image is then in blogSite/media then in my conf I have: SetHandler python-program PythonHandler django.core.handlers.modpython SetEnv DJANGO_SETTINGS_MODULE akonline.settings PythonOption django.root /akonline PythonDebug On PythonPath "['C:/Program Files/Apache2.2/htdocs'] + sys.path" Order Allow,Deny Allow from all SetHandler None Alias /media/ "C:/Program Files/Apache2.2/htdocs/akonline/templates/ blogSite/media/" SetHandler None I'm using mod_python and Windows XP, I have the same setup (with different locations and directories) on my linux host and it works fine. So whats going on. I would be grateful for any help. Thank you, Andrew PS. I know your not supposed to put your project in htdocs but this is just on my PC so there aren't any security issuses. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: date error
On Tue, Feb 10, 2009 at 6:51 PM, Hervé Edorhwrote: > > nobody for helping me? It seems you have several problems: First, the code you are pasting has the indentation totally broken. Second, >i forgot, the first ulrs.py (in the project directory) is like this > > (r'^weblog/$',include('dibongo.urls')), > (r'^weblog/(?P\d{4})/(?P\w{3})/(?P\d{2})/(?P\w+)/$',include('dibongo.urls')), > > this is the second that i put before. It for the chapiter decoupling > the URLs You aren't really decoupling things, because with the first entry in the URL map you are correctly delegating all things under weblog/ to the dibongo/urls.py URL map file but then in the second entry you show that you still want to handle URsL for the dibongo app in the main urls.py. Ideally that entry should be moved to dibongo/urls.py ith the appropiate modification in the regexp possibly merging it with the entry that invokes the django.views.generic.date_based.archive_index generic view. Third, > urlpatterns = patterns('django.views.generic.date_based', > (r'^$','archive_index',entry_info_dict,'dibongo_entry_archive_index'), > (r'^$','object_detail', entry_info_dict,'dibongo_entry_detail'), The regexp for the two entries in this URLmap are the same (r'^$') and, as the URL resolution is performed from top to bottom, the one using the django.views.generic.date_based.archive_index generic views is matching. Fix these problems first and then post again if you are still experimenting problems. HTH, -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
JODConverter with Django
I am curious if anyone is using JODConverter http://www.artofsolving.com/opensource/jodconverter in their Django project? I would be interested in learning from your experience. Thanks, Tonu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 display the human readable name of a choice?
On Tue, Feb 10, 2009 at 4:23 PM, Kevin Audlemanwrote: > > Hi everyone, > > I've set up a model that has a state field with the input set to a > list of states, > > state = models.CharField(max_length=100, blank=True, > choices=US_STATE_LIST) > > The drop-down on the edit form works great, displaying 'Alabama' and > storing AL in the database. However when I view it, I see AL. How do I > get django to display the human readable name? > > I would prefer to do this on the template level, as I'm using a view > from a contributed app that I can't modify. > > Thanks, > Kevin > > > http://docs.djangoproject.com/en/dev/ref/models/instances/?from=olddocs#get-foo-display 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 display the human readable name of a choice?
Hi everyone, I've set up a model that has a state field with the input set to a list of states, state = models.CharField(max_length=100, blank=True, choices=US_STATE_LIST) The drop-down on the edit form works great, displaying 'Alabama' and storing AL in the database. However when I view it, I see AL. How do I get django to display the human readable name? I would prefer to do this on the template level, as I'm using a view from a contributed app that I can't modify. Thanks, Kevin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
On Tue, Feb 10, 2009 at 4:15 PM, Greg Ewingwrote: > > Russell Keith-Magee wrote: > > > No - we don't provide a PDF version of the documentation. This idea > > has been proposed a few times in Django's history, but it has been > > rejected in favour of providing the tools to let people build offline > > versions by themselves. > > What about an offline HTML version, then? If you're > already building HTML for online use, it can't be > much harder to provide a tarfile of it for people to > download. > > -- > Greg > > > > As I said above, a checkout of the django source includes all the docs, which can be built into nice HTML just as online with the sphinx module for python. It takes all of 30 seconds. 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
Russell Keith-Magee wrote: > No - we don't provide a PDF version of the documentation. This idea > has been proposed a few times in Django's history, but it has been > rejected in favour of providing the tools to let people build offline > versions by themselves. What about an offline HTML version, then? If you're already building HTML for online use, it can't be much harder to provide a tarfile of it for people to download. -- 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 -~--~~~~--~~--~--~---
Re: Stupid Newbie ManyToManyField Contains question
On Tue, Feb 10, 2009 at 4:07 PM, bkevwrote: > > Hello all, > > Is there a way to check whether a field contains a certain value in a > ManyToManyField in the admin on a custom save method? For example, I > have a model like: > > class LastName(models.Model): >lastname = models.CharField(...) > > class Person(models.Model): > firstname = models.CharField(...) > lastname = models.ManyToManyField(LastName,...) > jumbledname = models.CharField(..., editable = False) > > def save(self): >if self.lastname CONTAINS? 'Smith': >self.jumbledname = u'%s%s' % ('self.firstname, > self.lastname') >else: >self.jumbledname = self.firstname >super(Person,self).save() > > Thanks, > -bkev > > > It all depends on what you're trying to do, in that example self.lastname is just a normal python string, so you can do "Smith" in self.lastname, for different datatypes it works slightly differently. 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Stupid Newbie ManyToManyField Contains question
Hello all, Is there a way to check whether a field contains a certain value in a ManyToManyField in the admin on a custom save method? For example, I have a model like: class LastName(models.Model): lastname = models.CharField(...) class Person(models.Model): firstname = models.CharField(...) lastname = models.ManyToManyField(LastName,...) jumbledname = models.CharField(..., editable = False) def save(self): if self.lastname CONTAINS? 'Smith': self.jumbledname = u'%s%s' % ('self.firstname, self.lastname') else: self.jumbledname = self.firstname super(Person,self).save() Thanks, -bkev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: date error
nobody for helping 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: dynamic ModelChoiceField and handling form submission
On Tue, Feb 10, 2009 at 3:24 PM, wynfredwrote: > > I'm sure there is a simple solution here, but I've been searching the > forum archive and elsewhere but so far haven't found an answer. > > I have a form that uses some dynamic ModelChoiceField fields, > filtering the model for the logged-in user. > > The form in app's forms.py, slightly abridged, is like this: > > class SystemAlertForm(forms.ModelForm): >usermessaging = forms.ModelChoiceField(label='Messaging address', > queryset=UserMessaging.objects.filter(isactive=True)) >def __init__( self, user, *args, **kwargs ): >super( SystemAlertForm, self ).__init__( *args, **kwargs ) >self.fields['usermessaging'].queryset = > UserMessaging.objects.filter(isactive=True,user=user) > > Then in the view, after a POST, I have a line of code like this: > > form = SystemAlertForm(request.POST, user=request.user, > instance=alert) > > But there is an error: __init__() got multiple values for keyword > argument 'user' > > When displaying a bound form for a user, the form is fine: it displays > this usermessaging ModelChoiceField correctly filtered -- and I call > it the same way but without the request.POST: > form = SystemAlertForm(user=request.user, instance=alert) > > But, after a POST, it displays the error above. > > Thanks in advance for any guidance. > > > > The issue is you are passing the kwarg "user" after the arg. Since user is the first param when you pass request.POST as the first arg it assumes it is user. Reorganize your arguments in some(make user first, or pass request.POST as a kwarg) way. 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 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
dynamic ModelChoiceField and handling form submission
I'm sure there is a simple solution here, but I've been searching the forum archive and elsewhere but so far haven't found an answer. I have a form that uses some dynamic ModelChoiceField fields, filtering the model for the logged-in user. The form in app's forms.py, slightly abridged, is like this: class SystemAlertForm(forms.ModelForm): usermessaging = forms.ModelChoiceField(label='Messaging address', queryset=UserMessaging.objects.filter(isactive=True)) def __init__( self, user, *args, **kwargs ): super( SystemAlertForm, self ).__init__( *args, **kwargs ) self.fields['usermessaging'].queryset = UserMessaging.objects.filter(isactive=True,user=user) Then in the view, after a POST, I have a line of code like this: form = SystemAlertForm(request.POST, user=request.user, instance=alert) But there is an error: __init__() got multiple values for keyword argument 'user' When displaying a bound form for a user, the form is fine: it displays this usermessaging ModelChoiceField correctly filtered -- and I call it the same way but without the request.POST: form = SystemAlertForm(user=request.user, instance=alert) But, after a POST, it displays the error above. Thanks in advance for any guidance. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 defined model
As much as I hate to suggest it, this sounds like a good time to use XML. Store each report as XML (in a file, or in a database row), then use templates to render the data. -Jeff On Feb 9, 3:24 pm, Didswrote: > > This is extremely unlikely to work, not to mention very inefficient. > > Can you let us know why you want to do this - what's your use case? We > > might be able to suggest a better way of doing it. > > -- > > DR. > > Users define a set of data they're interested in. Give a mean to get > the data (script, sql ...). The system goes and get the data at > regular interval (save by date) > The user can then review the data (table, charts , trends etc...) > See it as a basic monitoring system where I currently have no idea > what data the users will be interested in. > > I guess I can skip the table cration for each entity but I'm worried > the code for data retrieval might get messy. Not to mention the > templates ... > > Thanks for your input. > > Dids, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Bizarre sqlite3 / apache2 behaviour
You need to make sure that the user apache is running as (usually "apache") has write access to the database file *and* the directory that the database file is in. The development server would work because *you* probably have write access to those paths. As for the sqlite3 version, run python, then: >>> import sqlite3 >>> sqlite3.version -Jeff On Feb 9, 12:10 pm, lazyantwrote: > Hello, > > I installed yesterday Django 1.0.2 (current downloadable version) on a > new Ubuntu 8.10 machine with python 2.5.2. I wrote a toy application > and it works and shows fine with both the built-in development server > and Apache 2 (2.2.9). The database is sqlite3, it came with python > (btw, how do I get the sqlite3 version from python/the Linux command > line?). > > Anyways, yesterday everything was working fine, including the admin > application served by Apache. Today I only worked on templates, > restarting apache frequently (I know about setting MaxRequestsPerChild > 1 but anyways) but after a while I went to the admin application > (served by apache) and I got an error: "OperationalError: attempt to > write a readonly database", which is strange since it was working > before and I haven't made today any changes to file or directory > permissions or fiddled with the settings file. > > I looked up this error and I only see tips regarding permissions > problems, bad path in the setting file or perhaps a sqlite version > issue. I think none of that applies to me (since it was working > yesterday) but I double-checked just in case. > > I tried different things for troubleshooting, including dropping the > data with "manage.py sqlclear" and renaming the db file and re- > creating it with "manage.py reset" and "manage.py syncdb" (I suspected > perhaps the file was corrupted), but nothing I tried worked. I also > checked the server (it wasn't rebooted recently etc). > > Here's a twist: if I start the development server and I log in, then > the admin app in apache works fine (!), I can edit & save records etc. > As soon as I log out of the development server, then apache gives me > the readonly error. > > I'm ruling out client-side issues (cookies etc) since I tried with > different browsers and computers, deleting session and cookies etc. > > Any ideas? > > 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: SQLite, swedish signs
On Tue, Feb 10, 2009 at 2:55 PM, DaSawrote: > > The traceback: > > Environment: > > Request Method: POST > Request URL: http://127.0.0.1:8000/admin/polls/poll/add/ > Django Version: 1.0.2 final > Python Version: 2.5.3 > [snip] > File "C:\Python25\Lib\site-packages\django\utils\encoding.py" in > force_unicode > 52. s = unicode(str(s), encoding, errors) > > Exception Type: UnicodeEncodeError at /admin/polls/poll/add/ > Exception Value: 'ascii' codec can't encode character u'\xe5' in > position 6: ordinal not in range(128) > Your original note showed a model named "MyClass", here you seem to be dealing with adding a "poll" object. The line of code you have reached here implies your Poll class does not have a __unicode__ method, and the fix would be to add a __unicode__ method to Poll. However your original note shows MyClass as having a __unicode__ method, so this traceback isn't very helpful in identifying what is wrong in your MyClass case, since for the model you originally showed, you would not have reached this last line of code. 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: SQLite, swedish signs
On Tue, Feb 10, 2009 at 2:55 PM, DaSawrote: > > The traceback: > > Environment: > > Request Method: POST > Request URL: http://127.0.0.1:8000/admin/polls/poll/add/ > Django Version: 1.0.2 final > Python Version: 2.5.3 > [snip] > File "C:\Python25\Lib\site-packages\django\utils\encoding.py" in > force_unicode > 52. s = unicode(str(s), encoding, errors) > > Exception Type: UnicodeEncodeError at /admin/polls/poll/add/ > Exception Value: 'ascii' codec can't encode character u'\xe5' in > position 6: ordinal not in range(128) > Your original note showed a model named "MyClass", here you seem to be dealing with adding a "poll" object. The line of code you have reached here implies your Poll class does not have a __unicode__ method, and the fix would be to add a __unicode__ method to Poll. However your original note shows MyClass as having a __unicode__ method, so this traceback isn't very helpful in identifying what is wrong in your MyClass case, since for the model you originally showed, you would not have reached this last line of code. 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: html italic tag hinders search code
Yes, that's what I was suggesting. Sorry for not being more clear. As for storing the field twice, unless you're planning to have huge amounts of records, you wouldn't really noticed any difference at all. Also, you can have the admin interface set to *not* display the stripped version, so your users don't even have to know it exists. -Jeff On Feb 6, 3:54 pm, Maywrote: > Creating a duplicate field without tags looks like it might be the way > to go, then. I just hate the redundancy of two fields of data. > > Thanks to both you and Jeff! > > May > > On Feb 6, 12:30 pm, Karen Tracey wrote: > > > On Fri, Feb 6, 2009 at 3:05 PM, May wrote: > > > > I have data entry clerks typing the data, so I cannot have them type > > > the titles twice. > > > I'm quite sure Jeff wasn't suggesting having anyone type the titles in > > twice. Rather, when something with a title is saved, you have code (maybe > > in a save() override) that automatically populates a "stripped" version of > > your title field, based on the value of the title that was entered. (There > > is a simple strip_tags function in django.utils.html.) Then, in the > > database, you have both the field you have now (which contains html tags > > like ) and a stripped version, and it is the stripped version that you > > search, since people aren't going to be entering the html tags when they are > > searching. > > > > Is there a command where I could strip the tags out > > > after the keywords are typed but before python goes to the database to > > > search? > > > ? From what you've said the tags are in the data stored in the > > database, not in the query keywords. There's no way to strip the tags from > > the database data in order to do a search. > > > 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: SQLite, swedish signs
The traceback: Environment: Request Method: POST Request URL: http://127.0.0.1:8000/admin/polls/poll/add/ Django Version: 1.0.2 final Python Version: 2.5.3 Installed Applications: ['django.contrib.admin', 'django.contrib.admindocs', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.markup', 'mysite.polls', 'mysite.searchApp', 'mysite.forum'] Installed Middleware: ('django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware') Traceback: File "C:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response 86. response = callback(request, *callback_args, **callback_kwargs) File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in root 157. return self.model_page(request, *url.split('/', 2)) File "C:\Python25\Lib\site-packages\django\views\decorators\cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs) File "C:\Python25\Lib\site-packages\django\contrib\admin\sites.py" in model_page 176. return admin_obj(request, rest_of_url) File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in __call__ 191. return self.add_view(request) File "C:\Python25\Lib\site-packages\django\db\transaction.py" in _commit_on_success 238. res = func(*args, **kw) File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in add_view 499. self.log_addition(request, new_object) File "C:\Python25\Lib\site-packages\django\contrib\admin\options.py" in log_addition 294. object_repr = force_unicode(object), File "C:\Python25\Lib\site-packages\django\utils\encoding.py" in force_unicode 52. s = unicode(str(s), encoding, errors) Exception Type: UnicodeEncodeError at /admin/polls/poll/add/ Exception Value: 'ascii' codec can't encode character u'\xe5' in position 6: ordinal not in range(128) Thanks! BR Daniel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Problem posting a form to two separate URLs
Hello. I am trying to get a form to post to two separate URLs. I need to save the data to my own database and I am also trying to post the data to a URL for a company that does data tracking with it's own database. I realize that I could use javascript on the form template, or I could run a cron job to sync the databases, or export a csv file for them, but it seems like it should be possible to get this to work in my view. Here is the view code that sometimes works, but not reliably. Has anyone gotten this to work? Thanks in advance, Ryan === CODE == def my_form_post_view(request): if request.method == 'POST': form = MyForm(request.POST) if form.is_valid(): first_name = form.cleaned_data['first_name'] last_name = form.cleaned_data['last_name'] address_1 = form.cleaned_data['address_1'] # SAVE THE DATA o = MyModel(first_name=first_name, last_name=last_name, address_1=address_1) o.save() # CHANGE THE FIELD NAMES AND CREATE A DICTIONARY data = dict(FirstName = first_name, LastName = last_name, Address1 = address_1) # ENCODE THE DATA params = urllib.urlencode(data) # SEND THE POST TO ANOTHER URL headers = {"Content-type": "application/x-www-form- urlencoded", "Accept": "text/plain"} conn = httplib.HTTPConnection("www.someotherurl.com") conn.request("POST", "/test-form/?", params, headers) return HttpResponseRedirect("/thank-you-guide/") else: return render_to_response('siteapp/form_template.html', {'form':form}, context_instance=RequestContext(request)) else: form = MyForm() return render_to_response('siteapp/form_template.html', {'form':form}, context_instance=RequestContext(request)) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: including non-editable fields in forms?
Thanks Malcolm. I think inserting it directly in the form template will work fine for my purposes. Margie On Feb 9, 9:18 pm, Malcolm Tredinnickwrote: > On Mon, 2009-02-09 at 21:14 -0800,Margiewrote: > > I have a model that contains a 'created' field where 'editable' is set > > to False in the model. > > > I'd like to display the created field in my form, but not allow it to > > be modified. I tried putting it in > > the include list for the form, but that didn't seem to have any affect > > (it didn't display in the form). > > > Is there a way to do this in a form or do I need to simply put the > > created field into my template separate from the display of the form? > > You could create a form Field subclass that only displays the data and > never validates it or inserts it into cleaned_data for the form. In > other words, a kind of read-only for field. There are a few details that > would have to be sorted out, but it sounds eminently possible if you > were going to do this a lot. One day we'll eventually add support for > read-only items in the admin and we'll have to invent something like > that for those, I suspect. > > On the other hand, I've always just inserted it directly into the form > template when I've had this kind of situation. > > 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: YUI Image Uploader - OK on Firefox/Mac but not elsewhere
I'm pretty sure I have all the paths correct because the TinyMCE/ Filebrowser works ok on firefox mac, just not on any other browser. The only setting I changed was FILEBROWSER_URL_WWW = '/site_media/ uploads/'. At this stage I am trying to get the upload to happen in PHP as I can get that to work, but it seems silly to have to do that. I will use any solution so if yours is working on multiple browsers, maybe I should give it another go. But not sure where to start in fixing it!!! Phoebe. On Feb 10, 4:49 pm, "esatterwh...@wi.rr.com"wrote: > I found the TinyMCE & filebrowser insanely easy to impliment. I would > say 9 out of the 10 issued I had was simply a matter of defining the > right paths. > > I also found that creating a symlink for the admin media folder and > calling it 'media/' solved most of the path name issues. that way you > can leave most of the default paths in the settings.py file and it > just works out of the box. > > On Feb 9, 4:39 pm, phoebebright wrote: > > > Have been trying to get a RTE plugin working that will allow upload of > > images. The YUI verion is almost there but will not play well with > > browsers. > > > The plugin from > > herehttp://allmybrain.com/2008/11/06/example-yui-image-upload-with-yui-260/ > > I modified to get Javascript to make an asynchronous call to this > > function in the view: > > > def uploadimage(request): > > try: > > upload_full_path = settings.CONTENT_IMAGES > > > upload = request.FILES['image'] > > dest = open(os.path.join(upload_full_path, upload.name), > > 'wb+') > > > for chunk in upload.chunks(): > > dest.write(chunk) > > > dest.close() > > > result='{status:"UPLOADED",image_url:"%s%s"}' % > > (settings.CONTENT_IMAGES_URL, upload.name) > > > return_data = HttpResponse(result,mimetype='Content-Type: > > text/ > > html') > > > except Exception, e: > > return_data = HttpResponse("Error in uploading image") > > > return_data.flush() > > > return return_data > > > The plugin was written for turbon gears/php and there is a tg example > > here: > > >http://allmybrain.com/2007/10/22/yui-image-uploader-example-with-turb... > > > Firefox/Mac works perfectly. Safari downloads the image instead. No > > version on PC appears to do anything, (but only have Mac for local > > testing.) > > Have tried every possible permutation of the content-type, Content- > > Type and text/html definitely is the way to go. Various threads on > > python refer to the need to open the file for reading as rb to make > > sure windows knows it is binary, but not sure how to do that as the > > response data is already in memory. > > > In desperation I have also tried to implement image upload in TinyMCE > > - can't get FileBrowser working on PC. and FCKeditor no modifiable > > image upload that I could find. So I am back with YUI and hoping > > someone can suggest something to try > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: YUI Image Uploader - OK on Firefox/Mac but not elsewhere
I found the TinyMCE & filebrowser insanely easy to impliment. I would say 9 out of the 10 issued I had was simply a matter of defining the right paths. I also found that creating a symlink for the admin media folder and calling it 'media/' solved most of the path name issues. that way you can leave most of the default paths in the settings.py file and it just works out of the box. On Feb 9, 4:39 pm, phoebebrightwrote: > Have been trying to get a RTE plugin working that will allow upload of > images. The YUI verion is almost there but will not play well with > browsers. > > The plugin from > herehttp://allmybrain.com/2008/11/06/example-yui-image-upload-with-yui-260/ > I modified to get Javascript to make an asynchronous call to this > function in the view: > > def uploadimage(request): > try: > upload_full_path = settings.CONTENT_IMAGES > > upload = request.FILES['image'] > dest = open(os.path.join(upload_full_path, upload.name), > 'wb+') > > for chunk in upload.chunks(): > dest.write(chunk) > > dest.close() > > result='{status:"UPLOADED",image_url:"%s%s"}' % > (settings.CONTENT_IMAGES_URL, upload.name) > > return_data = HttpResponse(result,mimetype='Content-Type: > text/ > html') > > except Exception, e: > return_data = HttpResponse("Error in uploading image") > > return_data.flush() > > return return_data > > The plugin was written for turbon gears/php and there is a tg example > here: > > http://allmybrain.com/2007/10/22/yui-image-uploader-example-with-turb... > > Firefox/Mac works perfectly. Safari downloads the image instead. No > version on PC appears to do anything, (but only have Mac for local > testing.) > Have tried every possible permutation of the content-type, Content- > Type and text/html definitely is the way to go. Various threads on > python refer to the need to open the file for reading as rb to make > sure windows knows it is binary, but not sure how to do that as the > response data is already in memory. > > In desperation I have also tried to implement image upload in TinyMCE > - can't get FileBrowser working on PC. and FCKeditor no modifiable > image upload that I could find. So I am back with YUI and hoping > someone can suggest something to try --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Filter by ForeignKey reference??
That's it - thanks a lot!!! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
0.96 to 1.0 admin conversion
I'm in the process of converting a project from 0.96 to 1.0. The newforms admin has me a little stumped. The way I currently have one of my models set up is like so: cpip = models.ForeignKey('Cpip', edit_inline=models.TABULAR, num_in_admin=10, num_extra_on_change=3) That will give me 10 inlines initially and when I save will give me 3 extras. I like the way that works because when I create the object, I have up to 10 related objects that I want to add, but after that, I typically only need to add one or two. With the newforms admin, the only options that I have found are extra and max_num. If I set extra to 10, I get 10 inlines initially, but when I save I get an additional 10 empties that I don't want. I haven't been able to find any combination of extra and max num that works for me. I'm sorry if this has already been answered somewhere before. I wasn't able to find anything after some googling. Thanks, Brian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
version control convention?
Is it better to create repositories at a site-, project- or app-level? In other words, if I implement the conventional[1] directory structure below, is it better to place the entire site (example.com) under a single git repository, or would it be wiser to create separate git repos for each custom app? Any suggestions on the best course of action (Perhaps something to add to the conventions list)? example.com/ settings.py urls.py local_apps/ custom apps written for this project (Preferably Reusable; Probably on your PYTHONPATH) external_apps/ External reusable apps you are using on this project Note: These apps can also live anywhere on your PYTHONPATH projects/ dev_example/ production_example/ django96_example/ manage.py, settings, urls, etc docs/ This will hold the documentation for your project static/ -In production this will be the root of your MEDIA_URL css/ js/ images/ tests/ - Project level tests (Each app should also have tests) uploads/ - content imgs, etc templates/ - This area is used to override templates from your reusable apps flatpages/ comments/ example/ app1/ app2/ [1] http://ericholscher.com/projects/reusable-app-docs/projects/overview.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Pretty admin pages
On Tue, Feb 10, 2009 at 12:38 PM, djandrowwrote: > > I believe its quite akward to create a system link in XP so I tried > copying them to myproject/media file, but it didn't like that either. > > Should they go in the htdocs file or what? > This is more an Apache question, things should be set up in a way such that when you access, for example django/contrib/admin/media/img/arrow-down-png (or a copy of it) can be accessed through http://yourhost/media/img/arrow-down-png and yes, as the "2. Or, copy the admin media files so that they live within your Apache document root." blurb suggests, copying the django/contrib/admin/media tree to your document root would be one way of achieving this. Another option would be to use the Alias and Directory apache configuration directives (http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias) -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: m2m field and forms
On Feb 10, 5:51 pm, Sergey Kovalwrote: > On Tue, Feb 10, 2009 at 1:21 PM, Konstantin S wrote: > > > Hello > > > I have a form created from forms.ModelForm and in my model one of the > > fields is m2m field. Now when form is displayed for that m2m filed I'd > > like to have something that looks like checkbox where user can select > > several alternatives. I know that I can use widgets here and there are > > some that can be used in my case, but I don't know how do I use them > > in case of form being generated as ModelForm ? > > If you want to show multiple checkboxes, use CheckboxSelectMultiple widget. > > Sample code: > > class MyForm(forms.ModelForm): > my_field = fields.ModelMultipleChoiceField(queryset=your_query_set, > widget=forms.CheckboxSelectMultiple) > Thanks, that's exactly I was looking for. I didn't know that fields may be overwritten if the form is derived from a forms.ModelForm class --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: A solution for django/postgresql transaction problem
On Tue, Feb 10, 2009 at 9:58 AM, azerwrote: > > Hi, > I modified django's db/backends/postgresq_psycopg2/base.py and fixed > the problem.I added this lines before "cursor = self.connection.cursor > ()": > ># if transaction is broken, run rollback method >if self.connection.get_transaction_status()==3: >self.connection.rollback() ># > > I hope it will be useful for you too.Also, I've written a blog post > about this; > > http://berraksular.blogspot.com/2009/02/transaction-problem-of-django-and.html > Some description of the problem you are trying to solve here would have been useful. Based on what the code does, I guess you are trying to fix the problem that once some sort of database error is encountered, PostgreSQL refuses to process any subsequent commands in that transaction and instead returns another error along the lines of "current transaction is aborted, commands ignored until end of transaction block"? I don't believe what you have proposed here is a good solution. When the original error occurs, an exception is raised. In order for your code to get to the point of issuing another SQL command in that transaction, some code had to catch that exception and decide to continue on instead of abandoning whatever is being attempted. It is the code that catches the original exception and decides to proceed on anyway that should be responsible for restoring the connection to a state where SQL commands can be issued. That is the code that has enough context to know it is safe to proceed in the face of whatever error caused the exception, and to know that rolling back whatever has been done so far and continuing on is OK. Burying the rollback in the driver essentially hides an error from the calling code. This level of code has no context for knowing that it is safe to proceed in this situation, rather the reverse. All this code knows is that some database error has occurred, and whatever code caught the resulting exception did not restore the connection to a usable state, which rather implies the code that caught the exception didn't fully understand the exception it caught. That's not a situation that should be silently ignored. 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: Question about Filtering on a Related model (I think) - with example code.
On Feb 10, 2:25 pm, Almost Georgewrote: > On Feb 10, 1:30 am, Daniel Roseman > wrote: > That doesn't seem to work. Here's my manage.py shell session, which > appears as I expected it to: (hopefully email clients/google won't > screw up the quoting, otherwise seehttp://dpaste.com/118932/) > > >>> from xmx.models import Band > >>> b = Band.objects.get(name__startswith='r') > >>> b > > >>> b.get_upcoming_events > > > b.get_upcoming_events() > > Traceback (most recent call last): > File "", line 1, in > File "//x/django_projects/../xmx/models.py", line 39, in > get_upcoming_events > return self.event.eventoccurrence_set.filter > (start__gte=datetime.today()) > AttributeError: 'Band' object has no attribute 'event' > > - Any other suggestions? Aah, sorry, didn't read the models properly. Try this: events = EventOccurrence.objects.filter( start__gte=datetime.today(), event__bands=self ) Not sure if that will work, but I often find that it helps to turn a query around so you start with the model you want, and filter it back to include the related object you have, if you see what I mean. -- 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 Filtering on a Related model (I think) - with example code.
On Feb 10, 8:25 am, Almost Georgewrote: > On Feb 10, 1:30 am, Daniel Roseman > wrote: > > > > > On Feb 10, 5:03 am, Almost George > > wrote: > > > > On the following example models (actual models, removed of cruft that > > > doesn't seem to apply) I'd like to add a "get_upcoming_events" method > > > to Band like the one on Venue, but because of the relationship I'm not > > > sure how to use the API/filter. (An Event has the same bands, at > > > possibly different occurrences, whereas each Occurrence happens at a > > > particular Venue - if the models/structure needed justifying). > > > > [ code highlighted @ dpaste:http://dpaste.com/118817/] > > > > class Event(models.Model): > > > name = models.CharField(max_length=50, unique=True) > > > bands = models.ManyToManyField(Band) > > > > class EventOccurrence(models.Model): > > > name = models.CharField(max_length=50, blank=True) > > > venue = models.ForeignKey(Venue) > > > event = models.ForeignKey(Event) > > > start = models.DateField() > > > end = models.DateField() > > > > class Band(models.Model): > > > admin_approved = models.BooleanField(default=False) > > > name = models.CharField(max_length=50, unique=True) > > > > def get_upcoming_events(self): > > > # How do I get Events, where the EventOccurrence.start is > > > filtered > > > # the same as this method on the Venue model? > > > pass > > > > class Venue(models.Model): > > > name = models.CharField(max_length=50) > > > > def get_upcoming_events(self): > > > return self.eventoccurrence_set.filter > > > (start__gte=datetime.today()) > > > Looks like you could just use the same filter as in Venue, just adding > > 'event' before: > > self.event.eventoccurence_set.filter(...) > > -- > > DR. > > That doesn't seem to work. Here's my manage.py shell session, which > appears as I expected it to: (hopefully email clients/google won't > screw up the quoting, otherwise seehttp://dpaste.com/118932/) > > >>> from xmx.models import Band > >>> b = Band.objects.get(name__startswith='r') > >>> b > > >>> b.get_upcoming_events > > > b.get_upcoming_events() > > Traceback (most recent call last): > File "", line 1, in > File "//x/django_projects/../xmx/models.py", line 39, in > get_upcoming_events > return self.event.eventoccurrence_set.filter > (start__gte=datetime.today()) > AttributeError: 'Band' object has no attribute 'event' > > - Any other suggestions? I'm going to wrap this up with the (a?) correct answer: I was going about this backwards by going about it in a forward way. I should have been thinking backwards, in other words. I simply changed the Band model to have this method: def get_upcoming_events(self): """ Get the list of upcoming events for this band. """ #return self.event_set.eventoccurrence_set.filter (start__gte=datetime.today()) return EventOccurrence.objects.filter (event__bands__id=self.id) Starting with what I wanted, instead of "where I was". If this is not the correct way (for intuitive or other reasons) please let me know. Just wanted to make sure I put a "solution" to the problem I posted. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
A solution for django/postgresql transaction problem
Hi, I modified django's db/backends/postgresq_psycopg2/base.py and fixed the problem.I added this lines before "cursor = self.connection.cursor ()": # if transaction is broken, run rollback method if self.connection.get_transaction_status()==3: self.connection.rollback() # I hope it will be useful for you too.Also, I've written a blog post about this; http://berraksular.blogspot.com/2009/02/transaction-problem-of-django-and.html regards azer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Key Erro: 'perms' whenever I try and view a table in Admin
On Tue, Feb 10, 2009 at 9:46 AM, merricwrote: > > Help! Completely stuck with this one. Everytime I try to view any > table in the Admin I get an error. > > I am getting a KEY ERROR with exception value of 'perms': > > Exception Location: C:\Python25\Lib\site-packages\django-trunk\django > \template\context.py in __getitem__, line 43 > > Anybody have any ideas what might be causing this? > Whatever you changed right before it started happening likely caused it. You've given no context for what you've been doing so it's a little hard to guess what that might have been. You've also left out the full traceback, which might give a hint. 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: m2m field and forms
On Tue, Feb 10, 2009 at 1:21 PM, Konstantin Swrote: > > Hello > > I have a form created from forms.ModelForm and in my model one of the > fields is m2m field. Now when form is displayed for that m2m filed I'd > like to have something that looks like checkbox where user can select > several alternatives. I know that I can use widgets here and there are > some that can be used in my case, but I don't know how do I use them > in case of form being generated as ModelForm ? If you want to show multiple checkboxes, use CheckboxSelectMultiple widget. Sample code: class MyForm(forms.ModelForm): my_field = fields.ModelMultipleChoiceField(queryset=your_query_set, widget=forms.CheckboxSelectMultiple) -- Serge --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Key Erro: 'perms' whenever I try and view a table in Admin
Help! Completely stuck with this one. Everytime I try to view any table in the Admin I get an error. I am getting a KEY ERROR with exception value of 'perms': Exception Location: C:\Python25\Lib\site-packages\django-trunk\django \template\context.py in __getitem__, line 43 Anybody have any ideas what might be causing this? Cheers MerMer --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Pretty admin pages
I believe its quite akward to create a system link in XP so I tried copying them to myproject/media file, but it didn't like that either. Should they go in the htdocs file or what? Thanks, Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 Filtering on a Related model (I think) - with example code.
On Feb 10, 1:30 am, Daniel Rosemanwrote: > On Feb 10, 5:03 am, Almost George > wrote: > > > > > On the following example models (actual models, removed of cruft that > > doesn't seem to apply) I'd like to add a "get_upcoming_events" method > > to Band like the one on Venue, but because of the relationship I'm not > > sure how to use the API/filter. (An Event has the same bands, at > > possibly different occurrences, whereas each Occurrence happens at a > > particular Venue - if the models/structure needed justifying). > > > [ code highlighted @ dpaste:http://dpaste.com/118817/] > > > class Event(models.Model): > > name = models.CharField(max_length=50, unique=True) > > bands = models.ManyToManyField(Band) > > > class EventOccurrence(models.Model): > > name = models.CharField(max_length=50, blank=True) > > venue = models.ForeignKey(Venue) > > event = models.ForeignKey(Event) > > start = models.DateField() > > end = models.DateField() > > > class Band(models.Model): > > admin_approved = models.BooleanField(default=False) > > name = models.CharField(max_length=50, unique=True) > > > def get_upcoming_events(self): > > # How do I get Events, where the EventOccurrence.start is > > filtered > > # the same as this method on the Venue model? > > pass > > > class Venue(models.Model): > > name = models.CharField(max_length=50) > > > def get_upcoming_events(self): > > return self.eventoccurrence_set.filter > > (start__gte=datetime.today()) > > Looks like you could just use the same filter as in Venue, just adding > 'event' before: > self.event.eventoccurence_set.filter(...) > -- > DR. That doesn't seem to work. Here's my manage.py shell session, which appears as I expected it to: (hopefully email clients/google won't screw up the quoting, otherwise see http://dpaste.com/118932/ ) >>> from xmx.models import Band >>> b = Band.objects.get(name__startswith='r') >>> b >>> b.get_upcoming_events > >>> b.get_upcoming_events() Traceback (most recent call last): File "", line 1, in File "//x/django_projects/../xmx/models.py", line 39, in get_upcoming_events return self.event.eventoccurrence_set.filter (start__gte=datetime.today()) AttributeError: 'Band' object has no attribute 'event' - Any other suggestions? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Forms, fields and widgets
On Tue, Feb 10, 2009 at 10:14 AM, Malcolm Tredinnick < malc...@pointy-stick.com> wrote: > Your constraints are a bit arbitrary and, in fact, overly-restrictive. > In particular the "without changing ModelForm" wish is just that: a > hope, not something that falls out of the design as "it looks like this > must be possible." A ModelForm is a form that maps each model field to a > particular form field. That's all. It's not a prototype for arbitrary > model -> form mappings. Rather, it implements one particular sort of > (commonly useful) mapping. Indeed. And it also has special rules for foreign and m2m model fields. At the moment, for foreign key, model instance will be replaced with model id. And that's a bit restrictive. > I wouldn't be thinking about this from the widget level. Widgets are > just the rendering side. The better question is how to construct a form > class that allows you to specify form fields which can work with this > information. You're asking how to create a particular sort of form field > (Django-form field, not HTML-form field) here. The final rendering, via > Django-form widgets, will almost certainly just use normal (existing) > widgets. That's correct. I just want to have possibility for my custom form fields to participate in initial_data generation process (that's how ModelForm captures data from the model instance). Problem is in asymmetry: field which surely works only with models (ModelChoiceField/ModelMultipleChoiceField) is used to convert raw data (model id) to appropriate model instance, but not vice a versa. So I can create field that will "clean" raw data to model of my choice with some additional logic applied, but in order to do reverse conversion (from model to raw data) - I have to change ModelForm itself. That's what was bugging me :-) > I haven't worked out an answer, in terms of code, to your problem yet, > beyond thinking it didn't seem to hard. I'll try to find some time > tonight to work out some specifics and post tomorrow if nobody else > comes up with a passable solution. But, in the interests of > understanding the issue properly, I would suggest you spend a bit more > time thinking about this yourself, based on the lines I've written > above, rather than hoping somebody might give you the answer outright in > such a short space of time. > No need to, thank you. I know how to do it (by overriding default ModelForm behavior). It was more of the Thanks, Serge. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: trouble with template tag
On Feb 10, 2:07 pm, Bobby Robertswrote: > Hi. I have the following template tag: > > @register.filter(name='elementtotext') > @stringfilter > def elementtotext(string): > itext='Unknown' > if string=='DR': > itext='Door' > if string=='FL': > itext='Flooring' > if string=='FO': > itext='Foundation' > if string=='FR': > itext='Framing' > if string=='GR': > itext='Grounds' > if string=='HV': > itext='HVAC / Utilities' > if string=='MI': > itext='Miscellaneous' > if string=='RF': > itext='Roof' > if string=='WM': > itext='Wall Material' > if string=='WI': > itext='Window' > return itext > > The purpose of the tag is to take a record set field value and return > the text equivalent of that value. My field name in this example is > tm.element. > > I can print the raw code to the screen fine but I'm having trouble > running it through my template tag. Can someone tell me the proper > syntax? > > I'm trying {% elementtotext tm.element %} and it errors out. > > I'm using python2.5 and django .97 or thereabout. This is a filter, not a tag. So you just use the filter syntax on a variable: {{ tm.element|elementtotext }} By the way, you might find it easier to use a dictionary to map your template strings, rather than a whole load of if/else blocks: mapping = { 'DR': 'door', (etc) } itext = mapping.get(string, 'unknown') -- 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 -~--~~~~--~~--~--~---
trouble with template tag
Hi. I have the following template tag: @register.filter(name='elementtotext') @stringfilter def elementtotext(string): itext='Unknown' if string=='DR': itext='Door' if string=='FL': itext='Flooring' if string=='FO': itext='Foundation' if string=='FR': itext='Framing' if string=='GR': itext='Grounds' if string=='HV': itext='HVAC / Utilities' if string=='MI': itext='Miscellaneous' if string=='RF': itext='Roof' if string=='WM': itext='Wall Material' if string=='WI': itext='Window' return itext The purpose of the tag is to take a record set field value and return the text equivalent of that value. My field name in this example is tm.element. I can print the raw code to the screen fine but I'm having trouble running it through my template tag. Can someone tell me the proper syntax? I'm trying {% elementtotext tm.element %} and it errors out. I'm using python2.5 and django .97 or thereabout. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
On Tue, Feb 10, 2009 at 6:41 AM, igorlashwrote: > > > If I have correctly interpreted you correctly, this was an > > extraordinarily long-winded way to ask "Is there anywhere I can > > download a PDF of the Django documentation, and if not, why not?" > > I've not asked "Is there anywhere I can > download a PDF of the Django documentation, and if not, why not?" > because I know the answer. > > > > Time is an extremely limited resource on any volunteer project, and > > the core developers have made the decision that having an offline PDF > > version of the docs is a lower priority to improving Django as a tool, > > and improving the documentation that ships with Django and is > > available as an online resource. > > The django community should allow to download html version of > documentation to make this project more attractive , I'm sure it > doesn't take a lot of time to generate it on configured environment. > But a lot of time can be saved on django users' side.More over it can > be critical on making decision between this or other framework. > > > On Feb 10, 1:09 pm, Russell Keith-Magee > wrote: > > On Tue, Feb 10, 2009 at 4:21 PM, igorlash wrote: > > > > > Hi everybody. > > > I'm java developer , and I like comparing web frameworks. > > > Members of django community talk a lot about easiness of django > > > especially comparing with java frameworks. But they have not compared > > > all aspects. And I want to compare one of them. > > > As user of good web framework I want to have documentation on my > > > computer and have possibility to read it offline. > > > Let's compare spring framework and django. > > > To get spring documentation I can download spring , and this zip file > > > contains apis , reference manuals (in PDF and HTML formats). Or I can > > > visit this pagehttp://www.springsource.org/documentationand download > > > PDF or view HTML online (we will not take viewing HTML online into > > > account , I've mentioned about it only to be honest). > > > > > And now most interesting , let take a look at django. When you > > > download django you have documentation in ReStructured Text format > > >http://docs.djangoproject.com/en/dev/faq/general/#how-can-i-download-.. > .. > > > This format is not very readable so I've decided to convert it to html > > > or something other. > > > I was very surprised when I found makefile in the root of doc folder. > > > GREAT , to read documentation offline we need to install make.But not > > > all python developers , especially web developers know something about > > > make. Ok , I've installed make. But after that I found out I need to > > > install one more tool Sphinx But Sphinx requires some dependencies > > > and the easiest way to install them all is installing easy_install. Ok > > > I've installed easy_install and Sphinx but after that I've got error > > > about absence of some module (djangodocs).On this stage I gave up. > > > > > It's very interesting why I can't download django documentation in the > > > same way as I can download spring documentation or python > > > documentation (http://docs.python.org/download.html) ? > > > > If I have correctly interpreted you correctly, this was an > > extraordinarily long-winded way to ask "Is there anywhere I can > > download a PDF of the Django documentation, and if not, why not?" > > > > No - we don't provide a PDF version of the documentation. This idea > > has been proposed a few times in Django's history, but it has been > > rejected in favour of providing the tools to let people build offline > > versions by themselves. > > > > Django's documentation is constantly improving, even for old versions. > > Producing (and keeping up to date) PDF versions takes time. Yes, this > > process could be automated, but building and maintaining the framework > > to allow for automated documentation builds would take time. > > > > Time is an extremely limited resource on any volunteer project, and > > the core developers have made the decision that having an offline PDF > > version of the docs is a lower priority to improving Django as a tool, > > and improving the documentation that ships with Django and is > > available as an online resource. > > > > If you are having difficulties building the docs into a standalone > > format, feel free to ask questions on this mailing list. We would also > > welcome any suggestions for improvements to the documentation for this > > process of building the documentation. > > > > Yours, > > Russ Magee %-) > > > > Every checkout of the Django source tree includes the full set of docs, which you are able to build into HTML, or Latex, or PDF or what have you using Sphinx. Personally I always keep a local copy of the HTML docs built. 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
Re: comparisons with java framework
> If I have correctly interpreted you correctly, this was an > extraordinarily long-winded way to ask "Is there anywhere I can > download a PDF of the Django documentation, and if not, why not?" I've not asked "Is there anywhere I can download a PDF of the Django documentation, and if not, why not?" because I know the answer. > Time is an extremely limited resource on any volunteer project, and > the core developers have made the decision that having an offline PDF > version of the docs is a lower priority to improving Django as a tool, > and improving the documentation that ships with Django and is > available as an online resource. The django community should allow to download html version of documentation to make this project more attractive , I'm sure it doesn't take a lot of time to generate it on configured environment. But a lot of time can be saved on django users' side.More over it can be critical on making decision between this or other framework. On Feb 10, 1:09 pm, Russell Keith-Mageewrote: > On Tue, Feb 10, 2009 at 4:21 PM, igorlash wrote: > > > Hi everybody. > > I'm java developer , and I like comparing web frameworks. > > Members of django community talk a lot about easiness of django > > especially comparing with java frameworks. But they have not compared > > all aspects. And I want to compare one of them. > > As user of good web framework I want to have documentation on my > > computer and have possibility to read it offline. > > Let's compare spring framework and django. > > To get spring documentation I can download spring , and this zip file > > contains apis , reference manuals (in PDF and HTML formats). Or I can > > visit this pagehttp://www.springsource.org/documentationand download > > PDF or view HTML online (we will not take viewing HTML online into > > account , I've mentioned about it only to be honest). > > > And now most interesting , let take a look at django. When you > > download django you have documentation in ReStructured Text format > >http://docs.djangoproject.com/en/dev/faq/general/#how-can-i-download- > > This format is not very readable so I've decided to convert it to html > > or something other. > > I was very surprised when I found makefile in the root of doc folder. > > GREAT , to read documentation offline we need to install make.But not > > all python developers , especially web developers know something about > > make. Ok , I've installed make. But after that I found out I need to > > install one more tool Sphinx But Sphinx requires some dependencies > > and the easiest way to install them all is installing easy_install. Ok > > I've installed easy_install and Sphinx but after that I've got error > > about absence of some module (djangodocs).On this stage I gave up. > > > It's very interesting why I can't download django documentation in the > > same way as I can download spring documentation or python > > documentation (http://docs.python.org/download.html) ? > > If I have correctly interpreted you correctly, this was an > extraordinarily long-winded way to ask "Is there anywhere I can > download a PDF of the Django documentation, and if not, why not?" > > No - we don't provide a PDF version of the documentation. This idea > has been proposed a few times in Django's history, but it has been > rejected in favour of providing the tools to let people build offline > versions by themselves. > > Django's documentation is constantly improving, even for old versions. > Producing (and keeping up to date) PDF versions takes time. Yes, this > process could be automated, but building and maintaining the framework > to allow for automated documentation builds would take time. > > Time is an extremely limited resource on any volunteer project, and > the core developers have made the decision that having an offline PDF > version of the docs is a lower priority to improving Django as a tool, > and improving the documentation that ships with Django and is > available as an online resource. > > If you are having difficulties building the docs into a standalone > format, feel free to ask questions on this mailing list. We would also > welcome any suggestions for improvements to the documentation for this > process of building the documentation. > > Yours, > Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Deploying Django tutorial part 4, redirecting problem, apache error
Where exactly do you put this I'm guessing in the file, but a bit of context would be appreciated. On Jan 19, 7:17 am, Adam Yeewrote: > Success. I added > > 'script_name': request.META['SCRIPT_NAME'] > > into the context of object_detail() in django's generic views > list_detail.py. Here's the modified form tag to the polls_detail.html > template: > > method="post"> > > Note removing the / before {{ script_name }} > > Just to reiterate what Preston said, please share other solutions. > > On Jan 18, 8:13 pm, Adam Yee wrote: > > > On Jan 18, 7:39 am, ptone wrote: > > > > In thetutorial, the form action in the poll_detail template is > > > hardcoded to "/polls/..." > > > > So the browser is doing what's been explicitly asked of it, despite > > > Django doing its best to deal gracefully with your mounting the app > > > at /mysite. > > > > In my own newcomer approach, the way I found to work around this is to > > > pass in the script name into the context that goes to the template in > > > the render_to_response line of the view > > > > 'script_name':request.META['SCRIPT_NAME'] > > > > and then use that in the form action URL: > > > > > > method="post"> > > > Preston, thanks for pointing this out. You're right about the url > > being hardcoded and the prefix not being passed. I played around with > > your request.META['SCRIPT_NAME'] suggestion. I can't figure out how > > to pass the initial 'script_name' to the poll_detail before trying to > > vote. In other words, it seems like I would need to include > > 'script_name' in the context passed to the generic view > > (object_detail) before it can properly be used in the form. > > > If I add an {% if script_name %} in the poll_detail template or just a > > {{ script_name }}, it would need to be rendered before accessing the > > vote view. Maybe you can ellaborate on your method of getting django > > to recognize the prefix. Portability is looking difficult at this > > point. Thanks to all for your help. > > > > This proobably means a // in the URL if you mount your site at /, but > > > I think most browsers and servers won't care about that extra / > > > > I welcome anyone pointing out a better way to make the form action > > > more "portable" in projects... > > > > -Preston > > > > On Jan 17, 7:53 pm, Adam Yee wrote: > > > > > It was a slam dunk for completing thetutorialin the development > > > > server, but I can't figure out this issue I'm having with the generic > > > > views while using myapacheserver. I'm unable to get the vote view > > > > toredirectcorrectly. > > > > > Myapacheerror seen here with both urls.py and views.py. Theapache > > > > config is at the bottom. > > > > >http://dpaste.com/110275/ > > > > > Voting (hiting the vote button) with or without a radio button > > > > selected is redirecting me tohttp://127.0.0.1/polls/1/vote/which > > > > gives me a 404 (and not in django's debug format) instead of ...mysite/ > > > > polls/1/vote/. > > > > > However, going in the backdoor way and manually typing > > > > inhttp://127.0.0.1/mysite/polls/1/vote/takesmethroughthe vote view > > > > KeyError exception saying "You didn't select a choice" and displays > > > > the page. I'm also able to access the results URL manually. So I'm > > > > thinking the problem lies in either the views.py, my urlconfs or > > > > something with my wsgiapacheconfig. > > > > > Can anyone see what I'm missing?- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text -- 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: Group By and aggregation
2009/2/10 Russell Keith-Magee> > > i.e., plural modules, not singular module, in the Max lookup. It's the > reverse lookup name for the module relationship on Module_scheme. For > future reference, the message on the FieldError tells you the right > name - modules. You're great. It works. Thank you so much! -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo Software e Sistemi Open Source Sede: Via Poggiali 2/bis, 47100 Forlì (FC) Tel.: +39 0543 798985 - Fax: +39 0543 579928 Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Group By and aggregation
On Tue, Feb 10, 2009 at 8:43 PM, Alessandrowrote: > > > 2009/2/10 Russell Keith-Magee >> >> >> However, if you're using Django trunk, what you want is: >> >> >>> from django.db.models import Max >> >>> qs = >> >>> Module_scheme.objects.filter(plant=3).annotate(max_energy_tot=Max('module__energy_tot')) >> >>> for mod in qs: >> ...print mod.id, mod.max_energy_tot >> >> That is - retrieve a list of Module_scheme objects associated with >> plant 3, and annotate each one of which is annotated with the maximum >> of the energy_tot of the modules related to the Module_scheme. The >> maximum is provided as an extra attribute on each of the Module_scheme >> instance. > > I cannot do this because I have a ForeignKey from Module to Module_Scheme, > and your first line returns > > FieldError: Cannot resolve keyword 'module' into field. Choices are: id, > jbox, module_number, modules, plant, rack_number Apologies - I misread the name of your class. The query should read: Module_scheme.objects.filter(plant=3).annotate(max_energy_tot=Max('modules__energy_tot')) i.e., plural modules, not singular module, in the Max lookup. It's the reverse lookup name for the module relationship on Module_scheme. For future reference, the message on the FieldError tells you the right name - modules. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Group By and aggregation
2009/2/10 Russell Keith-Magee> > > However, if you're using Django trunk, what you want is: > > >>> from django.db.models import Max > >>> qs = > Module_scheme.objects.filter(plant=3).annotate(max_energy_tot=Max('module__energy_tot')) > >>> for mod in qs: > ...print mod.id, mod.max_energy_tot > > That is - retrieve a list of Module_scheme objects associated with > plant 3, and annotate each one of which is annotated with the maximum > of the energy_tot of the modules related to the Module_scheme. The > maximum is provided as an extra attribute on each of the Module_scheme > instance. I cannot do this because I have a ForeignKey from Module to Module_Scheme, and your first line returns FieldError: Cannot resolve keyword 'module' into field. Choices are: id, jbox, module_number, modules, plant, rack_number Can I solve this problem? -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo Software e Sistemi Open Source Sede: Via Poggiali 2/bis, 47100 Forlì (FC) Tel.: +39 0543 798985 - Fax: +39 0543 579928 Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Group By and aggregation
On Tue, Feb 10, 2009 at 6:47 PM, Alessandro Ronchiwrote: > I have to get the max value of a model grouped by a field. > > The RAW SQL query is this: > > SELECT max(energy_tot) FROM fotovoltaico_modules,fotovoltaico_module_scheme > WHERE fotovoltaico_module_scheme.plant_id = 3 AND > fotovoltaico_modules.scheme_id = fotovoltaico_module_scheme.id > GROUP BY fotovoltaico_modules.scheme_id; > > I haven't found any way to make the aggregation work with the group by. > > This is my model: > http://dpaste.com/118868/ If you're using Django v1.0.X, you're on your own. Aggregates don't really exist in v1.0; you will need to use custom SQL. However, if you're using Django trunk, what you want is: >>> from django.db.models import Max >>> qs = >>> Module_scheme.objects.filter(plant=3).annotate(max_energy_tot=Max('module__energy_tot')) >>> for mod in qs: ...print mod.id, mod.max_energy_tot That is - retrieve a list of Module_scheme objects associated with plant 3, and annotate each one of which is annotated with the maximum of the energy_tot of the modules related to the Module_scheme. The maximum is provided as an extra attribute on each of the Module_scheme instance. This will return full Module_scheme objects, rather than just the Maxima like your sample SQL. If you want to restrict the columns returned, you can do that by using the values() clause on the query. > I've tried also: > qs = Modules.objects.filter(scheme__plant=3).order_by("-time") > qs.query.group_by = ["fotovoltaico_modules.scheme_id"] You shouldn't ever need to touch qs.query as an end user. That is internal logic, and is therefore not guaranteed to be backwards compatible API. There be dragons. :-) Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
m2m field and forms
Hello I have a form created from forms.ModelForm and in my model one of the fields is m2m field. Now when form is displayed for that m2m filed I'd like to have something that looks like checkbox where user can select several alternatives. I know that I can use widgets here and there are some that can be used in my case, but I don't know how do I use them in case of form being generated as ModelForm ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Pretty admin pages
On Mon, Feb 9, 2009 at 10:07 PM, djandrowwrote: > > Hello all, > > I have just set up the admin pages for my site and if i use the built > in server i get the admin with the nice templates, but if I display it > on mod_python I just get the plain text, which is pretty hard to work > with. > > I have these set up in the conf: > > >SetHandler None > > > >SetHandler None > > > and my setting py has: > > MEDIA_ROOT = '' > MEDIA_URL = '' > ADMIN_MEDIA_PREFIX = '/media/' > > what am i doing wrong or what have i missed? > This is described in the documentation: http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#id3 You should be sure the django/contrib/admin/media/ directory from the Django source code tree is published by Apache at the URL set by the ADMN_MEDIA_PREFIX setting (/media in your case). -- Ramiro Morales --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: comparisons with java framework
On Tue, Feb 10, 2009 at 4:21 PM, igorlashwrote: > > Hi everybody. > I'm java developer , and I like comparing web frameworks. > Members of django community talk a lot about easiness of django > especially comparing with java frameworks. But they have not compared > all aspects. And I want to compare one of them. > As user of good web framework I want to have documentation on my > computer and have possibility to read it offline. > Let's compare spring framework and django. > To get spring documentation I can download spring , and this zip file > contains apis , reference manuals (in PDF and HTML formats). Or I can > visit this page http://www.springsource.org/documentation and download > PDF or view HTML online (we will not take viewing HTML online into > account , I've mentioned about it only to be honest). > > And now most interesting , let take a look at django. When you > download django you have documentation in ReStructured Text format > http://docs.djangoproject.com/en/dev/faq/general/#how-can-i-download-the-django-documentation-to-read-it-offline. > This format is not very readable so I've decided to convert it to html > or something other. > I was very surprised when I found makefile in the root of doc folder. > GREAT , to read documentation offline we need to install make.But not > all python developers , especially web developers know something about > make. Ok , I've installed make. But after that I found out I need to > install one more tool Sphinx But Sphinx requires some dependencies > and the easiest way to install them all is installing easy_install. Ok > I've installed easy_install and Sphinx but after that I've got error > about absence of some module (djangodocs).On this stage I gave up. > > It's very interesting why I can't download django documentation in the > same way as I can download spring documentation or python > documentation (http://docs.python.org/download.html) ? If I have correctly interpreted you correctly, this was an extraordinarily long-winded way to ask "Is there anywhere I can download a PDF of the Django documentation, and if not, why not?" No - we don't provide a PDF version of the documentation. This idea has been proposed a few times in Django's history, but it has been rejected in favour of providing the tools to let people build offline versions by themselves. Django's documentation is constantly improving, even for old versions. Producing (and keeping up to date) PDF versions takes time. Yes, this process could be automated, but building and maintaining the framework to allow for automated documentation builds would take time. Time is an extremely limited resource on any volunteer project, and the core developers have made the decision that having an offline PDF version of the docs is a lower priority to improving Django as a tool, and improving the documentation that ships with Django and is available as an online resource. If you are having difficulties building the docs into a standalone format, feel free to ask questions on this mailing list. We would also welcome any suggestions for improvements to the documentation for this process of building the documentation. Yours, Russ Magee %-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Prepoplulate admin form with previously entered data
here is how http://docs.djangoproject.com/en/dev/ref/contrib/admin/#save-as On Tue, Feb 10, 2009 at 12:04 PM, Marco Bazzaniwrote: > you can open a patient modify it and save it as new > > On Tue, Feb 10, 2009 at 4:00 AM, Adam Woodbeck > wrote: >> >> Would it be possible to extend the ModelForm for my encounter model, >> automatically filling the form when I add a new entry? >> >> On Feb 9, 9:51 pm, Adam Woodbeck wrote: >>> I'm building my first Django app and I've run into a roadblock. I'm >>> hoping someone with more knowledge of django 1.0 can point me in the >>> right direction. >>> >>> What the app does is allow me to enter SOAP notes for each of my daily >>> patient encounters. A good amount of the data I enter from visit to >>> visit is redundant. So I'm looking to cut down on the amount of >>> typing required each time I add a new patient encounter record through >>> the admin interface. Is there any way to prepopulate a patient's >>> encounter in the admin interface using data from the patient's >>> previous encounter? >>> >>> Adam >> >> >> > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Prepoplulate admin form with previously entered data
you can open a patient modify it and save it as new On Tue, Feb 10, 2009 at 4:00 AM, Adam Woodbeckwrote: > > Would it be possible to extend the ModelForm for my encounter model, > automatically filling the form when I add a new entry? > > On Feb 9, 9:51 pm, Adam Woodbeck wrote: >> I'm building my first Django app and I've run into a roadblock. I'm >> hoping someone with more knowledge of django 1.0 can point me in the >> right direction. >> >> What the app does is allow me to enter SOAP notes for each of my daily >> patient encounters. A good amount of the data I enter from visit to >> visit is redundant. So I'm looking to cut down on the amount of >> typing required each time I add a new patient encounter record through >> the admin interface. Is there any way to prepopulate a patient's >> encounter in the admin interface using data from the patient's >> previous encounter? >> >> Adam > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
user env needed in apache with mod_wsgi
Hi list, My problem is that: since when using apache + mod_wsgi I got a neutral env for my server (e.g. PATH=/usr/bin:/bin) but in the end what I need is all the envs that is in a particular $HOME/.bashrc file in order to when server spawns a program (that may not be in the neutral PATH and besides need some extra env parameters) it can run. So what I was trying is to find a python module or code that would do something like ". $HOME/basrc" inside my python code and before executing my binary program in order to pass to it the particular user's environment. My program is called with os.spawnvp(os.P_NOWAIT, program, args) and a simple os.system(". $HOME/basrc") before spawning it doesn't work. What works is to do os.putenv('PATH', 'blabla'), but then I have to do it for every key in my bashrc file (not only silly but unmaintainable). So if someone understood my problem and could give some tip on that, it would be very much appreciated. Many thanks in advance. Alan -- Alan Wilter S. da Silva, D.Sc. - CCPN Research Associate Department of Biochemistry, University of Cambridge. 80 Tennis Court Road, Cambridge CB2 1GA, UK. >>http://www.bio.cam.ac.uk/~awd28<< --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: date error
Hello Mr Alex i think you have forgotten 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 -~--~~~~--~~--~--~---
Group By and aggregation
I have to get the max value of a model grouped by a field. The RAW SQL query is this: SELECT max(energy_tot) FROM fotovoltaico_modules,fotovoltaico_module_scheme WHERE fotovoltaico_module_scheme.plant_id = 3 AND fotovoltaico_modules.scheme_id = fotovoltaico_module_scheme.id GROUP BY fotovoltaico_modules.scheme_id; I haven't found any way to make the aggregation work with the group by. This is my model: http://dpaste.com/118868/ I've tried also: qs = Modules.objects.filter(scheme__plant=3).order_by("-time") qs.query.group_by = ["fotovoltaico_modules.scheme_id"] but it loose the order by and the results are not the same I want. Thanks in advance! -- Alessandro Ronchi Skype: aronchi http://www.alessandroronchi.net SOASI Soc.Coop. - www.soasi.com Sviluppo Software e Sistemi Open Source Sede: Via Poggiali 2/bis, 47100 Forlì (FC) Tel.: +39 0543 798985 - Fax: +39 0543 579928 Rispetta l'ambiente: se non ti è necessario, non stampare questa mail --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
autocomplete searching many to many admin with large amount of data
I've seen this discussed a few times but have yet to hear/find a suitable solution: I have a ManyToManyField in my admin which was doing great with filter_horizontal until we imported the legacy database and realized we had more than 5000 rows for said field. Needless to say writing the select takes awhile. I've looked at raw_admin_id which works only with a through=Foo (intermediary table). What i'd like to see is a selectfilter widget which does a client side autocomplete when typing 3 or more characters . I can probably fix this with a jquery GET in normal forms but can't see the wood for the trees in admin. Maybe this is easier/clearer than i thought and somebody can point me in the right direction? Or better: does anyone have a solution for this already? Thanks! Christian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Subclass conflict with admin widgets
That makes sense. I'll just create a different admin for each model. Thanks. On Feb 10, 4:36 am, Karen Traceywrote: > On Mon, Feb 9, 2009 at 5:18 PM, phoebebright wrote: > > > > > > > Yes I see that, it's just if I don't put the custom form in it works > > fine: > > > class DirectoryAdmin(admin.ModelAdmin): > > > fieldsets = [ > > (None, {'fields': ['cat','name','is_live']}), < > > CAT FIELD STILL HERE AN OK > > ('Contact', {'fields': > > ['phone','mobile','fax','email','web','address']}), > > ('Details', {'fields': > > ['description','pic1','pic2','pic3','pic4']}), > > ] > > > admin.site.register(Business,DirectoryAdmin) > > I've not looked at the admin code here to determine when it does what, > exactly, but just looking at the defs I can see what I expect is going on, > and it makes sense, For this case, your DirectoryAdmin isn't tied a a > particular model until the admin.site.register, where you tie it to the > Business model, which has the cat field, so all in OK. In your other case, > you had a custom form with a class Meta specifying model=Directory, which > does not have a cat field. So your custom form does not have the field you > are trying to list in fieldsets. > > There is no error in this case here because you don't do anything to tie > DirectoryAdmin to the Directory model instead of the Business model, whereas > in the error case you tie DirectoryAdmin to the Directory model, which does > not have the cat field, so you get an error. > > 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 -~--~~~~--~~--~--~---
signal connection
Can anyone please suggest why a signal might be failing to connect. I'm using 1.0.2 on apache + mod_wsgi. The signal gets picked up fine using the localserver, but fails on the server proper. When i go into the shell and get the signal object and check 'receivers' i can see the listener registered. But it just doesn't seem to want to fire when the event occurs. The signal is in one app's models.py, when i put a listener in that same file it picks it up fine. When i move the listener to a different app's models.py this is when it fails. Something to do with an import conflict? The second app's models.py file already imports a class from the signal's models.py file. Any suggestions very welcome, thanks! 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 -~--~~~~--~~--~--~---
Re: Forms, fields and widgets
On Tue, 2009-02-10 at 09:56 +0200, Sergey Koval wrote: > Hello, > > I read mentioned thread and still can't figure out how I can pass > arbitrary values to widgets. > OK, I'll rephrase question (it was "task" in the previous email): how > I can make widget that takes two values out of the model without > changing ModelForm behavior or doing separate query in the widget? Your constraints are a bit arbitrary and, in fact, overly-restrictive. In particular the "without changing ModelForm" wish is just that: a hope, not something that falls out of the design as "it looks like this must be possible." A ModelForm is a form that maps each model field to a particular form field. That's all. It's not a prototype for arbitrary model -> form mappings. Rather, it implements one particular sort of (commonly useful) mapping. If you're wanting to do extra stuff, it's reasonable to think that you might have to make some changes to ModelForm. You've certainly moved a bit beyond that use-case in your example. You're wanting a form based on a model where each form field have potential access to the model instance (not each form field corresponding to a single model field), so you'll have to create a class that knows how to pass in that information when requested. I wouldn't be thinking about this from the widget level. Widgets are just the rendering side. The better question is how to construct a form class that allows you to specify form fields which can work with this information. You're asking how to create a particular sort of form field (Django-form field, not HTML-form field) here. The final rendering, via Django-form widgets, will almost certainly just use normal (existing) widgets. I haven't worked out an answer, in terms of code, to your problem yet, beyond thinking it didn't seem to hard. I'll try to find some time tonight to work out some specifics and post tomorrow if nobody else comes up with a passable solution. But, in the interests of understanding the issue properly, I would suggest you spend a bit more time thinking about this yourself, based on the lines I've written above, rather than hoping somebody might give you the answer outright in such a short space of time. > Probably it is bad mailing list to ask such questions, should I go to > devel instead? This is exactly the right mailing list for this type of question. Anything of the form "how do I ...?" is a django-users question: it's asking about using Django. The django-dev list is more appropriate for topics concerning developing Django (core) itself. 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: Django and jQuery trouble
2009/2/10 min: > > Hi, everyone. > > I have a question for the following example. > > Firstly, in the view.py: > > def test_1(request, zipcode, pro): > if zipcode == 'a' and pro == 'b': >city = 'c' > else: >city = '' > > return HttpResponse(city) > > def test_0(request): > return render_to_response('test_0.html', {}) > - > Then, in the test_0.html > > > > > Register form > > > function getZipData() { >var zipcode = $('#zip').val(); >var pro = $('#pro').val(); >$.get('http://127.0.0.1/ajax/test_1/' + zipcode + '&' + pro + > '/' , function(data) { > $('#city').attr({'value':data}); >}); > } > > > > > > Pro: > Zip: > City: > > > > > > -- > In the urls.py > > (r'^ajax/test_0/$', test_0), > (r'^ajax/test_1/(\S+)/$', test_1), > --- > When I input b to the Pro inputbox and a to the Zip inputbox, and > click the done button, the firebug displays :500 Interserver Error > > I think there are some problem with the $.get('http://127.0.0.1/ajax/ > test_1/' + zipcode + '&' + pro + '/' , function(data) {$('#city').attr > ({'value':data}); }); OR > > def test_1(request, zipcode, pro): > if zipcode == 'a' and pro == 'b': >city = 'c' > else: >city = '' > > return HttpResponse(city) > > Could you please give me some idea? > Test your Ajax URL agains the view directly with the browser. It's seems there is some kind of problem there. view: def test_1(request, zipcode, pro): url (r'^ajax/test_1/(\S+)/$', test_1) At firsth sight they don't match with http://127.0.0.1/ajax/test_1/' + zipcode + '&' + pro +"/" Try: url = r'^ajax/test_1/(?P\w+)/(?P\w+)/$ ... and http://127.0.0.1/ajax/test_1/' + zipcode + '/' + pro +"/" Hope it helps! -- 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 -~--~~~~--~~--~--~---