Re: how to get {% url %} working with {% blocktrans %}?
On Fri, Aug 29, 2008 at 10:55 PM, Martin Diers <[EMAIL PROTECTED]> wrote: > > There is a currently a discussion an even newer discussion on Dev, > where Jacob has proposed a new syntax, and has a patch that would > allow this: > > {% url django-admindocs-docroot as docroot %} > > Then docroot becomes a variable, containing the url, that can be used > in a {% blocktrans %}, obviating the need for {% captureas %} > > It looks like this will make it in to 1.0. > It already has: http://code.djangoproject.com/changeset/8716 Maybe the use of url with blocktrans should be documented now somewhere? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Getting things into entries
On Fri, Aug 29, 2008 at 11:22 PM, Martin Diers <[EMAIL PROTECTED]> wrote: > > On Aug 29, 2008, at 2:22 PM, Benjamin Buch wrote: > >> >> Clumsy subject, I know... >> >> I know there was a recent discussion about this, but I lost it, so >> sorry for asking again. >> So here's the question: >> >> How can you allow your users to add something like pictures into >> something like blog posts? >> Not just below or above (this could be achieved by a simple foreignkey >> I guess...), but at positions they want to? >> >> Antoher related question would be if it's possible to include tags and >> variables ({{ somevariable }}) into text I enter into the admin? >> >> -benjamin >> > > > Yes, and yes, and the solution is both cases is the same. > > As to how to get the image up there and reference it, here's a > suggestion: Create a model just for images, a form for users to upload > images, and a custom tag which I can then use to insert an image by > name. They can then use the tag in the blog post to include the image. > > To allow tags to be used in content areas, including what you add in > the admin, you will need to double-render your page. > > Like this: > > my_context = {'blah': 'blah'} > output = render_to_string('my_template.html', my_context) > t = Template(output) > HttpResponse(t.render()) > That's a really bad idea. Users can bring the whole site down with malformed content if you do it like that. At least you should do something like that: try: usercontent = render_to_string('whatever.html', {...}) except TemplateSynatxError: # maybe other exceptions? usercontent = '' render_to_response('main.html', { 'usercontent': usercontent, }) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: inlineformset_factory
here (http://dpaste.com/71450/) is an example for using inlineformset_factory (see better_author_edit). don´t know if this is much help though. maybe you can post your exact error-message. patrick. On Aug 30, 12:09 am, cmiller <[EMAIL PROTECTED]> wrote: > Hi All, > > I have been hitting my head against a wall for way to long on this. > > When I view it on the edit page everything looks great! But when I > try to Save or Update, everything unravels. > > I'm following it just the way the very sparse documentation suggests, > and yet I get a "Exception Type: KeyError". I've tried it the way > listed below and where "ff=BookFormSet(request.POST, instance=a)" and > where I first put request.POST into a dictionary. Nothing works. Any > help would be greatly appreciated. > > author = request.session.get('author', None) > a = Author.objects.get(id=author.id) > BookFormSet = inlineformset_factory(Author, Books, extra=0) > rf = BookFormSet(instance=a) > > if request.method == 'POST': > if request.POST['submit']=='Update': > ff = BookFormSet(request.POST) > if ff.is_valid(): > instances = ff.save() > return HttpResponseRedirect('/profile/books/view/') > > Thanks! > cmiller --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Type comparisons in templates - a Django wart?
I read the following snippet with interest: http://www.djangosnippets.org/snippets/1010/ I am trying to lock that tightly into brain as I can imagine being tripped up by that and ending up completely confused as to why my code doesn't work. Does anyone else think that there should be an elegant way to deal with comparing different types in a template? I almost wonder if we need to either: a) implicitly coerce types or b) throw an exception (or at least log a warning) The current behaviour turns Python into a loosely typed language in the worst possible way. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Problem with global variables in modules
Hello, this is more a python-specific problem then a django one. I have 2 modules #a.py: global filebuffer filebuffer = [] #b.py print filebuffer --> filebuffer not defined ___ Do I have to import a.py? but I want to work on the same instance of filebuffer from both modules? Any ideas? Thanks -Toni --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: new be Many to many relation question
Sorry but I didnt get it :( (Perhaps you should actually call the field user rather than user) . Could you please explain more ? I tried to do following but couldnt get user information, In [36]: p = PU.objects.all() In [37]: p Out[37]: [, ] In [38]: for i in p: : i.user.id : --- AttributeErrorTraceback (most recent call last) D:\PMO\ in () AttributeError: 'ManyRelatedManager' object has no attribute 'id' On Aug 29, 4:03 pm, Daniel Roseman <[EMAIL PROTECTED]> wrote: > On Aug 29, 7:18 am, "[EMAIL PROTECTED]" > > > > <[EMAIL PROTECTED]> wrote: > > I can get user_utilization but member.user gives me django object. How > > can I get that information? > > > In [199]: for member in prj_members: > > .: member.user > > .: member.user_utilization > > .: > > Out[199]: > at 0x016AD5 > > 70> > > Out[199]: 1.0 > > Out[199]: > at 0x016ADB > > 10> > > Out[199]: 1.0 > > > Thanks a lot > >Manoj > > Because it's a ManyToMany field, you can have muliple users associated > with one project. (Perhaps you should actually call the field user > rather than user). So the field itself returns a Manager - just like > project.objects, you have to use all() or filter() to return a > queryset or get() to return a single user. > > For now you probably just want member.user.all() > > -- > DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with global variables in modules
solved :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: new be Many to many relation question
On Aug 30, 10:54 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Sorry but I didnt get it :( > (Perhaps you should actually call the field user rather than user) . > Could you please explain more ? Sorry, that should have been "you should call the field users" - i.e. plural, because it refers to more than one user. > I tried to do following but couldnt get user information, > > In [36]: p = PU.objects.all() > > In [37]: p > Out[37]: [, ] > > In [38]: for i in p: > : i.user.id > : > --- > AttributeError Traceback (most recent call > last) > > D:\PMO\ in () > > AttributeError: 'ManyRelatedManager' object has no attribute 'id' Each 'i' has MULTIPLE users. So you can't say i.user.id, because 'user' refers to MANY users. You'll need a nested loop: for i in p: for a_user in i.user.all(): print a_user.id To be honest, all this is in the documentation. Django has some of the best docs out there for any open-source project, and the question you're asking is absolutely basic. See here, for example: http://www.djangoproject.com/documentation/db-api/#many-to-many-relationships -- DR. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Changing the AuthenticationForm username's max_length field (impossible!?)
After many frustrating hours, I have yet to monkey patch the form.username variable from: to In my urls.py file, I added: from django.contrib.auth.forms import AuthenticationForm AuthenticationForm.base_fields['username'].max_length = 75 AuthenticationForm.base_fields['username'].label = "Email" This is suggested by Julien in his post: http://groups.google.com/group/django-developers/msg/3420dc565df39fb1 I found that {{ form.username.label_tag }} will print "Email" as expected, but {{ form.username }} still prints a max_length of 30. I tested using: assert False, dir(AuthenticationForm.base_fields['username']) and indeed the max_length field is 75 (and before my code, it's 30 as expected) Why won't the maxlength html field change to 75? This perplexes me. This is using django 1.0 beta 1, but I've also tried with django 1.0 beta 2 and django svn trunk. Please advise. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 display custom messages in admin site
Hi, You want to modify these messages or add your own messages ? If it's the latter, look at here; http://www.djangoproject.com/documentation/authentication/#messages You can simply create your messages; request.user.message_set.create(message="Your message comes here") On Aug 29, 10:15 pm, Dennis Schmidt <[EMAIL PROTECTED]> wrote: > Hello everybody, > > when you do something like saving an object in the admin site this > small yellow bar on top will show up, telling you something like > "correctly saved". I'd like to display my own custom messages there. > But I couldn't find out yet how to achieve this. Can someone help me > please? > > regards, Dennis --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
Unaccountable syntax error
I'm having a problem when I try to validate my models. The interpreter somehow takes offense at this line: box_text_color = models.ColorField("Box Text Color") I'm using a custom "ColorField" here. What I don't understand is that it seems almost identical to this ColorField, which it did accept: bg_color = models.ColorField("Background Color") When it rejected it, the flow looked like this: File "/Users/leaf/Django/devsite/../devsite/djstyles/models.py", line 47 box_text_color = models.ColorField("Box Text Color") ^ SyntaxError: invalid syntax The caret was pointing at the r in "box_text_color". Does anyone know how this could have happened? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
photologue or: how to not escape html in the admin?
Hi, I've installed photologue recently, and it's a great app. Works like a charm... The only thing that doesn't is the thumbnail preview in the admin. I think photologue spits out the correct html: http://127.0.0.1:8000/site_media/photologue/photos/cache/DSC04668_admin_thumbnail.JPG "> But the admin interface escapes it, so I don't see any nice thumbnails, just html... How can I change this? -benjamin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Unaccountable syntax error
On Sat, Aug 30, 2008 at 9:50 AM, Leaf <[EMAIL PROTECTED]> wrote: > > I'm having a problem when I try to validate my models. The interpreter > somehow takes offense at this line: > >box_text_color = models.ColorField("Box Text Color") > > I'm using a custom "ColorField" here. What I don't understand is that > it seems almost identical to this ColorField, which it did accept: > >bg_color = models.ColorField("Background Color") > > When it rejected it, the flow looked like this: > > File "/Users/leaf/Django/devsite/../devsite/djstyles/models.py", > line 47 >box_text_color = models.ColorField("Box Text Color") >^ > SyntaxError: invalid syntax > > The caret was pointing at the r in "box_text_color". Does anyone know > how this could have happened? > What's on the line above that? That's probably where the trouble begins. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
id problem with mysql and django models
Hello, I'm using django 0.96.1 on ubuntu. I'm going to describe the steps I went through until I encountered something odd. I create a model: class shoutbox(models.Model): name = models.CharField(maxlength=15) shout = models.CharField(maxlength=256) pub_date = models.DateTimeField() Next I sync with my database which is mysql using manage.py syncdb. Then I enter the manage.py shell to test it out In [1]: from thisSite.shoutbox.models import shoutbox In [4]: s = shoutbox('jonas', 'bla enzo', datetime.now()) untill here everhting works fine then I want to check on the id of s and here is what it returns In [5]: s.id Out[5]: 'jonas' so I add an other param, like 1 and it works fine, seems like none doesn't get accepted. What should I do ? Is this a bug ? Did I do something wrong ? I don't want to hardcode every id when I enter some new data to my tables. Regards eniac --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: locale name conflict (deploy issue)
oh sh*t, that was it! So stupid :) Thanks! On 24 Aug, 21:01, msaelices <[EMAIL PROTECTED]> wrote: > Maybe you have an __init__.py inside locale directory? > > On 16 ago, 13:12, dcoy <[EMAIL PROTECTED]> wrote: > > > Hi, > > > I'm trying to deploy my django project to my VPN (CentOS 5 python > > 2.4). I'm having ALL kinds of issues, nothing seems to work after > > following the steps in the installation documentation at > > djangoproject.com. Anyways now I've tracked down an issue that I don't > > really know how to solve: > > > When running "# python manage.py" at my django project root I get: > > . > > File "/usr/lib/python2.4/gettext.py", line 128, in _expand_lang > > from locale import normalize > > ImportError: cannot import name normalize > > > So after some investigation I realize that it is my locale directory > > under $PROJECTPATH that screw things up since it is first in the > > sys.path(s). > > > My locale is set up according to django i18n doc as > > # $PROJECTPATH/locale//LC_MESSAGES/django.(po|mo) > > but when gettext.py is trying to import from locale it is looking at > > my project locale, not in the /usr/lib/python2.4/locale.py. > > > I confirmed this by temporarily renaming my $PROJECTPATH/locale. > > > Can someone help me out? I don't know the correct course to take here. > > > Thanks, > > Calle > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Unaccountable syntax error
Of course. I just look at the error actually occurs on, not the context. I guess even Python's awesome debugging still has limits. What happened was that I forgot a parenthesis at the end of the previous line. Thanks for giving me the tip. On Aug 30, 9:57 am, "Karen Tracey" <[EMAIL PROTECTED]> wrote: > On Sat, Aug 30, 2008 at 9:50 AM, Leaf <[EMAIL PROTECTED]> wrote: > > > I'm having a problem when I try to validate my models. The interpreter > > somehow takes offense at this line: > > >box_text_color = models.ColorField("Box Text Color") > > > I'm using a custom "ColorField" here. What I don't understand is that > > it seems almost identical to this ColorField, which it did accept: > > >bg_color = models.ColorField("Background Color") > > > When it rejected it, the flow looked like this: > > > File "/Users/leaf/Django/devsite/../devsite/djstyles/models.py", > > line 47 > >box_text_color = models.ColorField("Box Text Color") > >^ > > SyntaxError: invalid syntax > > > The caret was pointing at the r in "box_text_color". Does anyone know > > how this could have happened? > > What's on the line above that? That's probably where the trouble begins. > > Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Design question, Form using two models.
Hi, Like in many projects i use User from auth and my own Profile model. Except i have several profiles so Profile just holds a generic FK relationship; And ProfileFoo model has also a user Fk pointing back to User (its cleaner than using the generic reverse realtion which gives back a list) If i need to create a form which will edit/save fields for ProfileFoo and Basic User fiedls what is the right way to do ? For now i do as follow: Forms: A BasicProfileForm model Form with firstname, lastname and email fields. A ProfileFooForm inheriting from BasicProfileForm and adding some of his own fields (using Meta) View: # We will look at the update case form = ProfileForm(instance=myprofile) And in my form i intercept the instance as follow: def __init__(self, *args, **kwargs): super(ProfileFooForm, self).__init__(*args, **kwargs) if kwargs.has_key('instance'): profileFoo = kwargs['instance'] self.fields['bla'].initial = profileFoo.user.bla self.fields['bli'].initial = profileFoo.user.bli It works well, but woudnt it be possible to do it more cleanly ? Thanks, Greg --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Photologue Error: NoReverseMatch -- Reverse for 'pl-gallery' not found.
Check out this link, apply the patch and I think you'll see the problem (basically, whatever is being passed to {% url ... %} does not match the regex in urls.py). Cheers, Tone On Aug 30, 12:25 am, Jacolyte <[EMAIL PROTECTED]> wrote: > Here's a pastebin of the traceback:http://pastebin.com/m43fb0960 > > Photologue is version 2.0-rc1 > > Django is version 1.0-beta_1 > > I did everything the photologue readme said. Put photologue in my > installed apps, ran syncdb, plinit, etc. everything went fine. > > I added a photo and made a gallery, and then in the admin interface > for my gallery I clicked on "View on site" and it gives me this error. > > The traceback is saying my code is trying to use a named URL pattern > that doesn't exist, right? Well, shouldn't creating a photologue > gallery create that URL that the URL pattern references? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Photologue Error: NoReverseMatch -- Reverse for 'pl-gallery' not found.
The link would help :rolls eyes: http://groups.google.com/group/django-users/browse_thread/thread/eb5db61766a5dc07/a32ec2de4bd9ff0f?lnk=gst&q=noReverseMatch#a32ec2de4bd9ff0f On Aug 30, 3:12 pm, tonemcd <[EMAIL PROTECTED]> wrote: > Check out this link, apply the patch and I think you'll see the > problem (basically, whatever is being passed to {% url ... %} does not > match the regex in urls.py). > > Cheers, > Tone > > On Aug 30, 12:25 am, Jacolyte <[EMAIL PROTECTED]> wrote: > > > > > Here's a pastebin of the traceback:http://pastebin.com/m43fb0960 > > > Photologue is version 2.0-rc1 > > > Django is version 1.0-beta_1 > > > I did everything the photologue readme said. Put photologue in my > > installed apps, ran syncdb, plinit, etc. everything went fine. > > > I added a photo and made a gallery, and then in the admin interface > > for my gallery I clicked on "View on site" and it gives me this error. > > > The traceback is saying my code is trying to use a named URL pattern > > that doesn't exist, right? Well, shouldn't creating a photologue > > gallery create that URL that the URL pattern references? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 new comments framework error
...and of course, I find that http://code.djangoproject.com/ticket/8221 is now fixed! That should help clear up an awful lot of confusion. As of r8672, it's in the trunk. Cheers, Tone On Aug 29, 7:40 am, tonemcd <[EMAIL PROTECTED]> wrote: > Also > seehttp://groups.google.com/group/django-users/browse_thread/thread/1f4b... > > Short summary: maybe your named url regexes aren't matching the > variables passed to them in the {% url ... %} tag. > > Apply the patch fromhttp://code.djangoproject.com/ticket/8221and > you'll know for certain if that's it. > > Zapping old .pyc files can't hurt too! > > Cheers, > Tone > > On Aug 29, 4:29 am, hotani <[EMAIL PROTECTED]> wrote: > > > > > Did you delete the .pyc files from the django source? Another approach > > would be to go into /django/contrib/ and delete the comments > > directory, then do an 'svn up' to restore it. Then you'll be sure to > > get a fresh copy. > > > That is what worked for me. But if you haven't used the comment system > > before then there shouldn't even be any pyc files in there, so I don't > > know what is going on. > > > On Aug 28, 2:57 am, Mark <[EMAIL PROTECTED]> wrote: > > > > Hi, > > > > Updated to 8613 with the release of Django 1.0 Beta 2 and saw the > > > addition of commenting framework - tried to add it and am getting a > > > similar error to above. > > > > On Aug 27, 3:54 pm, Slavus <[EMAIL PROTECTED]> wrote: > > > > > Here is the solution: > > > > You'll get this if you still have stale pyc files left over from the > > > > old comment system. Delete 'em and your code will work. > > > > I tried this (even though I did not use the old commenting system). > > > > Here is the exception information... > > > --- > > > - > > > Environment: > > > > Request Method: GET > > > Request URL:http://localhost/apps/buildboard/builddetails/80/ > > > Django Version: 1.0-beta_1-SVN-unknown > > > Python Version: 2.5.1 > > > Installed Applications: > > > ['django.contrib.auth', > > > 'django.contrib.contenttypes', > > > 'django.contrib.sessions', > > > 'django.contrib.sites', > > > 'django.contrib.admin', > > > 'django_apps.buildboard', > > > 'django_xmlrpc', > > > 'django.contrib.comments'] > > > Installed Middleware: > > > ('django.middleware.common.CommonMiddleware', > > > 'django.contrib.sessions.middleware.SessionMiddleware', > > > 'django.contrib.auth.middleware.AuthenticationMiddleware', > > > 'django.middleware.doc.XViewMiddleware') > > > > Template error: > > > In template c:\_tools\python251\lib\site-packages\django\contrib > > > \comments\templates\comments\form.html, error at line 2 > > > Caught an exception while rendering: Reverse for ' > > post_comment at 0x0158BEF0>' not found. > > > 1 : {% load comments %} > > > > 2 : > > > > 3 : {% for field in form %} > > > > 4 : {% if field.is_hidden %} > > > > 5 : {{ field }} > > > > 6 : {% else %} > > > > 7 : > > > 8 : {% if field.errors %} class="error"{% endif %} > > > > 9 : {% ifequal field.name "honeypot" %} > > > style="display:none;"{% endifequal %}> > > > > 10 : {% if field.errors %}{{ field.errors }}{% endif %} > > > > 11 : {{ field.label_tag }} {{ field }} > > > > 12 : > > > > Traceback: > > > File "c:\_tools\python251\lib\site-packages\django\core\handlers > > > \base.py" in get_response > > > 86. response = callback(request, *callback_args, > > > **callback_kwargs) > > > File "c:\_tools\python251\lib\site-packages\django\contrib\auth > > > \decorators.py" in __call__ > > > 67. return self.view_func(request, *args, **kwargs) > > > File "c:\_projects\django_apps\..\django_apps\buildboard\views.py" in > > > build_details > > > 309. print t.render(c) > > > File "c:\_tools\python251\lib\site-packages\django\template > > > \__init__.py" in render > > > 176. return self.nodelist.render(context) > > > File "c:\_tools\python251\lib\site-packages\django\template > > > \__init__.py" in render > > > 756. bits.append(self.render_node(node, context)) > > > File "c:\_tools\python251\lib\site-packages\django\template\debug.py" > > > in render_node > > > 71. result = node.render(context) > > > File "c:\_tools\python251\lib\site-packages\django\contrib\comments > > > \templatetags\comments.py" in render > > > 158. formstr = render_to_string(template_search_list, > > > {"form" : self.get_form(context)}, context) > > > File "c:\_tools\python251\lib\site-packages\django\template\loader.py" > > > in render_to_string > > > 107. return t.render(context_instance) > > > File "c:\_tools\python251\lib\site-packages\django\template > > > \__init__.py" in render > > > 176. return self.nodelist.render(context) > > > File "c:\_tools\python251\lib\site-packages\django\template > > > \__init__.py" in re
Admin styles disappeared
Yes, they did. After upgrading to the newer version of Django, I lost all styles for the admin site. When I tried to access the stylesheet it was trying to access, I got a 403 Forbidden error. (I'm using OS X's built-in Apache server to serve the admin media.) Is it necessary for me to use an alternate Web server to serve the admin media? If not, how can I get it to set up properly so I can have my shiny blue theme back? Regards, Leaf --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
How to create a list of months from a date field.
I'm basically trying to create a standard archive function. I have the following field in my models:entry_date = models.DateField(auto_now_add=True) I understand dynamic urls and templates and things, so i don't need help with that. What i need to know is how can i get a list of months which have entries in them, I'd apperciate any help. Thanks Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Space added when including URLs
I'm testing a styles app, and I tried this URL: http://localhost:8000/styles/css/test-style/ When I did that, it responded with a 404 error. It said it checked against the URLConfs I had included, which were: # /devsite/urls.py urlpatterns = patterns('', # Example: # (r'^devsite/', include('devsite.foo.urls')), # Uncomment the next line to enable admin documentation: (r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: (r'^admin/(.*)', admin.site.root), # dj.styles (r'^styles/', include('devsite.djstyles.urls')),) # /devsite/djstyles/urls.py urlpatterns = patterns('devsite.djstyles.views', (r'css/(?P
Re: photologue or: how to not escape html in the admin?
Okay, I've got it! > I've installed photologue recently, and it's a great app. > Works like a charm... > > The only thing that doesn't is the thumbnail preview in the admin. > I think photologue spits out the correct html: > > src="http://127.0.0.1:8000/site_media/photologue/photos/cache/DSC04668_admin_thumbnail.JPG > > "> > > But the admin interface escapes it, so I don't see any nice > thumbnails, just html... > > How can I change this? The 'list_display' string in question is a method of a model, those are automatically escaped by django. But you can set it to allow tags like this: admin_thumbnail.allow_tags = True See here: http://www.djangoproject.com/documentation/admin/#list-display -benjamin --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 create a list of months from a date field.
djandrow wrote: > I understand dynamic urls and templates and things, so i don't need > help with that. What i need to know is how can i get a list of months > which have entries in them, I'd apperciate any help. Use generic date-based view (under django.views.generic.date_based.) and see `date_list` context variable. -- Happy Hacking. http://sphinx.net.ru む --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: photologue or: how to not escape html in the admin?
On Sat, 2008-08-30 at 15:52 +0200, Benjamin Buch wrote: > Hi, > > > I've installed photologue recently, and it's a great app. > Works like a charm... > > > The only thing that doesn't is the thumbnail preview in the admin. > I think photologue spits out the correct html: > > > src="http://127.0.0.1:8000/site_media/photologue/photos/cache/DSC04668_admin_thumbnail.JPG";> > > > But the admin interface escapes it, so I don't see any nice > thumbnails, just html... > > > How can I change this? Read the documentation about autoescaping in the template docs for Python programmers. Basically, whatever method is producing that string needs to wrap it in a call to django.utils.safestring.mark_safe() (and be very careful that the user-supplied data really is safe to put into an HTML form, so possibly pass it through django.util.http.urlquote as well). Regards, Malcolm > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Core keyword error
Thank you guys for saving my follicles. I completely trusted the backward incompatible changes page so far, but now it miserably failed :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: id problem with mysql and django models
On Sat, 2008-08-30 at 06:56 -0700, eniac wrote: > Hello, > > I'm using django 0.96.1 on ubuntu. > I'm going to describe the steps I went through until I encountered > something odd. > > I create a model: > > class shoutbox(models.Model): > name = models.CharField(maxlength=15) > shout = models.CharField(maxlength=256) > pub_date = models.DateTimeField() > > Next I sync with my database which is mysql using manage.py syncdb. > > > Then I enter the manage.py shell to test it out > > In [1]: from thisSite.shoutbox.models import shoutbox > In [4]: s = shoutbox('jonas', 'bla enzo', datetime.now()) > > untill here everhting works fine > then I want to check on the id of s and here is what it returns > In [5]: s.id > Out[5]: 'jonas' > > so I add an other param, like 1 and it works fine, seems like none > doesn't get accepted. > What should I do ? Is this a bug ? Did I do something wrong ? I don't > want to hardcode every id when I enter some new data to my tables. It's not a bug. You are assuming that you can pass position arguments to your model (which would be true if the only arguments taken by __init__ were the fields you declared). This isn't true, since are some implicit fields created by Django: for example, the automatic primary key field "id". That's why none of the examples in the documentation use positional arguments. So you should always use keyword arguments when initialising a model: shoutbox(name='jonas', shout='...', pub_date='...') or data = {'name': 'jonas', 'shout': '...', 'pub_date': '...'} s = shoutbox(**data) Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Space added when including URLs
On Sat, 2008-08-30 at 09:08 -0700, Leaf wrote: > I'm testing a styles app, and I tried this URL: > > http://localhost:8000/styles/css/test-style/ > > When I did that, it responded with a 404 error. It said it checked > against the URLConfs I had included, which were: [...] >1. ^admin/doc/ >2. ^admin/(.*) >3. ^styles/ css/(?P
Having trouble creating admin form using TabularInline
My model has 3 main classes, School, Contest, Participant. School contains the following fields: school_name, slug, nickname. Contest contains the following fields: date_scheduled, title, notes. Participant contains the following fields: contest (foreign key), school (foreign key), score I want my Contest admin form to contain a tabular list of 2 participants. I've added the following line to my ContestAdmin class: inlines = [ParticipantInline] But where do I put my ParticipantInline class? If I put it before the ContestAdmin class, I get an error that Participant can't be found because my Participant class comes after the ContestAdmin class. If I put it after the ContestAdmin class, I get an error with the ContestAdmin class with the inlines = [ParticpiantInline] Here's my complete model.py: class School(models.Model): school_name = models.CharField(max_length=50) mascot = models.CharField(max_length=50) def __unicode__(self): return self.school_name admin.site.register(School) class Contest(models.Model): date_scheduled = models.DateField() title = models.CharField(max_length=50) def __unicode__(self): return self.title class ContestAdmin(admin.ModelAdmin): inlines = [ParticipantInline] admin.site.register(Contest, ContestAdmin) class Participant(models.Model): contest = models.ForeignKey(Contest) school = models.ForeignKey(School) score = models.PositiveIntegerField() class ParticipantInline(admin.TabularInline): model = Participant extra = 2 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 create a list of months from a date field.
I've had alook through http://www.djangoproject.com/documentation/generic_views/ but i'm still not clear on what to do. I might be being a bit think but could someone explain it to me. Regards, Andrew On Aug 30, 5:59 pm, Dmitry Dzhus <[EMAIL PROTECTED]> wrote: > djandrow wrote: > > I understand dynamic urls and templates and things, so i don't need > > help with that. What i need to know is how can i get a list of months > > which have entries in them, I'd apperciate any help. > > Use generic date-based view (under django.views.generic.date_based.) and > see `date_list` context variable. > -- > Happy Hacking. > > http://sphinx.net.ru > む --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Having trouble creating admin form using TabularInline
On Sat, Aug 30, 2008 at 2:04 PM, jeffself <[EMAIL PROTECTED]> wrote: > > My model has 3 main classes, School, Contest, Participant. > > School contains the following fields: school_name, slug, nickname. > Contest contains the following fields: date_scheduled, title, notes. > Participant contains the following fields: contest (foreign key), > school (foreign key), score > > I want my Contest admin form to contain a tabular list of 2 > participants. I've added the following line to my ContestAdmin class: > inlines = [ParticipantInline] > > But where do I put my ParticipantInline class? If I put it before the > ContestAdmin class, I get an error that Participant can't be found > because my Participant class comes after the ContestAdmin class. If I > put it after the ContestAdmin class, I get an error with the > ContestAdmin class with the inlines = [ParticpiantInline] > > Here's my complete model.py: > > class School(models.Model): >school_name = models.CharField(max_length=50) >mascot = models.CharField(max_length=50) > >def __unicode__(self): >return self.school_name > > admin.site.register(School) > > class Contest(models.Model): >date_scheduled = models.DateField() >title = models.CharField(max_length=50) > >def __unicode__(self): >return self.title > > class ContestAdmin(admin.ModelAdmin): >inlines = [ParticipantInline] > > admin.site.register(Contest, ContestAdmin) > > class Participant(models.Model): >contest = models.ForeignKey(Contest) >school = models.ForeignKey(School) >score = models.PositiveIntegerField() > > class ParticipantInline(admin.TabularInline): >model = Participant >extra = 2 > Don't intermix model and admin definitions. The recommended way is to put model definitions in models.py and admin definitions in admin.py. Then admin.autodiscover() in urls.py will load your app's admin.py and the registrations will get done once (having them in models.py risks reigstration errors if/when your models.py gets loaded more than once). This will also solve your ordering problem. Karen --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Translating Model Form Error Messages
Hi, I'm working on a non-English site and need to replace the validation messages from ModelForm (e.g. 'This field is required.') What are some approaches that I can take? 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?hl=en -~--~~~~--~~--~--~---
Re: Type comparisons in templates - a Django wart?
On 30 août, 11:41, AndyB <[EMAIL PROTECTED]> wrote: > I read the following snippet with > interest:http://www.djangosnippets.org/snippets/1010/ > > I am trying to lock that tightly into brain as I can imagine being > tripped up by that and ending up completely confused as to why my code > doesn't work. Then you'd be tripped up and ends up completly confused by any raw python code. Did you ever tried comparing a string and an int in Python ??? > Does anyone else think that there should be an elegant way to deal > with comparing different types in a template? This is already the case : the ifequal tag relies on Python's equality testing, which is defined by the classes of the two objects to be compared. http://docs.python.org/ref/customization.html > I almost wonder if we > need to either: > a) implicitly coerce types yuck. > or b) throw an exception (or at least log a warning) Why so ? > The current behaviour turns Python into a loosely typed language in > the worst possible way. I'm not sure I get your point here... The "current behaviour" of ifequal is actually the the current behaviour of Python's equality testing. Python 2.5.1 (r251:54863, Apr 6 2008, 17:20:35) [GCC 4.1.2 (Gentoo 4.1.2 p1.0.2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> if "1" == 1: print "never" ... >>> Also and FWIW, the use case (hem...) mentionned in the django-snippet you linked to is IMHO a design smell. Such a test has nothing to do in a template. My 2 cents... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Translating Model Form Error Messages
On Sat, 2008-08-30 at 12:57 -0700, Aaron wrote: > Hi, I'm working on a non-English site and need to replace the > validation messages from ModelForm (e.g. 'This field is required.') > What are some approaches that I can take? All those strings should already be translated. They're defined in django/forms/fields.py and you can see they're all marked for translation. So providing you are using the LocaleMiddleware (or some other way of setting the locale), the messages will appear naturally in the active locale for each viewer. If you want to replace/change the messages entirely, you need to replace them on the instances of the field classes. This would require some poking about under the hood for ModelForms, but should be possible. For normal forms, you can pass in an error_messages dictionary when you specify the form field that controls the messages. Again, have a look at django/forms/fields.py for how the default setup is done. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Translating Model Form Error Messages
Hi Malcolm, Thanks for the info. It'll save me a lot of time, now that I know where to look. Aaron On Aug 30, 1:03 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sat, 2008-08-30 at 12:57 -0700, Aaron wrote: > > Hi, I'm working on a non-English site and need to replace the > > validation messages from ModelForm (e.g. 'This field is required.') > > What are some approaches that I can take? > > All those strings should already be translated. They're defined in > django/forms/fields.py and you can see they're all marked for > translation. So providing you are using the LocaleMiddleware (or some > other way of setting the locale), the messages will appear naturally in > the active locale for each viewer. > > If you want to replace/change the messages entirely, you need to replace > them on the instances of the field classes. This would require some > poking about under the hood for ModelForms, but should be possible. For > normal forms, you can pass in an error_messages dictionary when you > specify the form field that controls the messages. Again, have a look at > django/forms/fields.py for how the default setup is done. > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Type comparisons in templates - a Django wart?
> Then you'd be tripped up and ends up completly confused by any raw > python code. Did you ever tried comparing a string and an int in > Python ??? Doh. I knew that. For some reason the fact that it was template code sent my brain to sleep. > > Does anyone else think that there should be an elegant way to deal > > with comparing different types in a template? > > This is already the case : the ifequal tag relies on Python's equality > testing, which is defined by the classes of the two objects to be > compared. > > http://docs.python.org/ref/customization.html > > > I almost wonder if we > > need to either: > > a) implicitly coerce types > > yuck. Agreed > > or b) throw an exception (or at least log a warning) > > Why so ? > > > The current behaviour turns Python into a loosely typed language in > > the worst possible way. > > I'm not sure I get your point here... The "current behaviour" of > ifequal is actually the the current behaviour of Python's equality > testing. My point was muddled (next time - think>post instead of post>think...) However. The fact we are in Django's template language with less of the niceties of Python does change things. We can't explicitly cast types so what should we do? > Also and FWIW, the use case (hem...) mentionned in the django-snippet > you linked to is IMHO a design smell. Such a test has nothing to do in > a template. I'd be interested to read exactly what the design smell is here. Could you elaborate? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Problem with global variables in modules
On 30 août, 11:46, mwebs <[EMAIL PROTECTED]> wrote: > Hello, > this is more a python-specific problem then a django one. Then please post it on c.l.py. > I have 2 modules > > #a.py: > > global filebuffer > filebuffer = [] You don't need the global keyword at the top-level of a module. You only need it within a function. > #b.py > > print filebuffer > --> filebuffer not defined Not a problem here, but it's usually better to post the whole traceback. > Do I have to import a.py? Even importing "a" wouldn't be enough to solve your problem. You'd still have to use a fully qualified name (ie : "a.filebuffer"). The point is that there's no such thing as a global namespace in Python. Python's "global" really means "module level". > but I want to work on the same instance of > filebuffer from both modules? cf above. But for your own sake, *don't* do that, never, ever. Avoid mutable module-level variables whenever possible, and always treat module-level variables of another module as read-only - unless you *really* know what you're doing, of course, but even then... FWIW, I have 8+ years experience with Python, I wrote 50+ klocs python programs using each and every "advanced" stuff like decorators, metaclasses and custom descriptors, and I could write a book about Python's object model. I still stick to the above rules as a general guideline. > Any ideas? Yes : learn Python. Seriously. Django is a heck of a good *framework*, but it's not a *language*. The language is Python, and you'd better learn how it works before you shoot yourself in the foot (and blow the whole leg by the same occasion). My 2 cents... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Type comparisons in templates - a Django wart?
On 30 août, 22:17, AndyB <[EMAIL PROTECTED]> wrote: > (next time - think>post instead of post>think...) Lol. Don't worry, we all face the same problem one day or another... > However. The fact we are in Django's template language with less of > the niceties of Python does change things. We can't explicitly cast > types so what should we do? restrict ourselves from writing application logic in templates ?-) > > > > Also and FWIW, the use case (hem...) mentionned in the django-snippet > > you linked to is IMHO a design smell. Such a test has nothing to do in > > a template. > > I'd be interested to read exactly what the design smell is here. Could > you elaborate? The use case I'm talking about is this one: {% ifequal request.GET.key object.id %} never {% endifequal %} This is obviously (to me at least) application logic, that should be handled in the view (or any other part(s) of the controller), not in the template. Python is a dynamic language that let you add any arbitrary attribute to an object on the fly, so it should be the view's responsability to mark 'object' as being somehow "special" by adding a corresponding attribute before passing it to the template. Then the template should only have to look for this attribute. My 2 cents... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
admin deployment
http://127.0.0.1:8000/admin/ works fine, and under fcgi other things work and https:admin/ gives me the admin login screen (without css formatting). But in response to the Log in button it directs to https:///admin/ which fails because the server only directs URLS beginning with https://https:/ to my fcgi process. Fiddling with ADMIN_MEDIA_PREFIX only broke local admin interface css formatting. How do I tell the server to respond to /admin/..., not just / admin/...? Using django 0.97 with apache deployment server and django local server. It would be nice to know the right ADMIN_MEDIA_PREFIX for the server, but that's not the main problem. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: id problem with mysql and django models
Thanks for the advice ! Everhting seems to work fine now. Only when I enter s.id it return nothing and when I print s.id it returns None. Guess that's normal since the s-object hasn't been saved yet ? On Aug 30, 7:13 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Sat, 2008-08-30 at 06:56 -0700, eniac wrote: > > Hello, > > > I'm using django 0.96.1 on ubuntu. > > I'm going to describe the steps I went through until I encountered > > something odd. > > > I create a model: > > > class shoutbox(models.Model): > > name = models.CharField(maxlength=15) > > shout = models.CharField(maxlength=256) > > pub_date = models.DateTimeField() > > > Next I sync with my database which is mysql using manage.py syncdb. > > > Then I enter the manage.py shell to test it out > > > In [1]: from thisSite.shoutbox.models import shoutbox > > In [4]: s = shoutbox('jonas', 'bla enzo', datetime.now()) > > > untill here everhting works fine > > then I want to check on the id of s and here is what it returns > > In [5]: s.id > > Out[5]: 'jonas' > > > so I add an other param, like 1 and it works fine, seems like none > > doesn't get accepted. > > What should I do ? Is this a bug ? Did I do something wrong ? I don't > > want to hardcode every id when I enter some new data to my tables. > > It's not a bug. You are assuming that you can pass position arguments to > your model (which would be true if the only arguments taken by __init__ > were the fields you declared). This isn't true, since are some implicit > fields created by Django: for example, the automatic primary key field > "id". That's why none of the examples in the documentation use > positional arguments. > > So you should always use keyword arguments when initialising a model: > > shoutbox(name='jonas', shout='...', pub_date='...') > > or > > data = {'name': 'jonas', 'shout': '...', 'pub_date': '...'} > s = shoutbox(**data) > > Regards, > Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Anyone want to join in a cool new project as a hobby
Hi all, I'm building a website (www.meprice.com) to help consumers discuss, share, and seek pricing information for service-related transactions. The goal is to create pricing transparency for consumers to empower them to make better spending decisions and avoid being exploited by providers. The site is supported with ads to cover the cost but the goals are well beyond profit making. Think of it as wiki / craigslist for pricing information. I need help from django / python developer to help me take the site to the next level; there are several enhancements that are necessary to make it the product more usable and marketable. I'd only want a small part time commitment of 5-10 hours a week for now so think of it as a hobby with the goal of helping people. I'd reward you with a percentage of the proceeds if the site takes off. Happy labor day everyone Sandeep --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Weird ImproperlyConfigured error
Hi, I've spent a couple hours trying to debug this, in vain... I'm setting up a very simple site. In that site I've copied/pasted the flatpages app to be able to extend it at will (I call the new app 'staticpages'). Everything works fine on the local machine running with the dev server. But when I run the site on the production server with Apache, nothing works at all and I get: mod_wsgi (pid=12338): Exception occurred processing WSGI script '/ MYPATH/myproject.wsgi'. Traceback (most recent call last): File "/MYPATH/django/core/handlers/wsgi.py", line 194, in __call__ self.load_middleware() File "/MYPATH/django/core/handlers/base.py", line 40, in load_middleware raise exceptions.ImproperlyConfigured, 'Error importing middleware %s: "%s"' % (mw_module, e) ImproperlyConfigured: Error importing middleware staticpages.middleware: "No module named widgets" Only removing that middleware from the MIDDLEWARE_CLASSES setting gets rid of the error. I thought it was due to some stale *.pyc files, but I started from a clean checkout and the problem persists. I really don't understand where it's trying to import that 'widgets' module. Certainly not from the middleware module, which is the same as the flatpage's one: http://code.djangoproject.com/browser/django/trunk/django/contrib/flatpages/middleware.py The traceback is really not helpful. Would you have any hint to debug this? Thanks a lot! Julien --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 http header information in settings.py
Thanks Graham. I guess I won't be hiking that trail. On Aug 29, 6:40 pm, Graham Dumpleton <[EMAIL PROTECTED]> wrote: > On Aug 30, 12:20 am, Greg Fuller <[EMAIL PROTECTED]> wrote: > > > Thanks for the replies. > > > I like the middleware solution, if you can modify settings variables > > during middleware processing. The documentation warns against altering > > settings at runtime. > > > What are the consequences of ignoring the warning? > > You can't use middleware approach to modify stuff in settings module > as I believe the information is only pulled from there on first > initialisation of Django. So, middleware can only work where it > doesn't involve changing settings values. That is, where the handler > code itself acts based on the derived values and not the underlying > Django engine. Only exception would be if components being used allow > you to override stuff pulled from settings on a per request basis. > > Graham > > > Eric, I don't think setting up multiple projects would work well in > > this case. I didn't make it clear in my original post, but there > > would be more than two sites, more than 2 template directories, and > > possibly other settings based on http header information. The variety > > of possible combinations might get a little unweildy and require too > > many instances of django. > > > Graham: Wow, that is a lot :). In addition to what I mentioned above, > > I would like all this to be as easy as possible to configure (the > > software will be distributed). > > > --Greg > > > On Aug 29, 8:00 am, Graham Dumpleton <[EMAIL PROTECTED]> > > wrote: > > > > On Aug 29, 8:50 pm, Erik Allik <[EMAIL PROTECTED]> wrote: > > > > > For the iPhone templates issue, I'd set up two projects instead of one > > > > -- one for regular browsers, one for the iPhone. Then I'd simply > > > > redirect from the regular one to the iPhone one as needed. Although > > > > this has the negative side effect of having more than one URL per > > > > resource, but you could also customize content visibility. > > > > > Same for the second example -- normally one project is set up per > > > > domain. > > > > > Erik > > > > > On 29.08.2008, at 1:24, Greg Fuller wrote: > > > > > > I would like a way to to adjust settings based on information in the > > > > > http header. I've seen a similar question asked before, but I don't > > > > > need all the django request object, just the http header information. > > > > > More specifically, user_agent, http_host, and path_info. > > > > > > Here are two examples of the sort of things I would like to do: > > > > > > # use iphone template if appropriate > > > > > if http_header['USER_AGENT'].find('iphone'): > > > > > TEMPLATE_DIRS = ( > > > > > os.path.join(cur_dir_path, 'template_sets/' + 'iphone'), > > > > > > # set SITE_ID for MyOtherDomain.com > > > > > if http_header["HTTP_HOST"].find('myotherdomain.com'): > > > > > SITE_ID = 2 > > > > > > Does anyone know if this can be done? > > > > I am reasonably sure both of you could do what you want using > > > mod_wsgi. That is based on user agent map to different instances of > > > Django where only difference is the settings file that was used. > > > Importantly, in the process using the same host name and URLs. > > > > I'll explain how to setup Apache configuration etc, but will not be > > > surprised if I loose you along the way. :-) > > > > First off, for this example I'll use daemon mode of mod_wsgi. What we > > > will do here is create two distinct mod_wsgi daemon process groups to > > > hold the two Django instances. I'll show it as two single but > > > multithreaded processes (ie., the default), but you can change that. > > > > WSGIDaemonProcess config-1 display-name=%{GROUP} > > > WSGIDaemonProcess config-2 display-name=%{GROUP} > > > > With display-name option, these show separately in 'ps' output as: > > > > 70 2802 2800 0 0:00.01 ?? 0:00.01 (wsgi:config-1) -D > > > FOREGROUND > > > 70 2803 2800 0 0:00.01 ?? 0:00.01 (wsgi:config-2) -D > > > FOREGROUND > > > > Am then going to force the main interpreter in each process to be used > > > for handling any requests. This is actually to make it easier as need > > > to name the interpreter within the processes for next step. > > > > WSGIApplicationGroup %{GLOBAL} > > > > What we want to do now is setup each of those two process with > > > different environment. Specifically, we want to set > > > DJANGO_SETTINGS_MODULE environment variable to be different for each. > > > Normally we do this in the WSGI script file, but we will only have one > > > WSGI script file and no way to determine what to make the setting when > > > WSGI script file is first loaded. What we instead do is use ability to > > > preload a script file when processes are started. > > > > WSGIImportScript /Users/grahamd/Sites/config-1.wsgi \ > > > process-group=config-1 application-group=%{GLOBAL} > > > > WSGIImportScript /Users
regroup tag
how do i do a regroup under a regroup for example: Male: o George Bush o Bill Clinton Female: o Margaret Thatcher o Condoleezza Rice Unknown: o Pat Smith and then add another regroup for the age: Male: age:40+ o George Bush o Bill Clinton age:18-39 person person Female: age:40+ o Margaret Thatcher o Condoleezza Rice age:18-39 person person the actual regrouping (not calculating the age groups) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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: Getting things into entries
>> > That's a really bad idea. Users can bring the whole site down with > malformed content if you do it like that. > > At least you should do something like that: > > try: >usercontent = render_to_string('whatever.html', {...}) > except TemplateSynatxError: # maybe other exceptions? >usercontent = '' > > render_to_response('main.html', { > 'usercontent': usercontent, > }) > Dude, chill out. There are all sorts of things I could have put in there. I believe in pointing people in the right direction, not writing their code for them. If he's not already doing error trapping, he'd have to learn the hard way anyway. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---
recursive templates
I am trying to create a contents list using the following sidebar_sub_contents.html. {% for content in contents %} {% if content.link %} {{ content.name }} {% endif %} {% if content.list %} {% with content.list as contents %} {% include 'sidebar_sub_contents.html' %} {% endwith %} {% endif %} {% endfor %} The problem is that I get a maximum recursion runtime error. Even if I change the "if content.list" tag to a 'ifequal "0" "1"', I still get a max recursion error, suggesting that the template language is executed even if the conditions are not met. This doesn't seem right. I'm running python2.5 through mod_python on ubuntu (hardy heron), with the latest django trunk (8752) 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: recursive templates
On Sat, 2008-08-30 at 20:33 -0700, mmcduff wrote: > I am trying to create a contents list using the following > sidebar_sub_contents.html. > > {% for content in contents %} > {% if content.link %} > > {{ content.name }} > > {% endif %} > {% if content.list %} > > {% with content.list as contents %} > {% include 'sidebar_sub_contents.html' %} > {% endwith %} > > {% endif %} > {% endfor %} > > The problem is that I get a maximum recursion runtime error. Even if > I change the "if content.list" tag to a 'ifequal "0" "1"', I still get > a max recursion error, suggesting that the template language is > executed even if the conditions are not met. This doesn't seem right. Whether it seems right or not, that is what happens. The template is parsed at compile time and directives like "include" are processed then. At rendering time the various if-conditions are tested and the right branch taken. So, basically, the {% include %} tag is part of the compilation process, not part of the rendering stage. You can't do recursive includes with that tag. You will need to write your own (although I wouldn't be too surprised if somebody else has already done that) if you want to have recursive inclusions. Regards, Malcolm --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Changing the AuthenticationForm username's max_length field (impossible!?)
Keltus, The patch I mentioned in that thread solved the problem of validating the input. For the rendering of the form, you also need to patch the widget as follows: AuthenticationForm.base_fields['username'].widget.attrs['maxlength'] = 75 Note that here 'maxlength' doesn't take an underscore. Regards, Julien On Aug 30, 4:04 pm, keltus <[EMAIL PROTECTED]> wrote: > After many frustrating hours, I have yet to monkey patch the > form.username variable from: > > to > > > In my urls.py file, I added: > from django.contrib.auth.forms import AuthenticationForm > AuthenticationForm.base_fields['username'].max_length = 75 > AuthenticationForm.base_fields['username'].label = "Email" > > This is suggested by Julien in his > post:http://groups.google.com/group/django-developers/msg/3420dc565df39fb1 > > I found that {{ form.username.label_tag }} will print "Email" as > expected, but {{ form.username }} still prints a max_length of 30. > > I tested using: > assert False, dir(AuthenticationForm.base_fields['username']) > and indeed the max_length field is 75 (and before my code, it's 30 as > expected) > > Why won't the maxlength html field change to 75? This perplexes me. > > This is using django 1.0 beta 1, but I've also tried with django 1.0 > beta 2 and django svn trunk. > > Please advise. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Changing the AuthenticationForm username's max_length field (impossible!?)
As an alternative, you can also check the patch in ticket #8274 http://code.djangoproject.com/ticket/8274 It has been pushed post-1.0, but in the meantime it could be of some help for you. It gives full control on the form to use in the login view, and so allows you not to monkey-patch the code dynamically. Cheers, Julien --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 1.0 and Textmate
Has anybody taken a crack at updating the Textmate Django bundles (python and template) for version 1.0? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 SVN request.get_full_path() return main.fcgi?
When I update django SVN yestoday, about from 0.97 to 1.0 beta2, the function request.get_full_path() return wrong value sometimes. When I locate url http://domain/detail/list/, this function return /main.fcgi/ detail/list/, but should be /detail/list/. Who can tell me why? Now I have to add replace function to this value. My server config: django+fastcgi 1.4.18+fastcgi, the main.fcgi file in the public directory only has on line: export DJANGO_SETTINGS_MODULE=web.settings_fastcgi Thanks a lot. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Newbie Question - Regex Field to deal with Feet/Inches
On Fri, Aug 29, 2008 at 2:54 AM, bkev <[EMAIL PROTECTED]> wrote: > > Ronny, > > This is fabulous...thank you so very much. If you don't mind me > asking, can you give me an example of how you implemented this method > in your Class? In my case, I've defined the field as a DecimalField > type, but that brings up an error. Did you define some sort of custom > save method around that? Thank you; I really appreciate it. Nothing unusual. I'm using a FloatField to store it. person = Person.objects.get_or_create(...) person.height_in_cm = feetinch_to_cm(input) ... person.save() Ronny --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google 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 -~--~~~~--~~--~--~---