Re: newbie questions: common components in django

2009-07-19 Thread Gabriel Gunderson
On Sat, Jul 18, 2009 at 7:08 PM, online wrote: > I know i can have common stuff like this in django > > > > {% include "header.html" %} > > > blah > > > {% include "footer.html" %} > > > but it seems i need to pass data footer.html and header.html every > time i include these pages? There are

Re: never_cache doesn't work for login page

2009-07-19 Thread Ronghui Yu
Michael 写道: > On Fri, Jul 17, 2009 at 11:19 AM, Ronghui Yu > wrote: > > > > Michael 写道: >> 2009/7/17 Ronghui Yu mailto:stone...@gmail.com>> >> >> Hi, All, >> >> I have a project that have CsrfMiddleware enable, all forms >> work fine, bu

Re: never_cache doesn't work for login page

2009-07-19 Thread Ronghui Yu
That's a good idea. I'll make it the last resort if I can't figure out a better way to handle it. Thank you Eugene Mirotin ??: > Isn't adding a timestamp to the url a workaround? > I mean making all links to /login/ look like /login/?_=timestamp > This can be easily done on the client side with s

Re: Django, MySQL - bug?

2009-07-19 Thread Daniel Roseman
On Jul 18, 10:39 pm, Tomasz Zieliński wrote: > I prepared following repro case, just paste to models.py to an empty > project: > > --- > from MySQLdb import Warning as Warning > from django.db import models > import unittest > > class TestMo

Re: How redirect lightweight webserver messages?

2009-07-19 Thread fabrix
On Jul 17, 3:29 pm, Andrea Della Pietra wrote: > Django source. Server log message are send to stderr (stdout is set as a > file handler) but tee logs only stdout. Bash programming: stderr and stdout 2 file http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-3.html#ss3.6 $ python manage.py runserver &

urls.py error: unbalanced parenthesis

2009-07-19 Thread Rob B (uk)
Getting a unblanced parenthesis error with this urls setup. Not sure why. urls.py: from django.conf.urls.defaults import * from coltrane.models import Entry entry_info_dict = { 'queryset': Entry.objects.all(), 'date_field': 'pub_date', } urlpatterns = patterns('django.vi

Re: Django, MySQL - bug?

2009-07-19 Thread Tomasz Zieliński
On 19 Lip, 10:35, Daniel Roseman wrote: > > I don't know why you think it's a bug. Django's models are - by design > - not an instantaneous reflection of the database. Rather, they only > interact with the DB when you load and save them. So this is the > expected behaviour. So, should m.save() s

Re: A question about reverse url lookups for admin site in svn version

2009-07-19 Thread mrsource
I'm using the current trunk version and I have a similar issue with the reverse function: - I defined a get_urls() method for one of my models whose I have written a custom admin page. - From my view I try to reverse one of this pattern with the "admin:" prefix and it works but if I wrap the view

Re: ForeignKey model attribute value in save() method

2009-07-19 Thread onoxo
does someone have a hint on this one? On Jul 17, 5:08 pm, onoxo wrote: > how can i access ForeignKey model attribute value in save() or > __unicode__ method? > some hint will help. > > here is my model.py: > > class PhotoSetPhotoItem(models.Model): >     photo_item = models.ForeignKey('Photo', r

Re: urls.py error: unbalanced parenthesis

2009-07-19 Thread Frédéric Hébert
2009/7/19 Rob B (uk) : > > Getting a unblanced parenthesis error with this urls setup. Not sure > why. The message is pretty self-explanatory. It seems to me that you have forgotten a parenthesis after your first symbolic group named year. Frédéric > urls.py: > from django.conf.urls.defaults im

Re: Stuck re:Practical Django Projects 2nd E...

2009-07-19 Thread klaut
On Jul 18, 9:57 pm, Rob B wrote: > Huge thanks Tanja - worked a treat. > > Any ideas why the book has it the other way around? > I think it is just a typo :) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django

Re: looking for a clean, easy way to force user to change password on first login

2009-07-19 Thread pjv
thanks again. writing that login view is what i meant by re- implementing the login. my terminology is probably confusing. there is a generic login view in django.contrib.auth.views that does what you are saying, only [obviously] without the custom redirect logic that i want. i just copied and pas

Re: never_cache doesn't work for login page

2009-07-19 Thread Ronghui Yu
It proves that it is introduced by django.middleware.http.ConditionalGetMiddleware. It returns 304 when requesting the same login page, so at last the browser uses the former one. It works fine after removing this middleware. I believe this middleware cannot work with never_cache. Eugene Mirotin

Checking a User in another Table ...

2009-07-19 Thread The Danny Bos
Hey there, this should be easy, but my code just won't play along. I've let a logged in user Rate a music record. I'm saving it like so 'rating | user | record'. (Rating model) What I need to do is only display the Rating form if the logged in user hasn't rated the record yet, know what I mean.

Re: looking for a clean, easy way to force user to change password on first login

2009-07-19 Thread Ronghui Yu
How about writing a decorator? pjv ??: > thanks again. writing that login view is what i meant by re- > implementing the login. my terminology is probably confusing. there is > a generic login view in django.contrib.auth.views that does what you > are saying, only [obviously] without the custom r

Re: ForeignKey model attribute value in save() method

2009-07-19 Thread Daniel Roseman
On Jul 17, 4:08 pm, onoxo wrote: > how can i access ForeignKey model attribute value in save() or > __unicode__ method? > some hint will help. > > here is my model.py: > > class PhotoSetPhotoItem(models.Model): >     photo_item = models.ForeignKey('Photo', related_name='photoitem') >     slug = m

Re: Django, MySQL - bug?

2009-07-19 Thread Joshua Russo
2009/7/19 Tomasz Zieliński > So, should m.save() set m.id to some other value than None > or this is relaxed when Warning exception is thrown? It's the database that gives m.id a value upon a valid save. So because the record couldn't be saved it never received a value. --~--~-~--~

Re: Row-specific user permissions

2009-07-19 Thread nkulmati
Thank you Alex, this is an excellent article. On Jul 18, 5:55 pm, Alex Gaynor wrote: > On Sat, Jul 18, 2009 at 4:23 PM, nkulmati wrote: > > > Hi Django users, > > > It's been a while since I used Django, so I need an update on the > > following question. > > > Has anyone found a generic solution

Re: Django, MySQL - bug?

2009-07-19 Thread Tomasz Zieliński
On 19 Lip, 16:29, Joshua Russo wrote: > 2009/7/19 Tomasz Zieliński > > > So, should m.save() set m.id to some other value than None > > or this is relaxed when Warning exception is thrown? > > It's the database that gives m.id a value upon a valid save. So because the > record couldn't be save

Foreign key triggered some redundant SQL queries

2009-07-19 Thread aXqd
Hi, all: Recently, I linked two models ( FOO & BAR ) with a foreign key. Then I retrieved the whole records back with the following codes: 1 for item in FOO.objects.all(): 2 print item.bar.id In my opinion, the whole thing should be lazy enough. So if Line 1 got all the BAR id back, *WHY* did

Re: A question about reverse url lookups for admin site in svn version

2009-07-19 Thread Alex Gaynor
On Sun, Jul 19, 2009 at 6:03 AM, mrsource wrote: > > I'm using the current trunk version and I have a similar issue with > the reverse function: > > - I defined a get_urls() method for one of my models whose I have > written a custom admin page. > - From my view I try to reverse one of this patter

Re: Django, MySQL - bug?

2009-07-19 Thread Alex Gaynor
2009/7/19 Tomasz Zieliński : > > > > On 19 Lip, 16:29, Joshua Russo wrote: >> 2009/7/19 Tomasz Zieliński >> >> > So, should m.save() set m.id to some other value than None >> > or this is relaxed when Warning exception is thrown? >> >> It's the database that gives m.id a value upon a valid save.

Re: Foreign key triggered some redundant SQL queries

2009-07-19 Thread Alex Gaynor
On Sun, Jul 19, 2009 at 10:48 AM, aXqd wrote: > > Hi, all: > > Recently, I linked two models ( FOO & BAR ) with a foreign key. > Then I retrieved the whole records back with the following codes: > > 1 for item in FOO.objects.all(): > 2   print item.bar.id > > In my opinion, the whole thing should

Re: Non-editable (but visible) fields in admin?

2009-07-19 Thread dalembertian
Thanks for the reply, Shawn. I did find a solution to my first topic at http://www.djangosnippets.org/snippets/937/ which attend most of my needs. I think that having a 'readonly' attribute for fields would be a nice feature for the admin - providing a whole new form just because of that sounds

Re: A question about reverse url lookups for admin site in svn version

2009-07-19 Thread mrsource
Ok, I noted the same thing the reverse('admin:view_tree') works, then need a pattern to be named when self.admin_site.admin_view() decorator is used? On 19 Lug, 18:30, Alex Gaynor wrote: > On Sun, Jul 19, 2009 at 6:03 AM, mrsource wrote: > > > I'm using the current trunk version and I have a si

django-registration .missing templates?

2009-07-19 Thread Asinox
Hi guys, im trying to use the django-registration...im new with django, but i was thinking that maybe some templates are missing, like registration, login... i cant found ..but i dont know if i need to create the templates... Some help? Thanks --~--~-~--~~~---~--~

Re: Overriding admin forms

2009-07-19 Thread cornjuliox
Thanks! That helped. The slugfield is working again, although the textarea still looks broken (it works fine, though).. On Jul 18, 4:51 am, greatlemer wrote: > On Jul 17, 3:06 pm, cornjuliox wrote: > > > > > > > Hi everyone. I'm new to Django, learning things mostly through trial > > and error,

Re: django-registration .missing templates?

2009-07-19 Thread Asinox
ok, ...there no exist's :( --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to dja

Re: ForeignKey model attribute value in save() method

2009-07-19 Thread onoxo
after some debugging i find that i had a bug in filebrowser app. the code from above is ok and self.photo_set is something that i forget to remove before posting. but can you tell me how should i convert to unicode? self.slug = unicode(self.photo_set)+unicode(self.photo_item) is this ok? On Jul

Re: urls.py error: unbalanced parenthesis

2009-07-19 Thread Gabriel Gunderson
On Sun, Jul 19, 2009 at 4:02 AM, Rob B (uk) wrote: >         (r'^(?P\d{4}/, 'archive_year', entry_info_dict, This named regular-expression group is missing a ")" It should be: (?P\d{4}) http://docs.djangoproject.com/en/dev/topics/http/urls/#named-groups Best, Gabe --~--~-~--~~

Using Django's Cache

2009-07-19 Thread WilsonOfCanada
Hellos, I was wondering if I can use Django caching system to store .txt or .img files on the client side (as temp file). I want to use javascript to use them later so it would not require to transfer files from the server again. The txt files are just list so there is nothing about security, b

Re: Using Django's Cache

2009-07-19 Thread Alex Gaynor
On Sun, Jul 19, 2009 at 1:05 PM, WilsonOfCanada wrote: > > Hellos, > > I was wondering if I can use Django caching system to store .txt > or .img files on the client side (as temp file).  I want to use > javascript to use them later so it would not require to transfer files > from the server again

Change default queryset in admin for a model

2009-07-19 Thread Some Guy
I was wondering if it's possible to have an admin page always show a filtered (or other non-default) queryset? i.e. I would like the default admin page to show a queryset without any rows that have a particular boolean field set to false. I've looked in the admin views.py, but haven't found anyt

Re: Change default queryset in admin for a model

2009-07-19 Thread Some Guy
In an attempt to answer my own question... Would a custom manager be able to do this? I've never done one, but could one override the all() method to filter the results that the admin receives? On Jul 19, 12:17 pm, Some Guy wrote: > I was wondering if it's possible to have an admin page always

Re: Change default queryset in admin for a model

2009-07-19 Thread Some Guy
hrmm, I found this too.. http://blog.dougalmatthews.com/2008/10/filter-the-django-modeladmin-set/ the method used is def queryset(self, request): in the model admin class... This method is not in the docs, though. Should any of these methods be preferred over the others? any advice is appreciate

Re: A question about reverse url lookups for admin site in svn version

2009-07-19 Thread Ramiro Morales
On Sun, Jul 19, 2009 at 1:53 PM, mrsource wrote: > > Ok, I noted the same thing the reverse('admin:view_tree') works, >  then need a pattern to be named when self.admin_site.admin_view() > decorator is used? > I don't think the admin_view() wrapper has anything to do with the problem you are seei

Re: Change default queryset in admin for a model

2009-07-19 Thread jeff
I'm not entirely clear what you're trying to accomplish, but in general when I hear "dummy" anything, I have to think there's a better solution. Perhaps what you're looking for is an abstract model class, from which you can subclass your two concrete ones? See http://docs.djangoproject.com/en/dev/

Re: Model Validation

2009-07-19 Thread sjtirtha
Hi, I did by mistake copy and paste the coding from my editor. But in my coding it is "User". Still I have the same error. Steve On Sun, Jul 19, 2009 at 12:36 AM, Joshua Russo wrote: > On Sat, Jul 18, 2009 at 9:03 PM, sjtirtha wrote: > >> class AbstractContent(models.Model): >> viewed

A simple use for multidb... is this possible yet?

2009-07-19 Thread Jon Loyens
Hi everyone (particularly those working on multidb), I have a pretty simple use case that involves use of multidb support and I was wondering if the code base for multidb is far enough along to help me out on this. Basically, I have a legacy enterprise db that I've created working models for usi

Re: Model Validation

2009-07-19 Thread sjtirtha
I just found the error. This is the correct code class AbstractContent(models.Model): viewed = models.PositiveIntegerField(max_length=7, blank=True, null=True) #rating = #ranking = created_by = models.ForeignKey(User, related_name="%(class)s_create

Re: A simple use for multidb... is this possible yet?

2009-07-19 Thread Alex Gaynor
On Sun, Jul 19, 2009 at 3:29 PM, Jon Loyens wrote: > > Hi everyone (particularly those working on multidb), > > I have a pretty simple use case that involves use of multidb support > and I was wondering if the code base for multidb is far enough along > to help me out on this.  Basically, I have a

Checking if user is logged in and log in form

2009-07-19 Thread AKK
Hi, i have a login form using the generic view like so: (r'^accounts/login/$', 'django.contrib.auth.views.login', {'template_name': 'blogSite/login.html'}), but i only want the form to show up if your not logged in, but since its is a generic view how can i use if not request.user.is_authentica

Re: Change default queryset in admin for a model

2009-07-19 Thread Some Guy
Thanks for the help :-) overriding queryset in modeladmin worked for the filtering. as for the subclassing of the model.. I've basically got a table with lots of columns ex.[a,b,c,d,e,f,g...] I would like to have one admin page show a,b,c,d and another that shows a,b,c,f,g based (ideally) on a

Re: Django, MySQL - bug?

2009-07-19 Thread Tomasz Zieliński
On 19 Lip, 18:32, Alex Gaynor wrote: > 2009/7/19 Tomasz Zieliński : > > > > > > > On 19 Lip, 16:29, Joshua Russo wrote: > >> 2009/7/19 Tomasz Zieliński > > >> > So, should m.save() set m.id to some other value than None > >> > or this is relaxed when Warning exception is thrown? > > >> It's the

Re: Change default queryset in admin for a model

2009-07-19 Thread Alex Gaynor
On Sun, Jul 19, 2009 at 5:07 PM, Some Guy wrote: > > Thanks for the help :-) > > overriding queryset in modeladmin worked for the filtering. > > as for the subclassing of the model.. > > I've basically got a table with lots of columns ex.[a,b,c,d,e,f,g...] > I would like to have one admin page sho

colMS and how to put stuff in sidebar??

2009-07-19 Thread sico
Hi, Using django 1.0.2 and I'd like to put some extra read-only info in a sidebar on the editing forms for specific models. coltype= colMS looks perfect for this, but how/where do I tell django what I want to put in the sidebar?? thanks, Simon --~--~-~--~~~---~--~---

Re: Foreign key triggered some redundant SQL queries

2009-07-19 Thread aXqd
在 2009-7-20,0:33,Alex Gaynor 写到: > > On Sun, Jul 19, 2009 at 10:48 AM, aXqd wrote: >> >> Hi, all: >> >> Recently, I linked two models ( FOO & BAR ) with a foreign key. >> Then I retrieved the whole records back with the following codes: >> >> 1 for item in FOO.objects.all(): >> 2 print item.ba

Re: Change default queryset in admin for a model

2009-07-19 Thread Some Guy
Thanks, I am using 1.1 beta and proxy looks like it was meant to do what I want, without a kludge. will give it a shoot On Jul 19, 3:36 pm, Alex Gaynor wrote: > On Sun, Jul 19, 2009 at 5:07 PM, Some Guy wrote: > > > Thanks for the help :-) > > > overriding queryset in modeladmin worked for the

Re: Checking if user is logged in and log in form

2009-07-19 Thread Ryan K
> urlpatterns = patterns('', > (r'^someurl/', login_required(direct_to_template), { 'template': > 'template.html', }), > ) http://groups.google.com/group/django-users/browse_thread/thread/e9f85ce0666da8c/ Cheers, Ryan http://consulting.ryankaskel.com On Jul 19, 5:31 pm, AKK wrote: > Hi, i

Re: Dict objects are unhashable errors (FOUND THE BUG anyone know why?)

2009-07-19 Thread Karen Tracey
On Thu, Jul 16, 2009 at 5:06 PM, Some Guy wrote: > > Hi Group, > I found a bug that was causing my issue (ref: > > http://groups.google.com/group/django-users/browse_thread/thread/130f36db5e95bd81 > ) > > In my urls.py I have a line ... > >(r'^diamond/(?P\d+)/$', 'object_detail', info_dict, >

Re: Checking a User in another Table ...

2009-07-19 Thread Ryan K
What exactly are your models? If you are using a ManyToMany fields you could do it Rating.objects.get(user=request.user) and see if that returns anything. Cheers, Ryan On Jul 19, 10:06 am, The Danny Bos wrote: > Hey there, this should be easy, but my code just won't play along. > > I've let a l

Redundant SQL queries regarding DELETE ALL

2009-07-19 Thread aXqd
Hi, all: I encountered another redundant SQL query problem while using django. And this time it might even cause a defect of my own program. Here is the thing. I want to do something like below: FOO.objects.filter( bar_id__exact = 5 ).delete() But what I got from mysql log are: 1 SELECT blahbl

Re: Redundant SQL queries regarding DELETE ALL

2009-07-19 Thread Alex Gaynor
On Sun, Jul 19, 2009 at 9:51 PM, aXqd wrote: > > Hi, all: > > I encountered another redundant SQL query problem while using django. > And this time it might even cause a defect of my own program. > > Here is the thing. I want to do something like below: > FOO.objects.filter( bar_id__exact = 5 ).de

customizing admin template - how to refer to specific field

2009-07-19 Thread sico
Its quite simple to customize the admin template for a specific model by creating a change_form.html in the templates/admin// / directory. But, is it possible to refer to particular fields in the model/form directly? E.g. Instead of using the loops: for fieldset in adminform: for line

Re: Redundant SQL queries regarding DELETE ALL

2009-07-19 Thread aXqd
On Mon, Jul 20, 2009 at 12:00 PM, Alex Gaynor wrote: > > On Sun, Jul 19, 2009 at 9:51 PM, aXqd wrote: >> >> Hi, all: >> >> I encountered another redundant SQL query problem while using django. >> And this time it might even cause a defect of my own program. >> >> Here is the thing. I want to do so