Selecting only published Articles

2009-05-25 Thread Alex Jonsson
Hey! In my Article model I have a pub_status which can be either 0 (draft) or 1 (published). How can I make sure that every time I try to fetch some Articles, no Articles with pub_status 0 comes along? I'm currently using a custom manager to enable Article.objects.published.all(), but that's

Re: Customized model methods

2009-02-02 Thread Alex Jonsson
On Feb 2, 9:50 pm, Daniel Roseman wrote: > You can define as many methods on a model as you like. Models are just > Python classes, and you can do anything with them that you would do > with a normal class. > > def MyModel(models.Model): >     ... field definitions

Re: Customized model methods

2009-02-02 Thread Alex Jonsson
ag_funcs = {'sports': example_func, 'personal': example_func, > >>> 'whatever': example_func } > >>> for tag_name in tag_list: > >        tag_funcs[ tag_name ]( tag_name )  # This executes the > right function from tag_funcs with input tag_name > > Hope

Customized model methods

2009-02-01 Thread Alex Jonsson
Hey guys, I'm looking to create a model method like is_(), where the tag can be used to lookup if the object is tagged with a certain ... tag. Kind of like this: A blog entry is tagged "personal" and "funny". >> blog_entry.is_sports() False >> blog_entry.is_personal() True >>

Change uploaded filename

2009-01-30 Thread Alex Jonsson
I know this question has been asked before, but I've never seen a proper answer. My situation is as follows: In our news application the editors are able to upload photos, and I'd like to change the name of these to a random 10 char md5 hash based on the current timestamp. The reason for this is

Re: Request dictionary in view

2008-12-21 Thread Alex Jonsson
Did it! Thanks a bunch. On Dec 21, 8:16 pm, Bradley Wright wrote: > Request isn't ending up in the context, try installing: > > http://docs.djangoproject.com/en/dev/ref/templates/api/#django-core-c... > > It's not enabled by default, and you need it to make request

Request dictionary in view

2008-12-21 Thread Alex Jonsson
Hey guys, I want to check the user's user agent string in a template tag, but when I try to use the request variable in the template I get a Caught an exception while rendering: Failed lookup for key [request] error message. I'm using the generic list_detail templates, is there anything special

unique_together question

2008-12-09 Thread Alex Jonsson
Hey everyone, My model looks like the following: http://dpaste.com/97293/ An album has a release date for every format, and one format can only have one release date per album. Hopefully you get what I'm trying to achieve here ;) The thing is though, that in my Album model I specify a

Re: django-tagging encoding errors

2008-12-04 Thread Alex Jonsson
Basically, we use a VPS that runs CentOS 4.7, in which Python 2.3 came preinstalled. We've been on a tight schedule and therefore haven't updated Python yet. I probably would've been better off upgrading Python though than working with this bug ... We're switching hosts within the next weeks as

Re: django-tagging encoding errors

2008-12-03 Thread Alex Jonsson
ECTED]> wrote: > On Wed, Dec 3, 2008 at 10:14 AM, Alex Jonsson <[EMAIL PROTECTED]>wrote: > > > > > > > > > Guys, I'm in trouble. > > > I'm using the django-tagging application with a Swedish news > > application. It generally works, but there's

django-tagging encoding errors

2008-12-03 Thread Alex Jonsson
Guys, I'm in trouble. I'm using the django-tagging application with a Swedish news application. It generally works, but there's one big problem which has taken me forever to solve. I've concluded that the issue lies in the http://django-tagging.googlecode.com/svn/trunk/tagging/models.py file.

Modify uploaded image

2008-11-30 Thread Alex Jonsson
Hey guys, I have an application where I want my users to be able to upload a picture. The model contains a name field and a ImageField. My question is how the easiest way would be to modify this image before saving it? That is, cropping it down to a certain size and renaming it to the person's

Paragraph modifying

2008-11-29 Thread Alex Jonsson
Hey everyone, I could use some help with my application. When I present my blog posts in my template, I would like to make the three first words of every paragraph bold. How would be the easiest way to do this? I've already declared a template tag, but I'm clueless about the code. The post is

Re: I18N not working

2008-11-25 Thread Alex Jonsson
ally found them. Oh, and I can concur that the LocaleMiddleware is not needed to translate per-app. Thank you everyone for your help! On Nov 25, 12:37 pm, Alex Jonsson <[EMAIL PROTECTED]> wrote: > I did just check the permissions, and even tried change them to a=rwx. > Still not workin

Re: I18N not working

2008-11-25 Thread Alex Jonsson
) and then made and compiled a project-wide translation. Still not working! Could it have something to do with gettext or such? I use the ugettext_lazy and my server runs Python 2.3. On Nov 25, 12:03 pm, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote: > On Tue, 2008-11-25 at 03:01 -0800, Ale

Re: I18N not working

2008-11-25 Thread Alex Jonsson
Oh, and another note. I have checked my browser language, it's set to Swedish. That works locally as well with LocaleMiddleware. On Nov 25, 12:01 pm, Alex Jonsson <[EMAIL PROTECTED]> wrote: > Thank you everyone for your feedback. > > I forgot to mention that I read that paragr

Re: I18N not working

2008-11-25 Thread Alex Jonsson
Thank you everyone for your feedback. I forgot to mention that I read that paragraph in the docs as well and already installed the LocaleMiddleware. This makes the translation of the built-in modules work, but not my per-app translations. This was why I was thinking that maybe it had something

I18N not working

2008-11-24 Thread Alex Jonsson
Hey guys, I have some problems with the translations of my website. Locally, it works flawlessly. But as soon as I run the project on my server, it won't translate. I've translated the project per app, and I'm wondering if it could have something to do with my PYTHONPATH? As of now, my .htaccess

Executing raw Python

2008-11-24 Thread Alex Jonsson
Hey everyone, I use Django together with Photologue and would like to be able to store the images on my Amazon S3 account. I've been doing a lot of thinking about how the easiest way to do this would be, and have come to the conclusion that the easiest way probably would be to upload the image

Re: Passing values to template

2008-11-17 Thread Alex Jonsson
Thanks to both of you! David's suggestion fits my application perfectly. Again, big thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to

Passing values to template

2008-11-17 Thread Alex Jonsson
Hey guys, I have a news application that I would like some help with. My view generates a list with objects mixed with dictionaries with two objects. Then in my template, I want to loop through this list and output each value. However, when it encounters a dictionary in the list I want it to

Browser detection in Django

2008-11-07 Thread Alex Jonsson
Hey guys, I'm working on a Django application where I'd like to redirect IE6 users to a specific page encouraging them to update their browser. How would be the most efficient way of doing this? Thanks! Alex --~--~-~--~~~---~--~~ You received this message