Re: cherokee + uwsgi + django configuration
Hello, I have done several post on my blogs about how to setup django projects using cherokee and uWSGI : http://yml-blog.blogspot.com/search/label/uWSGI The first 2 are the most interesting for you : * http://yml-blog.blogspot.com/2009/11/how-to-set-up-cherokee-and-uwsgi.html * http://yml-blog.blogspot.com/2009/11/setting-up-django-project-with-cherokee.html another great resources are the cherokee documentation : * http://www.cherokee-project.com/doc/cookbook_uwsgi.html If you are more a visual person you can also look at this screencast : * http://www.cherokee-project.com/screencasts.html#django_uwsgi Regards, --yml On Dec 25 2009, 12:28 am, LarryEitel <larrywei...@gmail.com> wrote: > I am trying to get my little django hello world example site working > based on cherokee + uwsgi + django config. > I want to add detailed instructions to my How-to-Guide. Can you see > how/where to make adjustments? > > I if have a url ofwww.example.comand the following directory > structure: > /var/www/example/ > /var/www/example/static/ > /var/www/example/__init__.py > /var/www/example/manage.py > /var/www/example/url.py > > /var/www/example/settings.py > MEDIA_ROOT = '/var/www/example/static/' > MEDIA_URL = 'http://djdev.xchg.com/static/' > > /var/www/example/uwsgi.conf > > /var/www/example > -- > django_wsgi > > > > /var/www/example/django_wsgi.py > import os > import django.core.handlers.wsgi > os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' > application = django.core.handlers.wsgi.WSGIHandler() > > In the Cherokee admin are the following main parameters: > Virtual Servers > > BASICS: > Virtual Server nickname:www.example.com;Document Root: /var/www/ > example; Directory Indexes: ??? > > BEHAVIOR: > Target: /var/www/example; Type: Directory; Handler: uWSGI > > > I have tried to follow available documentation and user examples but > none give me a simple configuration for a simple 'Hello World' Django > app. > > PLEASE share your insights and I will document step-by-step the > required configuration so others can actually use these tools. > Thank you :) -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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: Internationalization in django and search engine indexing
This is the motivation for me to write this piece of middleware : http://yml-blog.blogspot.com/search/label/Internationalisation --yml On Jun 22, 5:52 pm, Olivier <o.mic...@gmail.com> wrote: > Hello everyone, > > I'm currently using django localization on my site to manage both > english and french. I'm using template tags blocktrans and block but > both the french & english pages have the same url. I'm wondering if > the search engines can work with this configuration and index the two > versions or should I use different url ? > > I first tried to find if the question was already solved in a > different topic but I didn't see it, sorry if I'm wrong. >l > Thanks in advance, > > Olivier --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: i18n: How to the language on per-user basis
Hello, Sometimes ago I try to solve a similar problem, it seems to me that the solution to your problem is to write a middleware. You will find an example there : http://yml-blog.blogspot.com/search/label/Django ---8< from django.utils.cache import patch_vary_headers from django.utils import translation class MultilingualURLMiddleware: def get_language_from_request (self,request): # This is the place where you should write # the logic to find the right language lang = user.language # <= May be something like return lang def process_request(self, request): from django.conf import settings language = self.get_language_from_request(request) if language is None: language = settings.LANGUAGE_CODE[:2] translation.activate(language) request.LANGUAGE_CODE = translation.get_language() def process_response(self, request, response): patch_vary_headers(response, ("Accept-Language",)) translation.deactivate() return response --8<-- I hope that help. --yml On Jul 18, 2:01 pm, "Rishabh Manocha" <[EMAIL PROTECTED]> wrote: > You could use "user profiles" which will allow you to store various user > specific preferences. See [1] to learn how to do this. > > I am currently using profiles to identify users by the department they work > in and the last time they edited a form (this is different from last login). > > Best, > > R > > [1] -http://www.djangoproject.com/documentation/authentication/#storing-ad... > > On Thu, Jul 17, 2008 at 6:32 PM, Torsten Bronger < > > [EMAIL PROTECTED]> wrote: > > > Hallöchen! > > > In my Web application, every user has to log in. In an additional > > user database table, the prefered language of each user is given. > > But how do I activate it? > > > I use django.contrib.auth.views.login for the login. However, as > > far as I can see, I have to copy-and-paste this function and add a > > line to it which stors the language in the current session. Am I > > right? > > > Tschö, > > Torsten. > > > -- > > Torsten Bronger, aquisgrana, europa vetus > > Jabber ID: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 sort in django template
Hello, I would see 2 approach to solve the problem you are describing : * Server side - Order the list of employees in your view before passing it to the template * Client side - use a JS to order a Javascript variable I hope this will help you. --yml On 18 juin, 09:53, laspal <[EMAIL PROTECTED]> wrote: > hi, > I have a list of employee and i want to sort it. > > Employee ( this is my header) > under which i have list of employee. > > So now my question is on clicking employee header I want to change the > list. > Like it happens for user in django admin. > > Please help me out. > > Thannks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 Admin Model View Page
Hello, I would recommend you to look at : databrowse http://www.djangoproject.com/documentation/databrowse/ Here it is a short description extracted from the django documentation: """ Databrowse is a Django application that lets you browse your data. As the Django admin dynamically creates an admin interface by introspecting your models, Databrowse dynamically creates a rich, browsable Web site by introspecting your models. """ I hope that will help you. --yml On 4 juin, 11:52, Ali Sogukpinar <[EMAIL PROTECTED]> wrote: > Hi, > > I have an website and I would like to use Django admin app for > modifing my model objects. > > Django admin app is out of the box providing C(R)UD actions for me. > But R (Read) action is implemented as list. You can see the list of > your objects and If you click on one the item in the list you will be > automaticall directed to change_form (Update action) > > I would like to have an intermediate step where you see the details of > the object with its relations etc. and from this page you can goto > change_form if you really want to edit it. > > Couldn't make it? Did any of you implemented such a functionality? > > Thanks in Advance. > > Ali --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: newforms
Hello, Here it is some documentation : * http://www.djangobook.com/en/1.0/chapter07/ * http://www.djangoproject.com/documentation/newforms/ The short answer to your question is the switch is done inside the views.py. You will make at least 2 cases there one if the "method" is "POST" and an other cases if it is not "POST. This will look to somthing like this : """ def contact(request): if request.method == 'POST': form = ContactForm(request.POST) if form.is_valid(): # Do form processing here... return HttpResponseRedirect('/url/on_success/') else: form = ContactForm() return render_to_response('contact.html', {'form': form}) """ Of course you will need to fill the blank with your own business logic. I hope that will help you. --yml On 2 juin, 16:38, Bobby Roberts <[EMAIL PROTECTED]> wrote: > hi all. I'm new to python and Django but have extensive experience on > the microsoft side of things. I am liking what I see so far with this > platform. forms/newforms seems confusing to me and I need some help > tying everything together. > > I have a simple one field form built in my forms.py and the template > is designed to show the form as well. However, with a form action of > "." in the template, how in the world does Django know what to do? > > Is there any more indepth documentation for django other than > djangobook? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 and i18n
hello, I have been using this recipe for some times : http://yml-blog.blogspot.com/search/label/Internationalisation It seems to exactly answer your requirements. I hope that helps. --yml On May 30, 6:09 pm, Taevin <[EMAIL PROTECTED]> wrote: > I've been working with translation in Django and it mostly works but > I'm wondering if there is a 'cleaner' way of doing things. That is, > here is what I seem to have to do to get a page translated into the > correct language: > > URLs are of the form $domain/$language_code/$page > (e.g.www.example.com/en/index > orwww.example.com/fr/index). > > 1. Look for a language code in the URL. > 2. Check the user's session for an existing django_language setting. > 3. Compare the two (and include edge cases for None with either). > 3.a. If equal, language is the same, just display the page. > 3.b. If not equal, set the django_language setting to the language > code from the URL and then redirect the page to the same URL (this is > the part that I'm wanting to fix). > > In other words, is there a way to immediately set the translation > language for the output without a page refresh? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: generic delete_object issue on Firefox (redirect bug)
Hello Koenb, Thank you very much your workaround is working like a charm. I have pasted below an example. In case someone else look for a solution to this problem in the future. However this is close to witchcraft art. I do not understand how FF can be aware that I am doing something in my view with request.POST or not. Does anyone has a rational explanation on why this work? ---8<--- @login_required() def survey_delete(request,slug): # TRICK: The following line does not have any logical explination # except than working around a bug in FF. It has been suggested there # http://groups.google.com/group/django-users/browse_thread/thread/e6c96ab0538a544e/0e01cdda3668dfce#0e01cdda3668dfce request_post = request.POST.copy() return delete_object(request, slug=slug, **{"model":Survey, "post_delete_redirect": "/survey/editable/", "template_object_name":"survey", "login_required": True, 'extra_context': {'title': _('Delete survey')} }) --->8--- Thank you --yml On Apr 28, 10:42 pm, koenb <[EMAIL PROTECTED]> wrote: > The problem is FF does not like it if you do not consume the POST > data. > Just add the line > request.POST > somewhere in your view before redirecting. > > Koen > > On 28 apr, 17:33, yml <[EMAIL PROTECTED]> wrote: > > > Hello, > > I noticed a very strange behavior with the generic view called : > > "delete_object". The symptom is the following : > > * Firefox return an error message > > ---8<--- > > The connection was reset > > > The connection to the server was reset while the page was loading. > > > * The site could be temporarily unavailable or too busy. Try > > again in a few > > moments. > > > * If you are unable to load any pages, check your computer's > > network > > connection. > > > * If your computer or network is protected by a firewall or > > proxy, make sure > > that Firefox is permitted to access the Web. > > --->8--- > > It seems that the bug is in Firefox code. The same code is working > > fine on IE 6.0 and Opéra, I am testing this on windows. > > > My code look like this (extracted form urls.py): > > ---8<--- > > url(r'^delete/(?P[-\w]+)/$', delete_object, > > {"model":Survey, > > "post_delete_redirect": "/survey/editable/", > > "template_object_name":"survey", > > "login_required": True, > > 'extra_context': {'title': _('Delete survey')} > > }, > > name='survey-delete'), > > --->8--- > > It would be nice if someone could help me with a workaround or a > > solution. > > > Should I report issues in the django bug tracker ? > > Thank you for your help. > > --yml --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
generic delete_object issue on Firefox (redirect bug)
Hello, I noticed a very strange behavior with the generic view called : "delete_object". The symptom is the following : * Firefox return an error message ---8<--- The connection was reset The connection to the server was reset while the page was loading. * The site could be temporarily unavailable or too busy. Try again in a few moments. * If you are unable to load any pages, check your computer's network connection. * If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web. --->8--- It seems that the bug is in Firefox code. The same code is working fine on IE 6.0 and Opéra, I am testing this on windows. My code look like this (extracted form urls.py): ---8<--- url(r'^delete/(?P[-\w]+)/$', delete_object, {"model":Survey, "post_delete_redirect": "/survey/editable/", "template_object_name":"survey", "login_required": True, 'extra_context': {'title': _('Delete survey')} }, name='survey-delete'), --->8--- It would be nice if someone could help me with a workaround or a solution. Should I report issues in the django bug tracker ? Thank you for your help. --yml --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Can I make it so that I get an error if a template accesses something that does not exist?
hello, Here it is what you are looking for : """ If you use a variable that doesn’t exist, the template system will insert the value of the TEMPLATE_STRING_IF_INVALID setting, which is set to '' (the empty string) by default """ It is extracted from the documentation. --yml On Apr 18, 6:23 pm, Salim Fadhley <[EMAIL PROTECTED]> wrote: > I have some templates which attempt to access non-existent attributes > of the context. > > For example supposing the template references {{ foo }} but foo does > not exist - can I force djgango to throw an error? > > Thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Can I print out the context from within a template?
Hello, Here it is an extract form the documentation : """ If you use a variable that doesn’t exist, the template system will insert the value of the TEMPLATE_STRING_IF_INVALID setting, which is set to '' (the empty string) by default """ It looks like it does what you want. --yml On Apr 18, 8:34 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > You could write a simple template tag that did this. > > On Apr 18, 12:26 pm, Salim Fadhley <[EMAIL PROTECTED]> wrote: > > > I'm trying to debug the context that is passed into the template. When > > I render the template I use a command like: > > > return HttpResponse( render_to_string('mtmreport/index.html'), > > myContext ) > > > Is it possible to write something in the template that simply prints > > out the myContext object? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: More Advanced Forms Help
Hello, Your particular situation look to me very similar to the Poll, Choice sample presented on this blog : http://collingrady.wordpress.com/2008/02/18/editing-multiple-objects-in-django-with-newforms/ I hope this will help you. --yml On Apr 6, 2:29 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote: > Thanks to all who made suggestions before. Now I have another problem I > have been unable to find a way to solve in Django. Here's the scenario: > I have the variable games, which contains (oddly enough) games > I have the variable stadium_forms, which contains a form for each game that > displays a check box > > I want to do something like this > > {% for game in games %} > (display info about game) > (display form in stadium_forms that belongs to the game) > {% endfor %} > > For every item in 'games' there is a corresponding item in 'stadium_forms' > > I found this page to be helpful in figuring out how to build the > stadium_forms variable: > > http://www.pointy-stick.com/blog/2008/01/06/django-tip-complex-forms/ > > Any tips on how to make this work would be greatly appreciated. > > -- > Chris Hartjes --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Fixture? Testing? how do you do it?
As far as I can remember the file containing the tests should be called : "tests.py" --yml On Apr 2, 9:01 pm, Tony <[EMAIL PROTECTED]> wrote: > Ah, that makes it alot clearer. > > I've had a go at it but I can't seem to get it to run my test.py file. > Any reason why that might be? > > Thanks for your help. > > On Apr 1, 6:17 pm, Prairie Dogg <[EMAIL PROTECTED]> wrote: > > > I just did this for the first time last night, although I definitely > > don't > > know how to write good tests, at least I wrote some tests. > > > First thing you'll wanna check out if you haven't is: > > >http://www.djangoproject.com/documentation/testing/ > > > But I assume you have, so I'll just get on to the fixtures. > > > Probably the easiest way to create a fixture is to enter some data > > into your site from the admin interface. Then go to your project > > folder (the one with manage.py in it) and type something like: > > > $>python manage.py dumpdata --indent=4 --format=json > > > my_text_fixture.json > > > Both the --indent and --format flags are optional, I think the output > > is JSON by default. For more information on dumping data into a > > fixture, check out: > > >http://www.djangoproject.com/documentation/django-admin/#dumpdata-app... > > > Then, when you write your unit tests for your app in tests.py, you > > simply load up that fixture at the beginning of each test case. The > > docs say that the test database is flushed and restored for each > > individual test case. Here's what one of my test cases looks like: > > > class FormatTestCase(TestCase): > > fixtures = ['book/test_data/book_test_data.json'] > > > def setUp(self): > > self.haiku = Submission.objects.get(title="A Peaceful Haiku") > > > def testPermalink(self): > > self.assertEquals(self.haiku.get_absolute_url(), "/submission/ > > peaceful-haiku/") > > > Hope that helps. Obviously, this only works for unit tests. I'm not > > entirely sure how you load fixtures for doctests, maybe someone more > > experienced would like to tackle that. > > > On Apr 1, 12:31 pm, Tony <[EMAIL PROTECTED]> wrote: > > > > I am relatively new to Django, and I am having trouble getting my head > > > around fixtures. > > > The Django documentation just assumes that you should know what a > > > test fixture is and how to write one. I understand that fixtures are > > > just test data, but how is one written? > > > > Any guidance/examples on this would be great. > > > > Thanks, > > > Tony --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
django-survey Extracted from PyCon
Hello, Last week I have discovered that some of the apps composing PyCon backend [2] have been exposed on "code.google.com". I am especially interested by "django-survey" [1] since I have been working recently on something similar [3]. I like how the survey from is built using the newforms. I have been myself unable to do it and this even with the several posts done around newforms. :-( I found two roadblocks on my way to do this. The first one is to be able to present the choices with different widgets : * Radio List * Checkbox List * Combobox * ... And the second is to be able to change the layout of each widget. For example I would like to be able to display the Radio List horizontally and vertically. The project actually available there [2] partially solved the first issue but not the second. I try this afternoon to extend the foms.py [4] to add ChoiceCheckbox : """ class ChoiceCheckbox(ChoiceAnswer): def __init__(self, *args, **kwdargs): super(ChoiceCheckbox, self).__init__(*args, **kwdargs) self.fields['answer'].widget = CheckboxSelectMultiple(choices=self.choices) """ Then I have also edited a tuple and a dictionary to enable this new type of question. And : "oh surprise !!" I can now add this type of question in the admin interface. The survey with this type of question is nicely rendered but I am unable to submit it succesfully . I am getting this error message : """ Select a valid choice. That choice is not one of the available choices. """ I hope that one of the core developers of "django-survey" is reading this list. Please do not hesitate to let me know if there is a more appropriate channel to discuss about django-survey. --yml [1] http://code.google.com/p/django-survey/ [2] https://pycon.coderanger.net/ [3] https://launchpad.net/django-survey [4] http://code.google.com/p/django-survey/source/browse/trunk/survey/forms.py --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
django-survey Extracted from PyCon
Hello, Last week I have discovered that some of the apps composing PyCon backend [2] have been exposed on "code.google.com". I am especially interested by "django-survey" [1] since I have been working recently on something similar [3]. I like how the survey from is built using the newforms. I have been myself unable to do it and this even with the several posts done around newforms. :-( I found two roadblocks on my way to do this. The first one is to be able to present the choices with different widgets : * Radio List * Checkbox List * Combobox * ... And the second is to be able to change the layout of each widget. For example I would like to be able to display the Radio List horizontally and vertically. The project actually available there [2] partially solved the first issue but not the second. I try this afternoon to extend the foms.py [4] to add ChoiceCheckbox : """ class ChoiceCheckbox(ChoiceAnswer): def __init__(self, *args, **kwdargs): super(ChoiceCheckbox, self).__init__(*args, **kwdargs) self.fields['answer'].widget = CheckboxSelectMultiple(choices=self.choices) """ Then I have also edited a tuple and a dictionary to enable this new type of question. And : "oh surprise !!" I can now add this type of question in the admin interface. The survey with this type of question is nicely rendered but I am unable to submit it succesfully . I am getting this error message : """ Select a valid choice. That choice is not one of the available choices. """ I hope that one of the core developers of "django-survey" is reading this list. Please do not hesitate to let me know if there is a more appropriate channel to discuss about django-survey. --yml [1] http://code.google.com/p/django-survey/ [2] https://pycon.coderanger.net/ [3] https://launchpad.net/django-survey [4] http://code.google.com/p/django-survey/source/browse/trunk/survey/forms.py --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 return Admin to previous filters after save?
Not a solution but a workaround. I had exactly the same problem as a user, I solved it by bookmarking the right url. --yml On 14 fév, 03:50, cyberjack <[EMAIL PROTECTED]> wrote: > I have an admin interface managing a few thousand records. Finding a > record requires heavy use of multiple list_filter selections. However, > once a user edits a record, the admin interface redirects to the root > admin URL and loses the filter state. > > Is there an easy way to have the admin editor return to the calling > URL after a form submit? > > Ie, I'd like the Admin tool to redirect to >/admin/foo/?is_active__exact=0__exact=A__exact=B > instead of > /admin/foo/? > > Thanks, > > -Josh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: What are the advantages of using Django for building things like blogs and CMS?
Hello, I would also add this list of resources: - http://www.djangosites.org/with-source/ Chance are good that someone has already solved your problem. --yml On 14 fév, 01:58, Doug B <[EMAIL PROTECTED]> wrote: > > Basically I'm looking for some users to placate my fear that I'll run > > into insurmountable problems down the road and I'll end up kicking > > myself for not going with a CMS or blog system because the problems > > could have been trivially addressed with those systems. > > It all depends on your needs, if they can all be provided out of the > box by a cms and a few plugins than I don't see any big advantage to > doing in yourself with django or any other framework. On the other > hand if you do need more than they can easily provide Django is a > great alternative. It's not a kitchen sink type framework though, so > you may have to hunt several places to solutions for some of the > common tasks. > > A few of good ones: > > www.djangosnippets.org(awesome site, 10x more so if there were a > search or you could browse tags by first letter rather than next, > next, next...) > > http://www.b-list.org/weblog/categories/django/ > > http://code.djangoproject.com/wiki/DjangoResources (I used django for > months and reinvented a wheel or two before finding this page. I guess > I'm blind) > > Having spent the last few days making a wordpress plugin to integrate > with our django powered site I'm reminded how much nicer to deal with > python is than php. That alone is a big 'feature' django has over > Wordpress and Joomla. I've never regretted choosing Django. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Replicating admin behavior in front end
Hello, If I am understanding your requirement correctly you are looking for databrowse. Here it is what the documentation says about it: """ Databrowse is a Django application that lets you browse your data. As the Django admin dynamically creates an admin interface by introspecting your models, Databrowse dynamically creates a rich, browsable Web site by introspecting your models. """ You will find the documentation there: http://www.djangoproject.com/documentation/databrowse/ On 4 jan, 03:14, Rodrigo Culagovski <[EMAIL PROTECTED]> wrote: > I am making a site that will handle and display a magazine article > database. I would like for front end (anonymous, not logged in) users > to be able to use some of the same functionality the admin interface > offers, namely the ability to sort by column (and reverse the order), > and filter by year, publication, etc. > Ideally, it should be as easy as adding the 'Admin' subclass is to a > class in models.py: > > class Admin: > list_display = ('titulo', 'revista', 'ano','visible') > list_filter = ('revista', 'pais','categoria','ano') > ordering = ('-ano',) > search_fields = ('titulo','autores','revista') > date_hierarchy = 'fecha_modificacion' > save_on_top = True > > Basically, I wonder if there's some read-only, public version of the > admin interface. > > Thanks, > > Rodrigo --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: i18n/setlang no longer support GET
Hello, I wrote an my blog about the solution I have chosen perform what is describes. To put it in a nutshell I am using a middleware to direct the user to the language requested in the URL. I am not sure this follow any "Best Practice": http://yml-blog.blogspot.com/2007/12/django-internationalisation.html May be this could help you. --yml On 20 déc, 00:32, "James Bennett" <[EMAIL PROTECTED]> wrote: > On Dec 19, 2007 12:59 PM, Poromenos <[EMAIL PROTECTED]> wrote: > > > My application's UI depends on the set_language view being a link, and > > I don't think it should be up to the framework to force this on the > > developer. It would be better if the view supported both ways and the > > developer could choose whether they wanted functionality or spec > > compliance. This isn't a simple change, and it shouldn't be decided > > just like that... > > So write your own view which uses GET. Django encourages best > practices, and that includes following the recommendations of the HTTP > specification. You are free to throw down and trample the spec as much > as you like in your own code, but don't expect Django to help you with > it. > > -- > "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: get_absolute_url not working as expected
Hello, This exact situation happens to me sometimes ago and the root cause is that either you have an error in your urls.py or you are using the decorator "user_passes_test". In order to solve the first one you should comments all the lines in urls.py and uncomment line after line. This is the the method I have used so far. If someone have a better one I would be happy to read it. Regarding the second issue comment the line with the decorator, more details on that pb can be found there: * http://code.djangoproject.com/ticket/5925 I hope that help On 15 déc, 12:30, Florian Lindner <[EMAIL PROTECTED]> wrote: > Am 15.12.2007 um 05:03 schrieb Alex Koshelev: > > > > > 1) May be string is needed > > As I said, even when I return a constant string (return "foo") it > changing nothing. > > > > > 2) Absolute url not uri. So domain name is not needed. > > > On 15 дек, 01:29, Florian Lindner <[EMAIL PROTECTED]> wrote: > >> Hello, > >> I have two question regarding get_absolute_url: > > >> 1) I have the template code: > > >> {% for entry in object_list %} > >> {{ entry.title }} >> h3> > >> {% endfor %} > > >> It's called from a .generic.list_detail.object_list. My > >> get_absolute_url is implemented in my model: > > >> class BlogEntry(Model): > >>def get_absolute_url(self): > >>return self.id > > >> but the link in the template is alwayshttp://localhost:8000/blog/ > >> where blog is my application name and which is also the URL used to > >> get to the template above. I can even return anything (like a > >> constant > >> string) but it's not being taken into account, the link is also the > >> same. What is wrong there? > > >> 2) As the name says get_absolute_url should always return a absolute > >> URL (which I understand is a complete URL). Is there a standard way > >> to > >> produce such a URL? For example I need to my server (here is > >> localhost: > >> 8000) and the path to application (blog/). > > >> Thanks, > > >> Florian --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Model advice, i18n and content
Hello Remco, A subset of what you are looking for is provided by this library: * http://code.google.com/p/django-multilingual/ I found it very easy to work with hand I was able to modify flatpage (since this was what I was looking) in a very small amount of time. What it will bring to you : * a nice admin interface to handle your multilingual content * The right language will be served to your user An exemple of it can be found there : http://yml.alwaysdata.net The content is available in 2 languages french and english. * I am also missing some icons to see the current language and other languages available. Of course you could jump from one to the other by clicking on it I hope that will help you. What it will not do : * easy to connect the same article in both languages (no idea on how to do that) * the language in the url (also they were some discussion about it there : http://groups.google.com/group/django-multilingual/browse_frm/thread/b05fc30232069e1d) The output is not yet completely clear to me * On Dec 12, 4:46 pm, Rajesh Dhawan <[EMAIL PROTECTED]> wrote: > Hi Remco, > > ... > > > > > Now, the question. I see two obvious way to model this. Say my blog has an > > 'Article' model. > > > Then: > > > - Either two different versions are separate Articles, the article has a > > language code, and it has optional fields 'this_article_in_dutch' and > > 'this_article_in_english', that lead to the other version, if it exists. > > > or > > > - One article holds both versions; they share a creation date, and have > > separate fields for 'context_dutch' and 'content_english', same for title > > and slug. > > > I think it should be the first. But I was wondering what other approaches > > others have taken, I can't be the first one with this sort of issue. > > Another way of modeling this: > > class ArticleContainer(Model): > "Language neutral container for an article" > slug = SlugField(unique=True) > > class Article(Model): > "Language specific article" > container = ForeignKey(ArticleContainer) > lang = CharField(max_length=2, db_index=True) > #title = ... > > class Meta: > unique_together = (('container', 'lang'),) > > def other_versions(self): > return self.container.article_set.exclude(pk=self.pk) > > def comments(self): > return self.container.comment_set.all() > > > Comments are an issue. In principle I'd want comments to one article also > > appear under the other, language doesn't matter. But I'm not sure. > > class Comment(Model): > "Comments are common to all language flavors of an article" > container = ForeignKey(ArticleContainer) > #comment = ... > > It's also possible to turn the Article.lang field into a ForeignKey to > a Language reference object if you foresee needing to hang other > objects off of a particular language. > > -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: Strange FastCGI problems
TP are you using @user_passes_test decorator with urlresolvers (url, reverse ...). I had a problem similar to what you are describing and I finally find out that this problem was infact related to the bug described there: http://code.djangoproject.com/ticket/5925 I hope that help On Dec 6, 3:31 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Dec 6, 12:40 pm, TP <[EMAIL PROTECTED]> wrote: > > > I thought I needed multiple Apache's since I frequently have several > > concurrent requests. The actual dynamic python processing is quick, > > but since clients could be connected for relatively long (slow > > connections, etc), I thought I'd need multiple Apache's talking to > > each. Since Django says it's not officially thread safe, I'm using the > > prefork MPM in Apache. > > Even in 'prefork' mode of Apache, there are multiple processes > handling requests and so concurrent requests is not a problem. The > problem with prefork though is that you can end up with lots of > process, all consuming the maximum your Django application will use. > > For memory constrained VPS systems, using 'worker' MPM is a better > choice as you cut down on the number of Apache child processes and > therefore memory, with concurrency then coming from multithreading, > but also from fact that multiple processes still may also be running. > > You might have a read of: > > http://code.google.com/p/modwsgi/wiki/ProcessesAndThreading > > which talks about the different process/threading models that Apache > provides and how mod_wsgi makes use of them and extends on them. > > In respective of thread safety of Django, where does it say it is 'not > officially thread safe'. I know that it is implied through fact they > suggest prefork when using mod_python, but they also don't say to > avoid mod_python on Windows, which is multithread, plus FASTCGI > examples give examples using multithreading. So, there is actually > conflicting information on the issue. > > As explained in: > > http://code.google.com/p/modwsgi/wiki/IntegrationWithDjango > > the situation seems to be that there are no known current issues with > Django itself in respect of multithreading. Thus, any multithread > problems are more likely to come from the application built by a user > using Django. So, it is just a matter of testing your application so > you are satisfied that there isn't a problem. > > > I looked at mod_wsgi and decided to try fastcgi since the Django docs > > explicitly support it. But, given my problems perhaps I'll try > > mod_wsgi next. > > That there is nothing in Django documentation about mod_wsgi is more > to do with no one offering up anything to add which mentions it. The > Django documentation on mod_wsgi site is reasonably comprehensive and > maybe even a link to that would be a good start. I haven't offered > anything up myself for the Django site as believe that it has to be > the Django developers/community that first need to work out whether > they see it as a viable option and when they are happy add a link to > it. > > FWIW, people are using mod_wsgi quite happily with Django. I know of a > couple of notable Django sites which are delaying looking at moving > until mod_wsgi 2.0 is released as that will be the first version which > allows Python code to be used to implement Apache HTTP authentication > provider. For what those sites do, having that feature is critical and > they can't move away from mod_python until mod_wsgi provides an > equivalent mechanism. > > Graham > > > On Dec 5, 8:26 pm, Graham Dumpleton <[EMAIL PROTECTED]> > > wrote: > > > > On Dec 6, 12:04 pm, TP <[EMAIL PROTECTED]> wrote: > > > > > I've been using Django for the past few months and had great results > > > > with Apache and mod_python. However, I'd like to try and reduce the > > > > amount of memory that is used by having multiple Apache's each with > > > > their own copy of my application. I decided to try mod_fastcgi in > > > > Apache and Django's FastCGI server capability. > > > > Why have multiple Apache's if using mod_fastcgi. You should be able to > > > hang multiple FASTCGI hosted applications hanging off the one Apache. > > > > BTW, you might also want to look at mod_wsgi. Allows you to run Django > > > in separate process of their own just like FASTCGI, but everything > > > still managed by Apache without the need for you to separately start > > > Django or use any supervisor system to keep it running. > > > > Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Nested Inlines, dynamic forms, templates and all sorts of problems.
Hello Felix, In a very similar situation I have chosen option 2 for the following reasons: * the code was much more simple, at least simpler to maintain for me * Very hight control on the layout of the form. I have taken this decision after spending several days working on a "newform" based solution. And just for the record the newform solution was working fine but was more complex to maintain/debug. Regards, --yml On 9 oct, 18:11, "Felix Ingram" <[EMAIL PROTECTED]> wrote: > Hello all, > > I've been making great strides with my application since returning > from the land of Pylons. Given that the app is all about data entry > I've taken the customise-the-admin-app approach to things and made the > switch to newforms-admin this morning. > > So far things are working: data is being entered and I've even got > things rendering into ODT and DOCX. > > I've now got a little stuck, however. I have three models: Report, > Section and Pictures. Sections are pieces of boilerplate which are > added to a report and pictures are added to a section. Currently > sections are edited inline with reports and pictures are edited inline > with sections. > > What I would like to do is allow users to add sections and pictures to > a report at the same time (effectively nested inlines). > > In models: > > class Report(...): > fields... > > class Section(...): > report = ForeignKey(Report, ...) > > class Picture(...): > section = ForeignKey(Section, ...) > > I'm trying to decide on the best way to do this. I've come up with a > few possible options and would appreciate any pointers about which > would be the best (or worst). > > 1. Create a dynamic newform. > This way gets all of the required fields onto the screen but I'd like > to be able to group things in fieldsets and do non-simple layouts. I > tried to create a template but ran into trouble as I didn't know the > number of fields or how to test the name of the fields being looped > over in order to group them. > > 2. Create the template by hand. > I can just pass my report instance to the template and create the form > manually but then I lose the magic of validation (which would probably > mean I'd end up using formencode or similar). > > 3. Add a pop up to the current template. > This would allow the user to create the section and then open a pop up > to do the pictures. There are problems with ensuring the section is > valid and saved first, however. > > 4. Mystery fourth option that I should have been using all along. > I don't know much about this one; anyone any ideas? > > If any one's had to implement something similar then I'd appreciate > any advice. Any thoughts or ideas would also be gratefully received. > > Regards, > > Felix --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Strange error, trying to deploy Django with mod_wsgi
Hello Steve, Sometimes ago when I first try to use mod_wsgi I have written a wiki page there: * http://code.djangoproject.com/wiki/django_apache_and_mod_wsgi It is a step by step procedure that I have followed to configure mod_wsgi. It might help you to get your application up and running with mod_wsgi. Good luck On Sep 25, 7:26 am, Steve Potter <[EMAIL PROTECTED]> wrote: > On Sep 24, 6:16 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > > > > Are you sure that the user Apache is running as has permissions > > > to read directories/files under the missed user's home dir?. > > > The permissions issues along with other common issues are described > > in: > > > http://code.google.com/p/modwsgi/wiki/ApplicationIssues > > > What you might do if permissions is an issue is use mod_wsgi daemon > > mode to delegate your Django instance to a separate daemon process > > that runs as you rather than the default Apache user. > > > Graham > > Thanks, > > That took care of the error I was receiving, as well as a few > subsequent ones. Now I am stuck with another one. > > I am able to load the admin properly, but when I try to access my app > I get the following error: > > ViewDoesNotExist at /imglog/ > Tried index in module projectsmt.imglog.views. Error was: 'module' > object has no attribute 'models' > > But the view does exist and works properly with the development > server. > > After looking through the archives, I thought I was running up against > a path problem. However I added both the project directory as well as > its parent directory to the PythonPath. > > Still no luck...So then I decided that I still had a permissions > issue, but I went as far as moving the project into /var/django and > setting all of the permissions to 777 and I still get the error. > > I am at a complete loss, what is the above error referring to when it > says 'module' object? > > I looked through the view.py file for my app, and the only occurrence > to the word 'models' I could find was in an import statement. > > Steve --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Multilingual site best practices
Hello, I have read something today about multi lingual database. There is a project hosted there: http://code.google.com/p/django-utils/wiki/TranslationService that seems to do what you are looking for. I have never used it myself. I hope that will help you On Aug 10, 9:52 pm, Francis <[EMAIL PROTECTED]> wrote: > 1. You should use a quick description and then write the full text in > the po file. > > 2. You are better of using english in the {%trans%} bloc because > gettext don't support UTF-8 or character outside the limited ascii. > > no clue for 3. > > Francis > > On Aug 10, 11:42 am, Vincent Foley <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I work for a company who develops web sites and web applications for > > clients in Quebec. People in Quebec mainly speak french, but there > > are english speaking people too. Most sites we make eventually want > > to have a french and english version with french being the "main" > > version. > > > I would like to know if anyone could share best practices for > > multilingual sites. I also have some questions: > > > 1. In the {% trans %} and {% blocktrans %} tags, should I include the > > full text, or just a quick description and enter the full text in > > the .po files? > > > 2. As I said, french is the main language in Quebec, so if I write a > > site in french and am later asked to translate it, will the accented > > characters cause a problem if they're used in the msgid of the .po > > files? > > > 3. It seems the server always has to be restarted after the .po files > > have been compiled. Is that so? If I don't have root access to the > > server to restart Apache, is there a way I can have the new > > definitions appear on the site? > > > Thanks for the input, > > > Vincent. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Trouble with installing stockphoto
Hello, It looks like your "base.html" is in a folder which is not defined in the "TEMPLATE_DIRS". In order to fix your problem you should add this directory to this tuple. I hope that help On Aug 2, 5:38 am, Danno <[EMAIL PROTECTED]> wrote: > So I was able to import everything it looks like ok, but when i go > tohttp://localhost/stockphoto/ > > it is giving me the following error: > TemplateSyntaxError at /stockphoto/ > Template u'base.html' cannot be extended, because it doesn't exist > > So I navigate to my installed stockphoto at c:/python25/Lib/site- > packages/stockphoto/templates/stockphoto/base.html and sure enough the > only thing in it is {% extends "base.html" %} > It is trying to extend itself as far as I can tell. > > Any help on this would be extremely appreciated, Thank you! > > Rocksteady, > Danno~ > > On Aug 1, 2:17 am, Danno <[EMAIL PROTECTED]> wrote:> I am having a bit of > trouble installing stockphoto > (http://www.carcosa.net/jason/software/django/stockphoto/README.html) > > > I am wanting to try out just the functionality of the app itself, not > > yet integrating it with a current project and am running into a few > > errors. Here is my work flow as to how I've set up a new project to > > have stockphoto: > > > I downloaded the stockphoto-0.2.tar.gz, uncompressed it and have the > > folder stockphoto-0.2 in c:/django/stockphoto-0.2 > > > command line>cd : c\django > > > c\django> manage.py startproject testproject > > > from here, I have tried multiple ways toinstallstockphoto as an app > > inside the c:/django/testproject/ directory and i just can't get it. > > > Any and all help you can give this newbie will be extremely > > appreciative. Thank you guys! > > > Rocksteady, > > Danno~ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: What should I do to make admin display more fields in User model?
This might help you: http://www.b-list.org/weblog/2006/06/06/django-tips-extending-user-model On Jul 30, 11:56 am, "James Bennett" <[EMAIL PROTECTED]> wrote: > On 7/30/07, Daniel Kvasnicka jr. <[EMAIL PROTECTED]> wrote: > > > Hey, nobody has ever needed this? Any thoughts? > > You might want to search the archives of this list, or go to Google > and type in "django extend user"; this is a pretty common question and > has been covered in a lot of detail ;) > > -- > "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 -~--~~~~--~~--~--~---
complex form => Newforms vs template
Hello, May be what I am going to say is completely stupid but if it is the case please let me know why :-) I face the situation several times in the last weeks that I was willing to build a "complex" form, not directly related to a model. This forms had the following requirements: it should be dynamically generated based on the object I want to create. It was trying to update/create or only display information from many instances from many different models. I don't know if this can help: I was trying to display a form to collect an "Interview" of someone on a "Survey" which is composed of "Polls" which are composed of Choices. For each Poll the user can select one or several choice. A choice is represented by "choice.text", "choice.image" and a checkbox. I spent to several days on trying to achieve this with the newforms library and thank to the help of many people I finally reach to a point where I got something almost working. But the result was such a monster that I have decided to rewrite it with a template approach. I have now a form that is dynamically created thanks to a template rather than the class from the newforms library. So my question is am I missing something or I was just expecting too much from the newforms? My last question is would it be absurd to have a form field called TemplateField to which we can give a template string that will be dynamically inserted and substituted in the template? I hope that this post is not too long, and that the answer of these 2 questions is not in the documentation. Thank you for your feedbacks yml --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: static css problems on windows box
Hello, just for the sake pay attention to the difference between "\" and "/". If I remember well ONLY "/" will work. yml On Jul 27, 10:59 am, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Jul 27, 6:31 pm, Graham Dumpleton <[EMAIL PROTECTED]> > wrote: > > > > > On Jul 27, 4:09 pm, devjim <[EMAIL PROTECTED]> wrote: > > > > Mod_python is working and I have this in my http.conf > > > > > > SetHandler python-program > > > PythonHandler django.core.handlers.modpython > > > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > > > PythonDebug On > > > PythonPath "['c:devtestproj'] + sys.path" > > > > > > > > > SetHandler None > > > > > > Instead of Location directive for media files, you should have Alias > > directive and Directory for actual physical directory the files are > > located in. For example something like: > > > Alias /mainmedia C:/path/to/media/files > > Whoops, missed the trailing slashes. Should be: > > Alias /mainmedia/ C:/path/to/media/files/ > > Grahamd > > > > > Order deny,allow > > Allow from all > > > > > > > SetHandler python-program > > PythonHandler django.core.handlers.modpython > > SetEnv DJANGO_SETTINGS_MODULE testproj.settings > > PythonDebug On > > PythonPath "['c:devtestproj'] + sys.path" > > > > > The Location directive will not work for media files as it is for > > virtual resources, whereas Alias maps it to physical resources. > > > Graham --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: django-admin.py validate
Hello, This is the webpage you are looking for: http://www.djangoproject.com/documentation/settings/ you should read the section called : "The django-admin.py utility" and according to the os you are running you should set this variable. I hope that help On Jul 27, 3:11 pm, arf_cri <[EMAIL PROTECTED]> wrote: > I forgot to say that I don't know how to make it work... if it is not > obvious :). > > On Jul 27, 3:07 pm, arf_cri <[EMAIL PROTECTED]> wrote: > > > Traceback (most recent call last): > > File "/usr/bin/django-admin.py", line 5, in ? > > management.execute_from_command_line() > > File "/usr/lib/python2.4/site-packages/django/core/management.py", > > line 1563, in execute_from_command_line > > from django.utils import translation > > File "/usr/lib/python2.4/site-packages/django/utils/translation/ > > __init__.py", line 3, in ? > > if settings.USE_I18N: > > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > > line 28, in __getattr__ > > self._import_settings() > > File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", > > line 53, in _import_settings > > raise EnvironmentError, "Environment variable %s is undefined." % > > ENVIRONMENT_VARIABLE > > EnvironmentError: Environment variable DJANGO_SETTINGS_MODULE is > > undefined. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Instant Django
This is half solving the problem. with your fix in the start.bat now when i launch python it start python on the memory stick but for some reasons dajngo-admin.exe call python installed on my computer not the one in your package. However this is working fine "E:\instant_django\django>python Utilities/django-admin.py" but this is not working : E:\instant_django\django>E:\instant_django\django\Utilities\django- admin.py Traceback (most recent call last): File "E:\instant_django\django\Utilities\django-admin.py", line 5, in from django.core import management ImportError: No module named django.core It seems that django-admin.exe behave like "E:\instant_django\django \Utilities\django-admin.py" instead of "python Utilities/django- admin.py" Thank you for your effort in helping me. On Jul 24, 8:45 pm, cjl <[EMAIL PROTECTED]> wrote: > Thanks again for the bug report, I have found the problem. > > Change the 'path' section of start.bat to read: > > path = %CD%\Python25;%CD%\Utilities;%CD%\Utilities\svn- > win32-1.4.4\bin;%CD%\Utilities\exemaker-1.2-20041012;%CD%\Utilities > \npp.4.1.2.bin;%CD%\Utilities\sqlite-3_4_0;%PATH% > > I had %PATH% first, and it needs to come last, because order matters, > and it needs to find my python before it finds the previously > installed python. > > I will make the change, and upload a new version later. > > -cjlesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Instant Django
Hello, I have downloaded your package and launch the start.bat Then in that console I have entered: "django-admin startproject test_admin" Unfortunatly the system raises this error message: """ Traceback (most recent call last): File "E:\instant_django\django\Utilities\django-admin.py", line 5, in from django.core import management ImportError: No module named django.core """ It looks like the system is using my "installed" python and not the one provided in your package. Could you please let me know what need to be done to fix this error? Thank you very much for your effort of making django moveable. Regards, yml On Jul 23, 11:30 pm, cjl <[EMAIL PROTECTED]> wrote: > Nathan: Thank you for the suggestion, I'm sure you're right. I'll add > in a start-up message to 'start.bat' the next time I upload an update. > > Cam: Thank you for the kind words. If you do get a change to play > around with it, I would appreciate feedback and bug reports. > > Rob: I see you read my 'disclaimer'. I would argue that sipping wine > in a nice club with a beautiful woman would make anything sound good, > but I'll admit that I have never done it. I have pounded cheap beer in > a dirty bar with slutty chicks while listening to AC/DC, and I would > highly recommend it. By the way, I'm from Buffalo, too. > > Strangely enough, and slightly off-topic, I found a Japanese > translation of my website:http://www.win-django.com/ > > -cjlesh --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: context processor question
Hello, Here it is the part of the documentation you are looking for: http://www.djangoproject.com/documentation/templates_python/#subclassing-context-requestcontext This is an extract of the part that you are looking: If you're using Django's render_to_response() shortcut to populate a template with the contents of a dictionary, your template will be passed a Context instance by default (not a RequestContext). To use a RequestContext in your template rendering, pass an optional third argument to render_to_response(): a RequestContext instance. Your code might look like this: def some_view(request): # ... return render_to_response('my_template.html', my_data_dictionary, context_instance=RequestContext(request)) I hope that help. On Jul 19, 6:45 am, james_027 <[EMAIL PROTECTED]> wrote: > Hi Jeremy, > > I am a bit lost ... where do I apply that? Isn't that I just call the > variable name/dict key in the template? > > Thanks > james > > On Jul 19, 11:18 am, "Jeremy Dunck" <[EMAIL PROTECTED]> wrote: > > > On 7/18/07, james_027 <[EMAIL PROTECTED]> wrote: > > ... > > > > the commonly use data will automatically available, do I get it right? > > > Yes. Just keep in mind that you need to use RequestContext rather > > than Context in order for context processors to be applied. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Improve the dynamic generation of a form with newforms library
Hello Djangonauts, After spending sometimes to learn using the test/fail/correct cycle I have finally reach a point where I have something that more or less do what I want. However since one of the objectives of the project I am working on was to improve my knowledge on django I would like to read from you how to improve what I have done. The goal is to generate dynamically a form using the newforms library. This forms should all the user to create an Interview (models.py:http://dpaste.com/hold/14560/ ) What I have done so far is create this custom form: class AnswerPollForm(forms.Form): def __init__(self, poll_id, *args, **kwargs): super(AnswerPollForm, self).__init__(*args, **kwargs) self.poll = Poll.objects.get(id=poll_id) for c in self.poll.choice_set.iterator(): self.fields[c.id] = forms.BooleanField(label=c.choice,required=False) That I use in this view (http://dpaste.com/hold/14562/). The interesting part is that I create a list of tuple made with the polls and the forms representing them. This allow me to create a single form that I can use to collect the interview to a survey. list_answer_forms =[] for poll in survey.poll_set.iterator(): list_answer_forms.append((poll,AnswerPollForm(poll.id))) [...] return render_to_response('dj_survey/template/ add_interview_forms.html', {'list_answer_forms': list_answer_forms, 'survey': survey, 'request': request}) This list of forms is then used in the following template: Welcome to {{ survey.name }} {{ survey.description }} {% for poll,form in list_answer_forms %} {{ poll.title }} | {{ poll.question }} {{ form.as_ul }} {% endfor %} This is not bat but i would prefer if instead of the list of tuple containing my forms could directly instantiate a "all in one" form. This would avoid the loop on list_answer_forms. This is were I get stuck. Could you please let me know how to add html text between the field? like "{{ poll.title }} | {{ poll.question }}" Any other improvement is more than welcome. Thank you for your time. Regards, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 newforms to create multiple related objects?
Hello, It would be great if one of the Gurus could spend some time to answer this kind of questions. I am trying to do something similar. But so far I haven't been able to achieve this. I am looking for a way to build dynamically a form representing a mashup of several models and its associated view. Thank you On Jun 29, 3:45 am, Michael Sylvan <[EMAIL PROTECTED]> wrote: > Hello, > > I am trying to use newforms and templates, together with the following > models, to mimic what the admin application does with num_in_admin : > provide a form for Person's fields, and multiple Phone forms. > > With just one Phone form things are quite straightforward: validate > the Person form, and if that passes, save the object, get its ID, fill > the ID field of the Phone object and then save it. > > With multiple Phone forms, however, I have not been able to customize > the HTML IDs of the various fields -- form_for_model generates > identical forms! > > One can modify form_for_model with a custom formfield_callback > function, but as far as I can tell, it maps a field name to a field > object, so it won't be enough to override that. > > Is there a way to do this sort of things cleanly, short of using the > newforms-admin branch of Django? Or do I have to do something like > changing the form's fields attribute by hand? > > Thanks, > > -- M. Sylvan > > class Person(models.Model): > firstName = models.CharField(maxlength=32) > lastName = models.CharField(maxlength=32) > > class Phone(models.Model): > person = models.ForeignKey(Person) > number = models.CharField(maxlength=24, core=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 -~--~~~~--~~--~--~---
need help to define models.py for a survey app?
Hello Djangonauts, I am creating a new application to support the creation of online poll (survey). The goals for this application is to support both: -a> The creation of the survey performed by the technical writers -b> Store the answers given by the interviewees The first aspect is similar to what is demonstrated in the tutorial so it was relatively easy to come up with a proposal. The part that I find difficult is to represent the second one. It would be great if someone could suggest a (the best) way to store the answers given by each interviewee. So far I am using a "class" called answer but I am not sure that this is the right thing to do. Thank you for your help. Here it is the models I am having so far: ===models.py= from django.db import models import datetime class Survey(models.Model): name = models.CharField(maxlength=20) description= models.CharField(maxlength=200) start_date=models.DateField("Effective from") end_date=models.DateField("Effective to") def __str__(self): return self.name def is_effective(self): if start_date
newform and edit in line
Hello, I am trying to create a form equivalent to the edit inline that is implemented in the admin interface. I have a models with "Survey", "Poll", "Choice" as describe below and I would like to have a single page to create my Survey with multiple questions (*n) and multiple (*n) choices. ==models.py= class Survey(models.Model): name = models.CharField(maxlength=20) description= models.CharField(maxlength=200) start_date=models.DateField("Effective from") end_date=models.DateField("Effective to") class Poll(models.Model): survey=models.ForeignKey(Survey) question = models.CharField(maxlength=200,core=True) pub_date = models.DateField('date published',auto_now=True) class Choice(models.Model): poll = models.ForeignKey(Poll, edit_inline=models.TABULAR, num_in_admin=5) choice = models.CharField(maxlength=200,core=True) votes = models.IntegerField(core=True) = I do not understand yet how I can create such from with the newform library. so far I have the following views.py =views.py def survey_cud(request): # initialize variables to sent to template message = '' submit_action = 'Add' edit_id = '' # generate default form SurveyForm = forms.form_for_model(Survey) f = SurveyForm() # handle edit and delete events if request.method=="GET": if request.has_key("edit_id"): # replace default form with form based on row to edit survey = Survey.objects.get(pk=request.GET['edit_id']) SurveyForm = forms.form_for_instance(survey) f = SurveyForm() submit_action = 'Update' edit_id = request.GET['edit_id'] message = 'Editing survey ID ' + request.GET['edit_id'] if request.has_key('delete_id'): Survey.objects.get(pk=request.GET['delete_id']).delete() message = 'Survey deleted.' # handle add and update events if request.method == 'POST': if request.POST['submit_action'] == 'Add': # attempt to do add add_f = SurveyForm(request.POST) if add_f.is_valid(): add_f.save() message = 'Contact added.' else: # validation failed: show submitted values in form f = add_f if request.POST['submit_action'] == 'Update': # attempt to do update survey = Survey.objects.get(pk=request.POST['edit_id']) SurveyForm = forms.form_for_instance(survey) update_f = SurveyForm(request.POST.copy()) if update_f.is_valid(): update_f.save() message = 'Survey updated.' else: # validation failed: prepare form for new update attempt submit_action = 'Update' edit_id = request.POST['edit_id'] f = update_f # get existing surveys survey_list = Survey.objects.all() # return rendered HTML page return render_to_response('dj_survey/template/cud_survey.html', { 'request': request, 'message': message, 'survey_list': survey_list, 'form': f.as_table(), 'submit_action': submit_action, 'edit_id': edit_id }) and the following template ==template= Surveys {% if message %} {{ message }} {% endif %} {% if survey_list %} {% for survey in survey_list %} {{ survey.name }} Edit Delete {% endfor %} {% endif %} {{ form }} {% ifnotequal submit_action 'Add' %} Add New Survey {% endifnotequal %} = Thank you very much for your help. Yann --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Shopping cart application for django
Hello, It seems that you are looking for this: http://satchmo.python-hosting.com/ There is also a google group for that project. I hope that will help you. Regards, On May 16, 1:16 pm, "Nathan Harmston" <[EMAIL PROTECTED]> wrote: > Hi, > > I m currently building an e-commerce site and I was wondering if there > are any shopping cart apps out there for django that I can have a look > at and work through. I am trying to build one that can integrate with > paypal but any ideas would be cool. > > So far I am thinking of storing the whole shopping cart as a > dictionary in session where it is simply > > { product_id:amount }, > > is this a good way to proceed or do you believe there are some > problems with this approach? > > Many Thanks in advance > > Nathan --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Many to Many Ordered List
Here it is a link that details the solution a bit more: - http://www.djangoproject.com/documentation/models/m2m_intermediary/ Yann --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: Many to Many Ordered List
I would handle this kind of situation by adding an intermediate class AttributeOfTheLink. I don't know if this is a good practice but I think it will do the tricks. Let me know if you find something better. Yann --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: Custom manipulator - multiple records
Hi winston, I a couple of weeks ago I was thinking about using this method to solve one of the pb I was facing. I don't see anything there that should not work, also I have never done such thing. Could you please let us know what is exactly your problem? If there is one, :-), could you also post the error message? bye, Yann --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: unexpected keyword argument with generic view
Luke, Not sure where exactly is the error but by reading the code above there is something strange in the view "edit_blog". the line : b = blogs.get_object(pk=request.user.id) seems a bit strange to me. I do not understand why the primary key of is "request.user.id". Don't you this would be better? * b = blogs.get_object(user__exact =request.user.id) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: unexpected keyword argument with generic view
Hi Luke, Could you please the url.py from were you are calling the generic view? That could help us to pin point the pb. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: UNICODE database API How to
Thank you Ivan, Happy to see that in any case my pb would have been solved today. ;-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: UNICODE database API How to
Here it is the script that is working for me. This was done thanks to this great pages (http://effbot.org/zone/unicode-objects.htm) it took me 3 days to find it on internet. Thank you google and of course thank you to the author :-) # -*- coding: utf8 -*- import os,codecs from django.models.announceManager import * import re os.chdir(os.path.abspath("E:\\instal\\django\\view_servicealapersonne\\votreservice\\_initialLoad")) f = open("departments.txt") regexobj = re.compile("([0-9]+)\s+([\w\s?]+)",re.UNICODE) for l in f.readlines(): fileencoding = "iso-8859-1" txt = l.decode(fileencoding) print "the current line is :"+txt.encode(fileencoding, "replace") try: matches = regexobj.search(txt).groups() except: print "this is an empty line" print "matches " +str(matches) r =Department(department=matches[1].encode('utf-8','replace'),department_number=matches[0].encode('utf-8'),country="France") r.save() print "ok" print r f.close() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: UNICODE database API How to
Hello Thank you for your help but so far I do not have any success. I am reading form a the lines from a file. Here it is the kind of error I am getting : the current line is :07 ArdFche matches ('07', 'Ard\xe8che\r\n') Traceback (most recent call last): File "E:\instal\django\view_servicealapersonne\votreservice\_initialLoad\loade r_departements.py", line 19, in ? r =Department(department=matches[1].encode('utf-8'),department_number=matche s[0].encode('utf-8'),country="France") File "C:\Python24\lib\encodings\utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeDecodeError: 'utf8' codec can't decode bytes in position 3-5: invalid dat a the word that is causing trouble is Ardèche. in order to parse my data I am using the following scripts: === My script to parse the data = import os,codecs from django.models.announceManager import * os.chdir(os.path.abspath("E:\\instal\\django\\view_servicealapersonne\\votreservice\\_initialLoad")) f = codecs.open("departments.txt",encoding='utf-8') import re regexobj = re.compile("([0-9]+)\s+([\w\s?]+)",re.UNICODE) for l in f.xreadlines(): print "the current line is :"+l try: matches = regexobj.search(l).groups() except: print "this is an empty line" print "matches " +str(matches) r =Department(department=matches[1].encode('utf-8'),department_number=matches[0].encode('utf-8'),country="France") r.save() print "ok" print r f.close() = my data = 01 Ain 02 Aisne 03 Allier 04 Alpes de Haute Provence 05 Hautes Alpes 06 Alpes Maritimes 07 Ardèche < this line crash 08 Ardennes 09 Ariège thank you for your help --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: UNICODE database API How to
Ivan hi, I try your recommandation but unfortunatly it is not working I am getting the following error message: In [38]: r=Department(department=matches[1].encode('utf-8'), department_number=matches[0].encode('utf-8'), country="France") --- exceptions.UnicodeDecodeErrorTraceback (most recent call last) E:\instal\django\view_servicealapersonne\votreservice\_initialLoad\ UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 1: ordinal not in range(128) I am using mysql as DB I supposed that it does support the unicode but I am not sure. How can I make sure that it does? Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
UNICODE database API How to
Hello Djangonauts, I am tryng to import non ascii data stored in a file to do so I am using a regular expression to parse the lines of the files in order separates the "department number" from the department names. This is working fine my problem comes when I am trying to use the Django's DB API in order to save the data in a model that is described below. The problems happens when matches[1] contains non ascii characters like éàçàè... r=Department(department=matches[1],department_number=matches[0],country="France") r.save() I guess that I should add something to my script called loader_departments.py in order to support this. It would be great if someone could explain what to me Thank you for your help. = models = class Department(meta.Model): department = meta.CharField(maxlength=30) department_number = meta.IntegerField() country = meta.CharField(maxlength=30) def __repr__(self): return self.department + " "+str(self.department_number) class META: admin = meta.Admin( list_display = ('department','department_number','country'), ) the file where my data are stored look like this: == departments.txt 89 Yonne 90 Territoire de Belfort 91 Essone 92 Hauts de Seine 93 Seine Saint-Denis 94 Val de Marne 95 Val d'Oise 971 Guadeloupe 972 Martinique 973 Guyane 974 Réunion = loader_departments.py == import os,codecs from django.models.announceManager import * os.chdir(os.path.abspath("E:\\instal\\django\\view_servicealapersonne\\votreservice\\_initialLoad")) f = codecs.open("departments.txt",encoding='utf-8') import re regexobj = re.compile("([0-9]+)\s+([\w\s?]+)",re.UNICODE) for l in f.xreadlines(): print "the current line is :"+l try: matches = regexobj.search(l).groups() print "matches " +str(matches) r=Department(department=matches[1],department_number=matches[0],country="France") r.save() print "ok" except: print "ko" f.close() --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: manipulator.save() and manytomany relationship
This is an amazing tip. I didn't know that I could print messages in the runserver console. I was missing that a lot. this is eaxcltly were the problem is for some unknown reason the information is correct in new_data but when I am retrieving new_data['localisation'] I got only the last piece of the list. In the example below new_data['localisation'] transform ['1','2'] en 2 == trace in the runserver console = Starting server on port 8000 with settings module 'votreservice.settings'. Go to http://127.0.0.1:8000/ for Django. Quit the server with CONTROL-C (Unix) or CTRL-BREAK (Windows). new_data contains : new_data['localisation'] contains : 2 [30/Mar/2006 11:34:53] "POST /profiles/create_manip/ HTTP/1.1" 302 0 [30/Mar/2006 11:34:53] "GET /profiles/ HTTP/1.1" 200 2896 Validating models... 0 errors found. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: manipulator.save() and manytomany relationship
Your suggestion give the same result: temp.set_localisation(map(int,new_data['localisation'])) Only the last selected localisation is saved. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: manipulator.save() and manytomany relationship
I have added an additional temp.save. First I create the Profile with the mandatory attributes then I add the optional ones if they exist. This seems to work, I mean I do not get an error message when clicking on submit. My problem is now that even if I multi select localisation I only save the last selected one. Do you have an idea on how to solve this? my manipulator "save" function = def save(self, new_data, current_user): temp = Profile( user=current_user, pseudo=new_data['pseudo'], #want_to_publised_personal_info=new_data['want_to_publised_personal_info'], memberShipLevel=memberships.get_object(pk=new_data['memberShipLevel']), want_to_publised_personal_info=False, is_default_profile=True ) temp.save() if new_data['localisation']: temp.set_localisation(new_data['localisation']) if new_data['gender']: temp.gender= genders.get_object(id__exact=new_data['gender']) temp.address = new_data['address'] temp.phonenumber = new_data['phonenumber'] if new_data['want_to_publised_personal_info']: temp.want_to_publised_personal_info= new_data['want_to_publised_personal_info'] temp.is_default_profile=True temp.save() return temp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: manipulator.save() and manytomany relationship
I don't set any value for the profile_id. This attribute where added by django, I guess in order to have a "primary key". If I comment the line with set_localisation (which is my many to many relation) I do not get this error so I do not see why I should care about this with this additional attribute. since I am creating a new profile how can I know whick is the next available integer for my primary key. I was expecting to have it automatically managed by Dango. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: manipulator.save() and manytomany relationship
hello limodou, you have been of great help till now, thank you for your time. I tried list because I was not working without: temp.set_localisation(list(new_data['localisation'])) = error page with: list(new_data['localisation']) === OperationalError at /profiles/create_manip/ (1048, "Column 'profile_id' cannot be null") Request Method: POST Request URL:http://localhost:8000/profiles/create_manip/ Exception Type: OperationalError Exception Value:(1048, "Column 'profile_id' cannot be null") Exception Location: C:\Python24\lib\site-packages\MySQLdb\cursors.py in _do_query, line 193 Traceback (innermost last) * c:\python24\lib\site-packages\django-0.91-py2.4.egg\django\core\handlers\base.py in get_response 66. # Apply view middleware 67. for middleware_method in self._view_middleware: 68. response = middleware_method(request, callback, callback_args, callback_kwargs) 69. if response: 70. return response 71. 72. try: 73. response = callback(request, *callback_args, **callback_kwargs) ... 74. except Exception, e: 75. # If the view raised an exception, run it through exception 76. # middleware, and if the exception middleware returns a 77. # response, use that. Otherwise, reraise the exception. 78. for middleware_method in self._exception_middleware: 79. response = middleware_method(request, e) ▶ Local vars Variable Value DEBUG True INTERNAL_IPS () ROOT_URLCONF 'votreservice.urls' callback callback_args () callback_kwargs {} db e <_mysql_exceptions.OperationalError instance at 0x01597468> exceptions mail_admins middleware_method > path '/profiles/create_manip/' request , POST:, COOKIES:{'sessionid': '5736d4edabff367ea3267c90ed4207fe'}, META:{'ALLUSERSPROFILE': 'C:\\Documents and Settings\\All Users', 'APPDATA': 'C:\\Documents and Settings\\yml\\Application Data', 'APR_ICONV_PATH': 'C:\\Program Files\\Subversion\\iconv', 'BOOKSHELF': 'C:\\IFOR\\WIN\\BIN\\EN_US', 'CATHEIGHTMMOFSCREEN': '215', 'CATWIDTHMMOFSCREEN': '290', 'CLASSPATH': 'C:\\Program Files\\Java\\jdk1.5.0_05\\jre\\lib\\ext\\QTJava.zip', 'COMMONPROGRAMFILES': 'C:\\Program Files\\Common Files', 'COMPUTERNAME': 'FOUDREDDS', 'COMSPEC': 'C:\\WINDOWS\\system32\\cmd.exe', 'CONTENT_LENGTH': '91', 'CONTENT_TYPE': 'application/x-www-form-urlencoded', 'DJANGO_SETTINGS_MODULE': 'votreservice.settings', 'DS3AGN': 'FRCQD511', 'DS3CONF': 'Bureautique', 'DS3OS': 'WinXP', 'DS3TYPEMAT': 'IBMThinkT42', 'DS3USER': 'tmp', 'FP_NO_HOST_CHECK': 'NO', 'GATEWAY_INTERFACE': 'CGI/1.1', 'HELP': 'C:\\IFOR\\WIN\\BIN', 'HOMEDRIVE': 'C:', 'HOMEPATH': '\\Documents and Settings\\yml', 'HTTP_ACCEPT': 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5', 'HTTP_ACCEPT_CHARSET': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', 'HTTP_ACCEPT_ENCODING': 'gzip,deflate', 'HTTP_ACCEPT_LANGUAGE': 'fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3', 'HTTP_CONNECTION': 'keep-alive', 'HTTP_COOKIE': 'sessionid=5736d4edabff367ea3267c90ed4207fe', 'HTTP_HOST': 'localhost:8000', 'HTTP_KEEP_ALIVE': '300', 'HTTP_REFERER': 'http://localhost:8000/profiles/create_manip/', 'HTTP_USER_AGENT': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.8.0.1) Gecko/20060111 Firefox/1.5.0.1', 'I4_INSTALL_DRIVE': 'C:', 'I4_LANG': 'EN_US', 'IPF_PATH32': 'C:\\IFOR\\WIN\\BIN\\EN_US', 'JAVA_HOME': 'C:\\Program Files\\Java\\jdk1.5.0_05\\bin', 'LIB': 'C:\\Program Files\\SQLXML 4.0\\bin\\', 'LOGONSERVER': 'FOUDREDDS', 'NLSPATH': 'C:\\IFOR\\LS\\MSG\\%L\\%N', 'NUMBER_OF_PROCESSORS': '1', 'OS': 'Windows_NT', 'PATH': 'C:\\Perl\\bin\\;C:\\Program Files\\Common Files\\VERITAS Shared;C:\\VERITASNetBackup\\bin;C:\\PROGRAM FILES\\THINKPAD\\UTILITIES;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\\ATI Technologies\\ATI Control Panel;C:\\Program Files\\Resource Pro Kit\\;C:\\IFOR\\WIN\\BIN;C:\\IFOR\\WIN\\BIN\\EN_US;C:\\Program Files\\ATI Technologies\\Fire GL 3D Studio Max;C:\\Program Files\\ATI Technologies\\Fire GL Control Panel;C:\\Program Files\\Microsoft SQL Server\\90\\Tools\\binn\\;E:\\users\\src_Install\\IronPython\\IronPython-0.7.3\\bin;C:\\Python24;C:\\Python24\\Scripts;C:\\cygwin;C:\\Program Files\\HTML Help Workshop;E:\\instal\\SmarTeam\\BIN;C:\\Program Files\\Microsoft SQL Server\\80\\Tools\\Binn\\;E:\\users\\src_Install\\Nant\\nant-0.85-rc3\\bin;C:\\WINDOWS\\Microsoft.NET\\Framework\\v1.1.4322;C:\\cygwin\\bin;c:\\Program Files\\MySQL\\MySQL Server 5.0\\bin;C:\\Program Files\\Java\\jdk1.5.0_05\\bin;c:\\Program Files\\QuickTime\\QTSystem\\;C:\\Program Files\\Subversion\\bin', 'PATHEXT': '.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH', 'PATH_I
Re: ANN:Woodlog Testing
hello limodou, I was think to start developing something similar to add it to a portal I am working on. Of course I would have done it with a less talent than you. :-) Are you going to open source it that I could learn from your source and use it Good job --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: customised generic view
Thank you Michael, This make sense now to me, I was expecting to much from it. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: customised generic view
Eureka! Thank you all for your help and support. After 2 days of test and fails. here it is the solution: Here it is the save function which is solving my issue: def save(self, new_data): temp = Profile( user=users.get_object(pk=new_data['user']), pseudo=new_data['pseudo'], #gender=new_data['gender'], #address=new_data['address'], #phonenumber=new_data['phonenumber'], #want_to_publised_personal_info=new_data['want_to_publised_personal_info'], want_to_publised_personal_info= False, memberShipLevel=memberships.get_object(pk=new_data['memberShipLevel']) ) #temp.set_localisation(newdata['localisation']) temp.save() return temp Based on this, I can tell you that I do not understand at all what the following statement is doing. manipulator.do_html2python(new_data) Does someone could help me on this? Thank you again for open sourcing Django. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: customised generic view
Limodou, This is what I did and the result is that it hapens in the: manipulator.save() So I am going to the same thing in this function in order to see which satement is causing trouble. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: customised generic view
Limodou, This is what I did and the result is that it hapens in the: manipulator.save() So I am going to the same thing in this function in order to see which satement is causing trouble. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~--~~~~--~~--~--~---
Re: customised generic view
Hello Limodou, ok I read the soucre of the formfield in order to fix the radio_admin buton I replace the SelectField by a RadioSelectField the form is now properly displayed with radio button. I agree with you that the error message seems to direct us to a pb of template but there the line which is causing me trouble is the line 50 of my view.py: manipulator.save(new_data) if this line is commented everything work except that the object is not created. :-) is there a way to run a view in "Debug Mode" with the debugger going line by line to follow my request in the django stack? do you have any other idea of what can cause this? Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: customised generic view
Hello, As discussed above I spend mos of my evening learning about manipulator. I was pretty happy since it seems much more difficult than it is. This is what I thaught when I did the couple of examples I found on the web. So what I did is generate the custom manipulator using the script that I found there: http://code.djangoproject.com/wiki/ManipulatorScript The first trouble I had was with radio_admin. Django for some reason was complaining about them. Here it is the message: ++ TypeError at /profiles/create_manip/ __init__() got an unexpected keyword argument 'radio_admin' Request Method: POST Request URL:http://localhost:8000/profiles/create_manip/ Exception Type: TypeError Exception Value:__init__() got an unexpected keyword argument 'radio_admin' Exception Location: E:\instal\django\view_servicealapersonne\votreservice\..\votreservice\announceManager\views.py in __init__, line 58 ++ So I remove those keyword. Does someone can tell me what I should do to solve this? Once I remove radio_admin everyting seems to work except the statement: manipulator.save(new_data) == The Model == class Profile(meta.Model): user =meta.ForeignKey(User) pseudo = meta.CharField(maxlength=30,core=True) gender= meta.ForeignKey(Gender,radio_admin=True,null=True,blank=True) address = meta.TextField(maxlength=300,null=True,blank=True) phonenumber = meta.CharField(maxlength=10,null=True,blank=True) want_to_publised_personal_info = meta.BooleanField() #photo = meta.ImageField(upload_to="memberPhoto",null=True) localisation = meta.ManyToManyField(Localisation,null=True,blank=True,filter_interface=meta.HORIZONTAL) memberShipLevel = meta.ForeignKey(Membership,radio_admin=True) def __repr__(self): return self.pseudo class META: admin = meta.Admin( fields = ( ('General information',{'fields': ('user','localisation')}), ('Online information',{'fields': ('pseudo','memberShipLevel','want_to_publised_personal_info')}), ('Optional information',{'fields': ('gender','address','phonenumber')}), ), list_display = ('user','pseudo','want_to_publised_personal_info','phonenumber'), ordering = ['pseudo'], ) views.py === @login_required def profiles_create_manipulator(request): manipulator =announceManagerProfileManipulator() logged_in_user=request.user if request.POST: new_data = request.POST.copy() errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) manipulator.save(new_data) return render_to_response("announceManager/profiles_index") else: errors = new_data = {} form = formfields.FormWrapper(manipulator, new_data, errors) return render_to_response('announceManager/profiles_form', {'form': form}) class announceManagerProfileManipulator(formfields.Manipulator): def __init__(self, pk=None): self.fields = ( formfields.SelectField(field_name='user', is_required=True, choices=[('','---')] + [(o.id, o) for o in users.get_list()]), formfields.TextField(field_name='pseudo', is_required=True, maxlength=30), #formfields.SelectField(field_name='gender', radio_admin=True, choices=[('','---')] + [(o.id, o) for o in genders.get_list()]), formfields.SelectField(field_name='gender', choices=[('','---')] + [(o.id, o) for o in genders.get_list()]), formfields.TextField(field_name='address', maxlength=300), formfields.TextField(field_name='phonenumber', maxlength=10), formfields.CheckboxField(field_name='want_to_publised_personal_info'), #formfields.SelectField(field_name='memberShipLevel', is_required=True, radio_admin=True, choices=[('','---')] + [(o.id, o) for o in membershiplevels.get_list()]), formfields.SelectField(field_name='memberShipLevel', is_required=True, choices=[('','---')] + [(o.id, o) for o in memberships.get_list()]), formfields.SelectMultipleField(field_name='localisation', choices=[(o.id, o) for o in localisations.get_list()]), ) def save(self, new_data): temp = Profile( user=new_data['user'], pseudo=new_data['pseudo'], gender=new_data['gender'], address=new_data['address'], phonenumber=new_data['phonenumber'], want_to_publised_personal_info=new_data['want_to_publised_personal_info'], memberShipLevel=new_data['memberShipLevel'] ) temp.set_localisation(newdata['localisation']) temp.save() return temp = prodiles_form.py {% block content %}
Re: limit_choices_to
Hello tonemcd, Thank you for the link it look interesting. However I am not understanding where I should add those lines: # cciw/middleware/threadlocals.py import threading _thread_locals = threading.local() def get_current_user(): try: return _thread_locals.user except AttributeError: return None class ThreadLocals(object): """Middleware that adds various objects to thread local storage from the request object.""" def process_request(self, request): _thread_locals.user = getattr(request, 'user', None) Do you have an idea? Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: customised generic view
Hello Limodou, Thank you this is what I start to understand. The pb is that so far I have never try that and it looks pretty difficult. This impression might be becous I have never done it. This is time to learn... :-) So I will try to implement my first manipulator this evening. My objective is to be able to put my application in production in may so I think it would be wise to move now to the magic removal branch before starting to write too much code. What do you think about this? Thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Re: customised generic view
Hi, I understand your point but for some reason in that case I need a one to many relationship. cu --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
limit_choices_to
Hello, Is there someone kind enought to provide me some guidance on the usage of "limit_choices_to" in a foreign key? my model look like this: class Profile(meta.Model): user =meta.ForeignKey(User) pseudo = meta.CharField(maxlength=30,core=True) [...] def __repr__(self): return self.pseudo class META: admin = meta.Admin() class Announce(meta.Model): titre = meta.CharField(maxlength=30) [...] profile =meta.ForeignKey(Profile, limit_choices_to={'user__exact' : meta.LazyDate()}) def __repr__(self): return self.titre class META: admin = meta.Admin( ) The User is the regular django.models.auth class. I would like to filter the Profiles on the attribute user. the objective it display only the profiles of the logged in user. I found that it should look like somelike this: profile =meta.ForeignKey(Profile, limit_choices_to={'user__exact'=##?the curentuser?## : meta.LazyDate()}) It would be great if someone can help me to complete my dict. thank you --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---