Make New Autocomplete form field
Hello, i'm trying to do a AutoCompleteField. I'm creating a new widget (AutoCompleteWidget) to generate the code and AutoCompleteField with is a form field. The value of my field should be a tuple with (key, value). Can someone please help me. Bellow if the code i've already done. I don't understand how the field interacts with the widget. Thanks in advance. With best regards, Luis class AutoCompleteWidget(Widget): url = '' def __init__(self, attrs=None, url=None): self.attrs = attrs or {} self.url = url def render(self, name, value, attrs=None): output = [] output.append( TextInput().render('%(name)s_edit'% {'name':name}, '') ) output.append( HiddenInput().render('%(name)s_key'% {'name':name}, '') ) html =''' $(document).ready(function() { $("#% (id)s").autocomplete( "%(url)s", { delay: 10, minChars: 2, matchSubset: 1, matchContains: 1, cacheLength: 10, // onItemSelect:selectItem, // onFindValue:findValue, // formatItem:formatItem, autoFill:true, maxItemsToShow: 10 } ); }); '''%{ 'url' : self.url, 'id': '%s_edit'%name } output.append(html) return mark_safe(u'\n'.join(output)) def value_from_datadict(self, data, files, name): data = data.get('%(name)s_edit'%{'name':name}) if data: return data class AutoCompleteField(forms.MultiValueField): widget = AutoCompleteWidget def __init__(self, url=None, *args, **kwargs): self.url = url super(AutoCompleteField, self).__init__(*args, **kwargs) def clean(self, value): """ Validates that the input can be converted to a tuple (key,value) """ super(AutoCompleteField, self).clean(value) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Choices from table vs. Foreign Key relationship.
Seems like you'd want a many-to-many relationship, no? Each student gets multiple teachers, and each teacher has multiple students, unless all my years in school were for nothing :). Or am I missing something? Does delete remove FK's with M2M? J On Dec 17, 4:05 pm, radioflyer <[EMAIL PROTECTED]> wrote: > So the recommendation seems to be when your selection choices are not > static you should go ahead and use a Foreign Key relationship. You get > the automatic loading of the table into a select widget etc. > > But there's this issue of the cascade on delete. > > I have a Student model with a Foreign Key relationship to Teacher. > When a teacher is removed, so go the students. Too dangerous for my > particular scenario. There doesn't seem to be a Django feature that > allows for adjusting the cascade. > > I thought to uncouple the relationship and use the Teacher model > strictly as a 'lookup table.' > > What are best practices on this? What will I be losing if I just load > the teachers as 'choices' on the student forms? Is it worth creating > my own cascade protection to keep the Foreign Key relationship? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template text are not being escaped when used with textile
On Tue, 2007-12-18 at 09:39 -0800, shabda wrote: > So should not {{text|escape|textile}} remove html tags first, and then > apply the textile-markup to generate html? The "escape" filter does not remove HTML tags, that's done by the "striptags" filter. "Escape" converts five special characters to their corresponding HTML entities. It also applies *last* in the sequence, regardless of where you specify it (and only applies once to avoid accidental double-escaping). Read the documentation for "escape" and "force_escape" carefully (and probably the backwards incompatible changes page's entry for autoescaping, since you are making assumptions about "escape" that are based on its old behaviour). This is all explained there. Regards, Malcolm -- A clear conscience is usually the sign of a bad memory. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: get to named url pattern from request.path
On Tue, 2007-12-18 at 02:40 -0800, frank h. wrote: > hello, > in a contextprocessor i am writing, i would like to use the "named > url" of the current view instead of request.path. > > I toyd with django.core.urlresolvers.resolve() but that just returns > the function configured in urls.py and not the name it was configured > with > > to give an example: my urls.py contains this pattern > > urlpatterns += patterns('mcc.log.status', > url(r'ftpqueue/$', 'ftpqueue', name='mcc-ftpqueue'), > ) > > > in my contextprocessor, request.path is '/ftpqueue/' > now I want to get to the name: 'mcc-ftpqueue' > > how to do that? There's not built in way to do this. If you really wanted to do this in an automated way, you would need to write something like the current URL resolving code that ran through the patterns until it found a match (following include() calls as well) and then returned the pattern name. Not impossible and you could probably follow the code in urlresolvers.py initially, but not something that you'll get just by calling a single function in core(). Regards, Malcolm -- Quantum mechanics: the dreams stuff is made of. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Returning a Queryset
On Tue, 2007-12-18 at 00:16 -0800, Rufman wrote: > Hey guys > > Is there a way to return a QuerySet object, when I make my own custom > sql? No. Part of the reason is that it's not particularly useful in the general case and very easy to get into trouble. A QuerySet has a lot of methods that can be called on it that modify the eventual query. These methods are almost useless after custom SQL has been run, because we don't want to have to try and work out what your custom SQL was doing. What I suspect you are needing (since you don't explain your use-case, I'm obviously guessing a little bit) is something that has a few of the QuerySet methods -- primarily being an iterator that returns some kind of Python object instances and maybe supports the caching that QuerySets do. There are (low-priority) plans to write something like that so you can run custom SQL and pass it a dictionary or some functions that will map result rows to a Python object and support the iterator and cache. Anything beyond that is probably not useful, but I'd be interested in hearing the use-case you're wanting to solve. Malcolm -- Two wrongs are only the beginning. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: determining newforms field type in a template
On Mon, 2007-12-17 at 22:10 -0800, MrJogo wrote: > If I pass a form into my template as a variable, is there a way to > tell what input type a field is in the template? My template creates > pretty boxes for the form fields, but I don't want them around hidden > inputs. I was hoping for something like {% ifequal field.type "hidden" > %} but I can't seem to find an equivalent of field.type. Each form field that the template sees is a django.newforms.forms.BoundField instance. That class has a "is_hidden" property that does what you want. So test field.is_hidden at the template level. Regards, Malcolm -- Why can't you be a non-conformist like everyone else? http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Changing sort order of admin select object
On Mon, 2007-12-17 at 15:23 -0800, borntonetwork wrote: > Thank you Malcom. > > Could you tell me: when the functionality is available, do you know > what the steps to create the sort order will be? Yes. :-) Or were you actually asking if I could tell you what they were? In that case, see http://code.djangoproject.com/browser/django/branches/queryset-refactor/docs/db-api.txt#L517 Malcolm -- The sooner you fall behind, the more time you'll have to catch up. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: templating javascript code
On Mon, 2007-12-17 at 09:47 -0800, msoulier wrote: > On Dec 2, 8:27 pm, Darryl Ross <[EMAIL PROTECTED]> wrote: > > I've done this is CSS files before, so it should work just fine. Just > > make sure you set the correct Content-Type header in your JS view. > > FTR, this works fine. I couldn't use render_to_response() as I had to > supply the mimetype, but otherwise it works fine. render_to_response() can be passed "mimetype=". Malcolm -- Remember that you are unique. Just like everyone else. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django requires db access to dump sql that it would use in syncdb
On Mon, 2007-12-17 at 09:45 -0800, msoulier wrote: > I'm trying to write db initialization code for an existing db > framework on a product that I work on. To do this I'm "asking" django > to show SQL that it would use to create its db, so I can copy it into > the initialization code. > > I can't though, as I haven't created the db yet, and for some reason > it requires access to the db, even though it's not actually performing > any operations on the db. > > [EMAIL PROTECTED] servermanager]# python manage.py sql main > BEGIN; > Traceback (most recent call last): > File "manage.py", line 12, in ? > execute_manager(settings) > File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/ > django/core/management.py", line 1672, in execute_manager > File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/ > django/core/management.py", line 1632, in execute_from_command_line > File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/ > django/core/management.py", line 123, in get_sql_create > File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/ > django/core/management.py", line 68, in _get_table_list > File "/var/tmp/django-0.96-root/usr/lib/python2.3/site-packages/ > django/db/backends/postgresql_psycopg2/base.py", line 48, in cursor > psycopg2.OperationalError: FATAL: Password authentication failed for > user "smeserver" > > Seems like a bit of a chicken and egg problem. I'll create the db and > user now, but I don't see why it should be required when it's not > being used by the command. I suppose it might not be fixable, as it > may be in the psycopg2 module. Unfortunate, but not really worth worrying about. This is such an edge-case that this isn't really worth putting in any significant extra code to work around. Just create the database and you won't have the problem. It's so rare as to be effectively non-existent that you'll be wanting to view the SQL and never, ever connect to the database. Malcolm -- Tolkien is hobbit-forming. http://www.pointy-stick.com/blog/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Allowing downloads for only certain users
It would be great if the apache_auth module had a user passes test function instead of using permissions. Here is a good article on using lighttpd w/ mod_secdownload: http://isdevelopment.weblog.glam.ac.uk/news/en/2006/nov/30/secure-downloads-django/ On Dec 18, 7:12 pm, Jonathan Buchanan <[EMAIL PROTECTED]> wrote: > Ryan K wrote: > > What is the best way to serve static media and only letting certain > > users (using django.contrib.auth) download that data? > > > Thanks, > > Ryan Kaskel > > http://blog.lighttpd.net/articles/2006/07/02/x-sendfilehttp://tn123.ath.cx/mod_xsendfile/ > > Jonathan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Allowing downloads for only certain users
Ryan K wrote: > What is the best way to serve static media and only letting certain > users (using django.contrib.auth) download that data? > > Thanks, > Ryan Kaskel http://blog.lighttpd.net/articles/2006/07/02/x-sendfile http://tn123.ath.cx/mod_xsendfile/ Jonathan. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: completely escaping an included template
On Dec 18, 8:12 pm, Bram - Smartelectronix <[EMAIL PROTECTED]> wrote: > Hello everyone, > > trying to upgrade to the latest trunk, I'm wrestling a bit with the > autoescape function. Talking about embed-code for an enduser, I used to > write: > > {% include embedded_player.html %} > Copy-paste this: > > The first part shows to the end-user how the embeddable player will look > like, the second shows the user the code he can copy-paste. Now with > autoembed this no longer works as "escape" doesn't exist anymore as a > filter. See http://www.djangoproject.com/documentation/templates/#force-escape --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
syncdb problem: ValueError: list.remove(x): x not in list
I have django dev version 6941. There seems to be a problem with manage.py line when I do python manage.py syncdb: execute_manager(settings) It creates the tables and but fails to populate initial data. #!/usr/bin/env python from django.core.management import execute_manager try: # This is for Dos Prompt Start up import settings except ImportError: import sys sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__) sys.exit(1) if __name__ == "__main__": execute_manager(settings) [EMAIL PROTECTED] mysite]$ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 15, in ? execute_manager(settings) File "/usr/lib/python2.4/site-packages/django/core/management/ __init__.py", line 272, in execute_manager utility.execute() File "/usr/lib/python2.4/site-packages/django/core/management/ __init__.py", line 219, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/lib/python2.4/site-packages/django/core/management/ base.py", line 72, in run_from_argv self.execute(*args, **options.__dict__) File "/usr/lib/python2.4/site-packages/django/core/management/ base.py", line 86, in execute output = self.handle(*args, **options) File "/usr/lib/python2.4/site-packages/django/core/management/ base.py", line 168, in handle return self.handle_noargs(**options) File "/usr/lib/python2.4/site-packages/django/core/management/ commands/syncdb.py", line 95, in handle_noargs emit_post_sync_signal(created_models, verbosity, interactive) File "/usr/lib/python2.4/site-packages/django/core/management/ sql.py", line 489, in emit_post_sync_signal verbosity=verbosity, interactive=interactive) File "/usr/lib/python2.4/site-packages/django/dispatch/ dispatcher.py", line 358, in send sender=sender, File "/usr/lib/python2.4/site-packages/django/dispatch/ robustapply.py", line 47, in robustApply return receiver(*arguments, **named) File "/usr/lib/python2.4/site-packages/django/contrib/contenttypes/ management.py", line 21, in update_contenttypes content_types.remove(ct) ValueError: list.remove(x): x not in list thanks, joe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Allowing downloads for only certain users
On Dec 18, 2007 3:50 PM, Ryan K <[EMAIL PROTECTED]> wrote: > What is the best way to serve static media and only letting certain > users (using django.contrib.auth) download that data? http://www.djangoproject.com/documentation/apache_auth/ -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Allowing downloads for only certain users
What is the best way to serve static media and only letting certain users (using django.contrib.auth) download that data? Thanks, Ryan Kaskel --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
sending >500 emails using send_email in a for loop
I've built a newsletter app that currently cycles through 500+ emails and I'd like to have it scale to handle more. Currently I just have code like this in my view: for recipient in email_list: msg = EmailMultiAlternatives(email.subject, email.message_text, email.sender, [recipient]) msg.attach_alternative(email.message_html, 'text/html') msg.send() it seems to hang up the browser for quite a while with even just a few emails. What is the best way to do this and give the user confirmation that the email has been sent to everyone? Should I fork off a new process? If so, how can I be sure it finishes successfully? -- Pete --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: url.py
Marty...you de man!! On Dec 18, 1:20 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > It looks like you've configured the built-in admin at "/admin/", and > you're defining your custom URLs *later* in the list of URL patterns. > This means that the admin's URL configuration will see > "/admin/display/12/" and assume it's supposed to route to its view for > an app named "display" and a model named "12". This clearly doesn't > exist, which is why you're getting that error. > > You have three options: > * Change the URL you'd like "show_ticket" to use, so that it doesn't > start with "/admin/" > * Change the prefix you're using for the admin > * Move your "show_ticket" pattern *above* the admin configuration, so > that yours will be found before the admin's > > -Gul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: url.py
It looks like you've configured the built-in admin at "/admin/", and you're defining your custom URLs *later* in the list of URL patterns. This means that the admin's URL configuration will see "/admin/display/12/" and assume it's supposed to route to its view for an app named "display" and a model named "12". This clearly doesn't exist, which is why you're getting that error. You have three options: * Change the URL you'd like "show_ticket" to use, so that it doesn't start with "/admin/" * Change the prefix you're using for the admin * Move your "show_ticket" pattern *above* the admin configuration, so that yours will be found before the admin's -Gul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
completely escaping an included template
Hello everyone, trying to upgrade to the latest trunk, I'm wrestling a bit with the autoescape function. Talking about embed-code for an enduser, I used to write: {% include embedded_player.html %} Copy-paste this: The first part shows to the end-user how the embeddable player will look like, the second shows the user the code he can copy-paste. Now with autoembed this no longer works as "escape" doesn't exist anymore as a filter. Any ideas welcome :) cheers, - bram --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FileField and form.save()
Thanks a lot. Missed save_FOO_file in the docs. On Dec 18, 12:52 pm, "Marty Alchin" <[EMAIL PROTECTED]> wrote: > On Dec 18, 2007 12:08 PM, Ryan K <[EMAIL PROTECTED]> wrote: > > > def save(self, user): > > if user != self.scheduled_product.teacher: > > return False > > media = Media(name=self.cleaned_data['media'].filename, > > media=self.cleaned_data['media'].content, > > uploader=user, scope='STC', accessed=0, > > description=self.cleaned_data['description']) > > media.save() > > You don't pass in the contents of the file to the model's constructor > like this. Instead, you instantiate the object, *then* save the file. > Saving a file also saves the object, by default, so you can do it all > in one pass. Try something like this instead: > > def save(self, user): > if user!= self.schedule_product.teacher: > return False > media = Media(name=self.cleaned_data['media'].filename, > uploader=user, scope='STC', accessed=0, > description=self.cleaned_data['description']) > media.save_media_file(self.cleaned_data['media'].filename, > self.cleaned_data['media'].content) > > Here, media.save_media_file() will actually write the file where it > needs to go, update the model to reflect that location, and save the > record to the database, all at once. > > -Gul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
url.py
I am trying to get the url.py to display my template based on the 'id' of my model, but I cannot get this to work, any help would be appreciated. I have tried the url below and also my view is below, I would like to be able to visit /admin/display//id-number and see the ticket corresponding to that id. All i am getting is 'App not found' (r'^admin/display/$', show_ticket), (r'^admin/display/(\d{2})/$', show_ticket), (r'^admin/display/(?P\d+)/$', show_ticket), (r'^admin/display/(\d+)/$', show_ticket), (r'^admin/display/(\d+)/$', show_ticket), ) I have tried def show_ticket(request): return HttpResponse("You're looking at poll") and, #def show_ticket(request, id): # ticket = Ticket.objects.get(pk=id) # return render_to_response('ticket_all.html', {'ticket': ticket}) and, #from django.shortcuts import render_to_response, get_object_or_404 ## ... #def show_ticket(request, id): #p = get_object_or_404(Ticket, pk=id) #return render_to_response('ticket_all.html', {'ticket': p}) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Weird problem with request.POST, correct data not coming out from request.POST
On Dec 18, 7:14 pm, shabda <[EMAIL PROTECTED]> wrote: > I am trying to get a value from request.POST. After form submit, > request.POST contains the values of the ids from the checkbox > selected. I want the list of those ids. SO I am doing something like, > entry_ids = request.POST['delete'] , but this doesnot pick the list, > but instead gets me the last value in the list! See http://www.djangoproject.com/documentation/request_response/#querydict-objects. Regards, Jan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Weird problem with request.POST, correct data not coming out from request.POST
I am trying to get a value from request.POST. After form submit, request.POST contains the values of the ids from the checkbox selected. I want the list of those ids. SO I am doing something like, entry_ids = request.POST['delete'] , but this doesnot pick the list, but instead gets me the last value in the list! This is my code snippet. elif request.POST.has_key("del"): entry_ids = request.POST['delete'] print request.POST print entry_ids And this is the output. 9 What am I doing wrong? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem trying to configure Django with FastCGI and Lighttpd
Also, make sure you are using a recent release of flup (either the latest 0.5 update or the 1.0 release): http://cheeseshop.python.org/pypi/flup/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem trying to configure Django with FastCGI and Lighttpd
Hi, > Interesting, I've changed my fcgi script to prefork, and updated the > lighttpd conf to have the edternal IP address of the machine and now > I'm getting a 403 - Forbidden error when I go to the site URL. > I think one area of confusion (for me) is how and when to start > Django's fcgi process. You start it one of two ways: - Let lighttpd spawn it for you using the "bin-path" parameter. From your first post, this is what you were originally using. - Start the FCGI process manually or through a script that's independent of lighttpd. That's the "python manage.py runfcgi" command... > Currently what I'm doing is starting lighttpd (/etc/init.d/lighttpd > restatr) then starting Django's FCGI process as follows: > $ python manage.py runfcgi protocol=fcgi host=78.110.163.145 port=3303 You need to listen on host=127.0.0.1 since that's where your lighttpd.conf is sending FCGI requests. Also, since you don't need Lighttpd to spawn your FCGI process, in lighttpd.conf, remove the bin- path, max-procs, etc. and leave only the host, port, and check-local parameters. Since you're running your FCGI listener process on the same server as your lighttpd, you should communicate via the internal loopback IP address 127.0.0.1. -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FileField and form.save()
On Dec 18, 2007 12:08 PM, Ryan K <[EMAIL PROTECTED]> wrote: > def save(self, user): > if user != self.scheduled_product.teacher: > return False > media = Media(name=self.cleaned_data['media'].filename, > media=self.cleaned_data['media'].content, > uploader=user, scope='STC', accessed=0, > description=self.cleaned_data['description']) > media.save() You don't pass in the contents of the file to the model's constructor like this. Instead, you instantiate the object, *then* save the file. Saving a file also saves the object, by default, so you can do it all in one pass. Try something like this instead: def save(self, user): if user!= self.schedule_product.teacher: return False media = Media(name=self.cleaned_data['media'].filename, uploader=user, scope='STC', accessed=0, description=self.cleaned_data['description']) media.save_media_file(self.cleaned_data['media'].filename, self.cleaned_data['media'].content) Here, media.save_media_file() will actually write the file where it needs to go, update the model to reflect that location, and save the record to the database, all at once. -Gul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template text are not being escaped when used with textile
And is there some setting which allows markdown to convert linebreaks to for all line breaks? Askin users to add two spaces when they want a line break in comment seems strange to me. On Dec 18, 10:39 pm, shabda <[EMAIL PROTECTED]> wrote: > So should not {{text|escape|textile}} remove html tags first, and then > apply the textile-markup to generate html? > On your weblog, b-list, you allow comments in markdown, but strip > HTML, are you using something like "safe mode?" How can I enable that? > BTW, that site is acting a bit strange from some days, I can not see > the styling on some pages, :( . > > On Dec 18, 9:03 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > > > On Dec 18, 2007 8:56 AM, shabda <[EMAIL PROTECTED]> wrote: > > > > I am using textile markup filter. When I am using a variable in the > > > template without any filter they are being auto escaped, as they > > > should. However, if I use any markup filter like textile or markdown, > > > the text is not being auto escaped. Even using the escape filter > > > manually does not help. (as in {{comment.text|escape|markdown}} ). > > > Is there any combination of filters which can, > > > 1. Escape html tags. > > > 2. Apply textile/markdown? > > > The point of Textile/Markdown/etc. is to produce HTML, so the bundled > > filters do not escape their output (otherwise they'd escape the HTML > > they produce). > > > Your best bet is probably the Markdown filter, which allows you to > > enable python-markdown's "safe mode" -- this will have Markdown itself > > remove any "raw" HTML before doing Markdown processing. Note that > > *all* "raw" HTML which goes into Markdown with this mode enabled will > > be removed, regardless of whether you wanted it to be or not. > > > -- > > "Bureaucrat Conrad, you are technically correct -- the best kind of > > correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template text are not being escaped when used with textile
So should not {{text|escape|textile}} remove html tags first, and then apply the textile-markup to generate html? On your weblog, b-list, you allow comments in markdown, but strip HTML, are you using something like "safe mode?" How can I enable that? BTW, that site is acting a bit strange from some days, I can not see the styling on some pages, :( . On Dec 18, 9:03 pm, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Dec 18, 2007 8:56 AM, shabda <[EMAIL PROTECTED]> wrote: > > > I am using textile markup filter. When I am using a variable in the > > template without any filter they are being auto escaped, as they > > should. However, if I use any markup filter like textile or markdown, > > the text is not being auto escaped. Even using the escape filter > > manually does not help. (as in {{comment.text|escape|markdown}} ). > > Is there any combination of filters which can, > > 1. Escape html tags. > > 2. Apply textile/markdown? > > The point of Textile/Markdown/etc. is to produce HTML, so the bundled > filters do not escape their output (otherwise they'd escape the HTML > they produce). > > Your best bet is probably the Markdown filter, which allows you to > enable python-markdown's "safe mode" -- this will have Markdown itself > remove any "raw" HTML before doing Markdown processing. Note that > *all* "raw" HTML which goes into Markdown with this mode enabled will > be removed, regardless of whether you wanted it to be or not. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: FileField and form.save()
Just to make the question a little more clear: What type of object does model.FileType expect to get? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
FileField and form.save()
I am trying to allow certain users to upload media and then "attach" it via the contenttypes framework. The code posted below just puts the contents of the file in the media field. How do I make this work with the model.FileField? (putting it in the settings.MEDIA_ROOT+upload_to directory?) This is the code I have the following model: class Media(models.Model): SCOPE_CHOICES = ( ('PUB', 'Public'), ('ALL', 'All users'), ('TEA', 'All teachers'), ('STU', 'All students'), ('STC', 'Only Students in class'), ) name = models.CharField(max_length=96) media = models.FileField(upload_to='upload/%y/%m/%d') uploader = models.ForeignKey(User) scope = models.CharField(max_length=3, choices=SCOPE_CHOICES) accessed = models.PositiveIntegerField() description = models.TextField() and this form: class MediaUploadForm(forms.Form): media = forms.FileField() description = forms.CharField(max_length=1024, widget=forms.Textarea) sp_id = forms.CharField(max_length=32, widget=forms.HiddenInput) def clean_sp_id(self): sp_id = int(self.cleaned_data['sp_id']) try: self.scheduled_product = ScheduledProduct.objects.get(id=sp_id) except ObjectDoesNotExist: raise forms.ValidationError('Invalid scheduled product.') return self.cleaned_data['sp_id'] def save(self, user): if user != self.scheduled_product.teacher: return False media = Media(name=self.cleaned_data['media'].filename, media=self.cleaned_data['media'].content, uploader=user, scope='STC', accessed=0, description=self.cleaned_data['description']) media.save() content_type = ContentType.objects.get_for_model(ScheduledProduct) content_media = ContentMedia(content_type=content_type, object_id=self.scheduled_product.id, media=media) content_media.save() return True --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Templates, filesystem, caching?
On 12/18/07, Michael Elsdörfer <[EMAIL PROTECTED]> wrote: > James Bennett schrieb: > > Manually call get_template() or select_template(), and stuff the > > resulting Template object into a module-global variable somewhere. > > Then just re-use it, calling render() with different contexts, each > > time you need it. > > Is there anything speaking against building that behaviour directly into > Django? I was curious of the same thing. The only downside I see is that templates wouldn't "reload" automatically if you changed them. But you could disable this when DEBUG=True. And most people are used to the idea of reloading Apache if there is a change in a .py file. -Rob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How generate thumbail with png transparency
Hi, I'm using the thumbail field for autogenerate thumbails. I have my graphics in png with transparency. However, the transparency is not saved, I try: http://snippets.dzone.com/posts/show/1383 and def pngsave(im, file): # these can be automatically added to Image.info dict # they are not user-added metadata reserved = ('interlace', 'gamma', 'dpi', 'transparency', 'aspect') # undocumented class from PIL import PngImagePlugin meta = PngImagePlugin.PngInfo() # copy metadata into new object for k,v in im.info.iteritems(): if k in reserved: continue meta.add_text(k, v, 0) # and save im.save(file, "PNG", pnginfo=meta) But with not look. How do this trick with PIL? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Using CheckboxSelectMultiple
Try this: credentials = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=Truckshare.CREDENTIALS_CHOICES) On Dec 17, 9:14 pm, "Alex Ezell" <[EMAIL PROTECTED]> wrote: > I have several fields define in my models like this: > CREDENTIALS_CHOICES = ( > ('LM', "Commercial Driver's License"), > ('IN', 'Insured'), > ('DR', 'DOT Registered (Interstate)'), > ('FI', 'Fragile Item Qualified'), > ) > credentials = models.CharField(max_length=2, blank=True, > choices=CREDENTIALS_CHOICES) > > Then, I have them described in my form class as this: > > credentials = forms.ChoiceField(choices=Truckshare.CREDENTIALS_CHOICES) > > What I would like to do is use a CheckboxSelectMultiple for this field. > However, when I do that like this: > > credentials = forms.ChoiceField(choices=Truckshare.CREDENTIALS_CHOICES > ,widget=CheckboxSelectMultiple) > > but that will fail because it will submit multiple values to the model and > since it's ChoiceField, it will complain. > > How can I set this up so that I can use choices in my model and use a > CheckboxSelectMultiple field via newforms? > > Thanks! > > /alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Simple Database Import Memory Problems
That indeed did the trick. I new it would be something embarrassingly simple. Thank you very much, James. Much obliged. -Alex. On Dec 18, 11:06 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Dec 18, 2007 9:57 AM, [EMAIL PROTECTED] > > <[EMAIL PROTECTED]> wrote: > > That's really all it does. If you watch it in top, however, python's > > memory consumption rises steadily as the file is processed (f is very > > large, so there are many iterations of the loop). I was wondering if > > anyone knew where all this memory was going? Is django spawning > > objects under the hood somewhere that I need to explicitly delete? > > Forgive me if this is a too-simple question, but I have been unable to > > figure it out thus far. > > You have DEBUG=True in your settings file, which means that, for > debugging purposes, Django is keeping an in-memory list of database > queries it has performed. This list naturally grows in size with each > successive query. To disable this, set DEBUG=False. > > -- > "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Simple Database Import Memory Problems
On Dec 18, 2007 9:57 AM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > That's really all it does. If you watch it in top, however, python's > memory consumption rises steadily as the file is processed (f is very > large, so there are many iterations of the loop). I was wondering if > anyone knew where all this memory was going? Is django spawning > objects under the hood somewhere that I need to explicitly delete? > Forgive me if this is a too-simple question, but I have been unable to > figure it out thus far. You have DEBUG=True in your settings file, which means that, for debugging purposes, Django is keeping an in-memory list of database queries it has performed. This list naturally grows in size with each successive query. To disable this, set DEBUG=False. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Template text are not being escaped when used with textile
On Dec 18, 2007 8:56 AM, shabda <[EMAIL PROTECTED]> wrote: > I am using textile markup filter. When I am using a variable in the > template without any filter they are being auto escaped, as they > should. However, if I use any markup filter like textile or markdown, > the text is not being auto escaped. Even using the escape filter > manually does not help. (as in {{comment.text|escape|markdown}} ). > Is there any combination of filters which can, > 1. Escape html tags. > 2. Apply textile/markdown? The point of Textile/Markdown/etc. is to produce HTML, so the bundled filters do not escape their output (otherwise they'd escape the HTML they produce). Your best bet is probably the Markdown filter, which allows you to enable python-markdown's "safe mode" -- this will have Markdown itself remove any "raw" HTML before doing Markdown processing. Note that *all* "raw" HTML which goes into Markdown with this mode enabled will be removed, regardless of whether you wanted it to be or not. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Simple Database Import Memory Problems
Hi, I was hoping I could cajole someone into helping me out. I've created a test project that essentially reads records from a large flat file, assigns the contents of each line in said file to a pair of models, and saves the model (that's really all it does). The code reads something like this: = def asl_import(): from asl.models import Model1 as A from asl.models import Model2 as P f = open_as_list('data/A.full', 'r') while f.readline(): p = P() a = A() #assign model attributes to the appropriate p.first = f[0] p.second = f[1] ... p.last = f[n] a.first = f[n+1] a.second = f[n+2] ... a.last = f[m] p.save() a.save() p.a.add(a) #there is a many-to-many between p and a del(p) #I know I shouldn't have to explicitly delete these, but I did this in order to del(a) #try to resolve the memory problems = That's really all it does. If you watch it in top, however, python's memory consumption rises steadily as the file is processed (f is very large, so there are many iterations of the loop). I was wondering if anyone knew where all this memory was going? Is django spawning objects under the hood somewhere that I need to explicitly delete? Forgive me if this is a too-simple question, but I have been unable to figure it out thus far. -Alex --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
User behaviour: Rating + Comments or Rating OR comments?
I'm debating myself what could be best for the upcoming redesing of www.paradondevamos.com in the area of rating & comments. I know the comments framework have both, but I wonder for a site with blogs & places related to enterteinment for 16-30 years old people what could provide the best return (ie: enchance participation): - Let rating & comment in one step or - Comment & rating apart. I think is best the second, maybe because people that hate writing perhaps could rate. In the other hand, if simply rate but not say why, the content get less valuable What do you think? Exist any emprirical proof? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Choices from table vs. Foreign Key relationship.
On Dec 17, 2007 7:05 PM, radioflyer <[EMAIL PROTECTED]> wrote: > I have a Student model with a Foreign Key relationship to Teacher. > When a teacher is removed, so go the students. Too dangerous for my > particular scenario. There doesn't seem to be a Django feature that > allows for adjusting the cascade. Personally, I'd keep the ForeignKey relationship, but just override Teacher.delete() so that removes itself from all of its Students before being deleted. Something like this should do it: class Teacher(models.Model): # ... Fields here def delete(self): for student in self.student_set.all(): student.teacher = None student.save() super(Teacher, self).delete() This, of course, assumes that you created your students include a field looking something like this: teacher = ForeignKey(Teacher, null=True) Would that work for you? -Gul --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Template text are not being escaped when used with textile
I am using textile markup filter. When I am using a variable in the template without any filter they are being auto escaped, as they should. However, if I use any markup filter like textile or markdown, the text is not being auto escaped. Even using the escape filter manually does not help. (as in {{comment.text|escape|markdown}} ). Is there any combination of filters which can, 1. Escape html tags. 2. Apply textile/markdown? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Templates, filesystem, caching?
James Bennett schrieb: > Manually call get_template() or select_template(), and stuff the > resulting Template object into a module-global variable somewhere. > Then just re-use it, calling render() with different contexts, each > time you need it. Is there anything speaking against building that behaviour directly into Django? Michael --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to get the urls defined in urls.py
On Dec 18, 9:10 am, shabda <[EMAIL PROTECTED]> wrote: > I have my urls.py defined as > urlpatterns = patterns('app.views', > (r'^foo/$', 'foo'), > (r'^bar/$', 'bar'),) > > Now from a template i need to access these urls. So inside the > template we can refer them as /foo/, /bar/. However later when I > change the urls.py, these urls defined in urls.py would break. What > would be a good way around this? You can name your URL patterns and then use the "url" templatetag in your templates. Start here: http://www.djangoproject.com/documentation/url_dispatch/#naming-url-patterns and follow on to the "url" templatetag description. -Rajesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Are paginators lazy?
Paginator is lazy. It loads only needed page. It uses slice syntax( [:] ) of query set On 18 дек, 16:26, shabda <[EMAIL PROTECTED]> wrote: > I am using the paginators(django.core.paginator) as describes > athttp://www.djangoproject.com/documentation/models/pagination/. > Are paginators lazy, like .filter and related method are? If I use > paginator = ObjectPaginator(Article.objects.all(), 5) > and then paginator.get_page(0) > would the first 5 pages be loaded or all of the objects returned > by .all be loaded? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: How to get the urls defined in urls.py
On Dec 18, 2007 8:10 AM, shabda <[EMAIL PROTECTED]> wrote: > Now from a template i need to access these urls. So inside the > template we can refer them as /foo/, /bar/. However later when I > change the urls.py, these urls defined in urls.py would break. What > would be a good way around this? You most likely want to look at the documentation on Django's built-in template tags. -- "Bureaucrat Conrad, you are technically correct -- the best kind of correct." --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to get the urls defined in urls.py
I have my urls.py defined as urlpatterns = patterns('app.views', (r'^foo/$', 'foo'), (r'^bar/$', 'bar'),) Now from a template i need to access these urls. So inside the template we can refer them as /foo/, /bar/. However later when I change the urls.py, these urls defined in urls.py would break. What would be a good way around this? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Are paginators lazy?
I am using the paginators(django.core.paginator) as describes at http://www.djangoproject.com/documentation/models/pagination/ . Are paginators lazy, like .filter and related method are? If I use paginator = ObjectPaginator(Article.objects.all(), 5) and then paginator.get_page(0) would the first 5 pages be loaded or all of the objects returned by .all be loaded? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
get to named url pattern from request.path
hello, in a contextprocessor i am writing, i would like to use the "named url" of the current view instead of request.path. I toyd with django.core.urlresolvers.resolve() but that just returns the function configured in urls.py and not the name it was configured with to give an example: my urls.py contains this pattern urlpatterns += patterns('mcc.log.status', url(r'ftpqueue/$', 'ftpqueue', name='mcc-ftpqueue'), ) in my contextprocessor, request.path is '/ftpqueue/' now I want to get to the name: 'mcc-ftpqueue' how to do that? thanks for any insight you might have -frank --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
FREE Web Hosting...
Http://host.2freedom.com/ 250 MB of Disk Space 100 GB Bandwidth! Full Domain Hosting cPanel Powered Hosting Host unlimited domains! Over 500 website templates Free POP3 Email Box Enjoy unrestricted POP3 email Full Webmail access FTP and Web based File Manager access PHP, MySQL, Perl, CGI, Ruby. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Choices from table vs. Foreign Key relationship.
radioflyer wrote: > So the recommendation seems to be when your selection choices are not > static you should go ahead and use a Foreign Key relationship. You get > the automatic loading of the table into a select widget etc. > > But there's this issue of the cascade on delete. > > I have a Student model with a Foreign Key relationship to Teacher. > When a teacher is removed, so go the students. Too dangerous for my > particular scenario. There doesn't seem to be a Django feature that > allows for adjusting the cascade. > > I thought to uncouple the relationship and use the Teacher model > strictly as a 'lookup table.' > > What are best practices on this? What will I be losing if I just load > the teachers as 'choices' on the student forms? Is it worth creating > my own cascade protection to keep the Foreign Key relationship? Don't delete the Teacher. Instead, I would add a boolean field 'active' to the model and change the value on delete. -- Christian Joergensen | Linux, programming or web consultancy http://www.razor.dk | Visit us at: http://www.gmta.info --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Bio Technology seacrat
Bio Technology seacrat http://vigaragirls.blogspot.com/ Bio Technology seacrat http://prasoga.blogspot.com/ Bio Technology seacrat --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem trying to configure Django with FastCGI and Lighttpd
Interesting, I've changed my fcgi script to prefork, and updated the lighttpd conf to have the edternal IP address of the machine and now I'm getting a 403 - Forbidden error when I go to the site URL. I think one area of confusion (for me) is how and when to start Django's fcgi process. Currently what I'm doing is starting lighttpd (/etc/init.d/lighttpd restatr) then starting Django's FCGI process as follows: $ python manage.py runfcgi protocol=fcgi host=78.110.163.145 port=3303 Am I doing something wrong? On Dec 17, 9:00 pm, "Chris Moffitt" <[EMAIL PROTECTED]> wrote: > In your mysite.fcgi script, just pass in the variable "prefork" instead of > threaded. > > The other thing you could try is to use the ip address instead of 127.0.0.1. > > -Chris --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Hi to ALL. I just join this group.
Greetings to all http://erleroy.tripod.com/japanese-anime-lesbian-sex.html japanese anime lesbian sex http://erleroy.tripod.com/japanese-anime-art.html japanese anime art http://erleroy.tripod.com/anime-japanese-robot-toys.html anime japanese robot toys http://erleroy.tripod.com/japanese-school-girl-anime-sex.html japanese school girl anime sex http://erleroy.tripod.com/japanese-anime-mp3-mp3.html japanese anime mp3 mp3 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Performance of a django website
have you tried mod_wsgi ? Nic пишет: > "Karen Tracey" <[EMAIL PROTECTED]> writes: > >> On Dec 11, 2007 1:49 PM, Richard Coleman <[EMAIL PROTECTED]> wrote: >> >>> 1. Static content and dynamic are on the same server (that will change >>> on production). But they are on different apache virtual. Mod_python >>> is turned off for the static stuff. Hitting only a static page is very >>> fast (6500 requests per second). Hitting the dynamic side is slow (300 >>> requests per second). >>> >>> 2. It's gigE between the web server and mysql server, on a dedicated >>> switch. The database is working pretty hard (7000 selects per second), >>> but doesn't seem to be the bottleneck. The webserver is hammered >>> (typing any command takes a long time). >>> >> DB handling 7000 selects/sec while web server is serving 300 pages/sec >> implies each page request is generating >20 select requests. Does that seem >> reasonable to you based on the content of the page you are serving? (It >> seems high to me.) Brian Morton provided a pointer to the doc for >> select_related, which could help to reduce the number of selects. Even if >> the database is keeping up, so many round-trips talking to it for a single >> page request is going to add up. > > > Have you tried a connection pool? > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Returning a Queryset
Hey guys Is there a way to return a QuerySet object, when I make my own custom sql? Stephane --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---