Re: access to REQUEST_URI ?

2009-08-06 Thread Alex Koshelev
Hi, Rebecca! Try to use request's `get_full_path` [1] method. It's environment independent and produces full path string with query. [1]: http://docs.djangoproject.com/en/dev/ref/request-response/#django.http.HttpRequest.get_full_path --- Alex Koshelev On Fri, Aug 7, 2009 at 1:37 AM, Rebecca

Re: is it possible to do a monkey patch on django.contrib.atuh.models.User to make the email field unique?

2009-08-04 Thread Alex Koshelev
Hi, Vasil! `Field.unique` is the read only property. If you want to set uniqueness you have to assign field's `_unique` attribute to True. --- Alex Koshelev On Wed, Aug 5, 2009 at 12:54 AM, Vasil Vangelovski <vvangelov...@gmail.com>wrote: > > Having this line of code: > > Us

Re: Template links when Django not domain root

2009-07-30 Thread Alex Koshelev
://docs.djangoproject.com/en/dev/ref/settings/#force-script-name --- Alex Koshelev On Thu, Jul 30, 2009 at 10:55 PM, Streamweaver <streamwea...@gmail.com>wrote: > > I have a django project that has worked just fine in development but > I'm trying to move it to a demo site and the application is not on

Re: where does this slug come from?

2009-07-20 Thread Alex Koshelev
hat > confuses me. > > Any suggestions? > > T > > Look at the html code itself not browser's status line output. --- Alex Koshelev --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Dja

Re: Dict objects are unhashable errors

2009-07-16 Thread Alex Koshelev
'object_detail', info_dict, > {'template': 'diamond_detail.html'}), > Please read url patterns docs [1] and answer to yourself - why you have 2 dicts in one pattern? [1]: http://docs.djangoproject.com/en/dev/topics/http/urls/#patterns --- Alex Koshelev --~--~-~--~~-

Re: Need help with URL rewrites

2009-05-25 Thread Alex Koshelev
Hi, Kevin. You can try to set FORCE_SCRIPT_NAME = '/directory' [1] settings variable. Or setup your web server to provide valid SCRIPT_NAME environment variable. [1]: http://docs.djangoproject.com/en/dev/ref/settings/#force-script-name --- Alex Koshelev On Mon, May 25, 2009 at 10:52 PM

Re: Using a subset of a queryset in a template

2009-05-13 Thread Alex Koshelev
On Wed, May 13, 2009 at 2:56 PM, Alex Rades wrote: > > Hi, > in one of my templates I'd like to show the last images taken from > a queryset. So the equivalent of: > > images.all()[:5] > > in a template. > Is there a simple way to do this? Do i need a templatetag? > Hi,

Re: Django and a basic SQL join

2009-05-06 Thread Alex Koshelev
On Wed, May 6, 2009 at 8:48 PM, jrs_66 wrote: > > Hi, > > I have 2 models... > [skip] > > e = FlattenedCategory.objects.select_related('category').filter > (member_of_category=15) > > which works... This, however, doesn't > > e = e.category > > How do I access the related

Re: "DeprecationWarning: the sets module is deprecated"

2009-05-01 Thread Alex Koshelev
You see MySQLdb warning not Django. May be you are using MySQLdb version that is not full compatible with Python 2.6 On Sat, May 2, 2009 at 1:59 AM, nbv4 wrote: > > Whenever I run the syncdb command, I get this error: > > ch...@chris-desktop:~/Websites/jobmap$ python

Re: manage.py runfcgi options

2009-04-28 Thread Alex Koshelev
Built-in help has the answers: $ ./manage.py help runfscgi On Tue, Apr 28, 2009 at 10:36 PM, Continuation wrote: > > In the doc an example of running django under fastcgi is given as: > > ./manage.py runfcgi method=threaded host=127.0.0.1 port=3033 > > > But isn't

Re: Models Aliases

2009-04-20 Thread Alex Koshelev
Hi, Bastien. I think the simple solution with property may be the best aproach if you cannot change dependent code: user = property(lambda self: self.author) On Mon, Apr 20, 2009 at 3:37 PM, Bastien wrote: > > You're right Dougal, I *should* do that I have various

Re: How to set up MySQL replication on Django?

2009-04-19 Thread Alex Koshelev
There is an existing production-ready application [1] that allows you to use MySQL replication facilities. It is formed as django database backend with some additional functional. We use it for our high-load Django powered content services. [1]:

Re: Default mimetype

2009-04-11 Thread Alex Koshelev
There is no such capabilities. Write your own set of decorators that will be path response object with needed mimetype - almost DRY solution. On Sat, Apr 11, 2009 at 10:40 AM, Roman Timushev wrote: > > Hello, > > My application serves content with different mimetypes:

Re: Flup question

2009-04-10 Thread Alex Koshelev
Flup is just a proxy library between your Django project and web-server. It is communicating with web-server through FastCGI protocol. So you cannot just start FastCGI daemon and visit you project with browser. To work properly you must set up your web-server's FastCGI capabilities and direct it

Re: RSS producing wrong link from get_absolute url

2009-04-03 Thread Alex Koshelev
Have you changed your `Site` model entry to the proper port number? On Fri, Apr 3, 2009 at 2:23 AM, John Baker wrote: > > I have a strange problem with simple RSS feeds. It works fine locally > on my development machine but when I deploy to the test server running > through

Re: Performance Issue: ForeignKey will touch database again!

2009-04-02 Thread Alex Koshelev
On Thu, Apr 2, 2009 at 10:36 AM, Zeal wrote: > > Hi, All, > [skip] > > Does every body know this issue and know how to solve it? Your any > suggestion or solution will be highly appreciated! > > Regards, > > Zeal > Documentation knows [1] [1]:

Re: ImageField on ModelForm not working - v1.0.2

2009-03-25 Thread Alex Koshelev
You don't pass request.FILES to form constructor [1] [1]: http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form On Wed, Mar 25, 2009 at 3:45 PM, Oli Warner wrote: > > I'm having a massive headache. I have a Model called companies with >

Re: Django annotate with Count() problem

2009-03-20 Thread Alex Koshelev
Try to add distinct() to query set. On Fri, Mar 20, 2009 at 10:06 PM, eli wrote: > > Hi, > > I have a problem with Django Orm annotate method.. > > My models (application: app): > > class File(models.Model): >  name = models.CharField(max_length=255) >  file =

Re: Numbering of items in template

2009-03-17 Thread Alex Koshelev
You can use `forloop.counter` with `sum` filter. Or use `ol` html tag with proper `start` attribute. On Tue, Mar 17, 2009 at 7:47 PM, Jesse wrote: > > Hello, > > I've finally gotten pagination to work.  Now I would like to add a > sequential number to the beginning of each

Re: Insert insetad edition with model form

2009-03-10 Thread Alex Koshelev
What task_id do you send when editing the entry? On Tue, Mar 10, 2009 at 3:54 PM, Dmitry Teslenko wrote: > > Hello! > > I'm starting with django framework; I use django 1.0 and sqlite > database backend. > I've stumbled upon this thing: when editing model entry with

Re: manage.py dumpdata app.model doesn't seem to work?

2009-03-06 Thread Alex Koshelev
This `dumpdata` command you can only serialize whole application not just its models. On Fri, Mar 6, 2009 at 11:17 PM, John M wrote: > > I tried using the command > > $ python manage.py dumpdata app.model. > > where app is the name of my application and model is one of

Re: count and group by aggregation

2009-03-06 Thread Alex Koshelev
Try this: R.objects.values('type').aggregate(Count('type')) On Fri, Mar 6, 2009 at 10:12 PM, kbs wrote: > > Hello, > > I got a model with a type field > > > class R(mode): >type = CharField(max_length=100) > > > Here is what im trying to do using sql notation: > > >

Re: How to compare two different types in templates using ifequal

2009-03-02 Thread Alex Koshelev
Just now {% ifequal %} doesn't support filter expressions as arguments. So you must prepare values by {% with %} tag before using them in {% ifequal %}. On Mon, Mar 2, 2009 at 12:22 PM, eli wrote: > > Hi, > > I have a problem: > > Python: > week = [1, 2, 3, 4, 5, 6,

Re: Manually parsing a URL and returning the view name and args

2009-02-27 Thread Alex Koshelev
Of course within `reverse` function there is `resolve` function that parses path and return view function, positional arguments, and named arguments. On Fri, Feb 27, 2009 at 2:33 PM, Andrew Ingram wrote: > > Hi All, > > I'm trying to to build a model which can store a

Re: Can QuerySet methods combine filters with an "OR" conjunction?

2009-02-21 Thread Alex Koshelev
You have to use `Q` objects [1] [1]: http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects On Sat, Feb 21, 2009 at 9:40 PM, Nate Morse wrote: > > Before I go down the road of writing SQL by hand or using > QuerySet.extra(...) [ don't know

Re: Removing fields in a form subclass

2009-02-20 Thread Alex Koshelev
Oh, sorry. Of course `base_field` instead. class SubForm(BaseForm): field1 = forms.EmailField(...) del SubForm.base_fields['fields2'] On Fri, Feb 20, 2009 at 6:45 PM, Alex Koshelev <daeva...@gmail.com> wrote: > No. Place this code right after the SubForm definition. > > &

Re: Removing fields in a form subclass

2009-02-20 Thread Alex Koshelev
No. Place this code right after the SubForm definition. On Fri, Feb 20, 2009 at 6:42 PM, David Zhou <da...@nodnod.net> wrote: > > Do you mean del self.fields['field2'] in SubForm's __init__? > > -- dz > > > > On Fri, Feb 20, 2009 at 10:39 AM, Alex Koshelev <dae

Re: Removing fields in a form subclass

2009-02-20 Thread Alex Koshelev
Try this: del SubForm.fields['fields2'] On Fri, Feb 20, 2009 at 6:15 PM, David Zhou wrote: > > Suppose I had this form: > > class BaseForm(forms.Form): >field1 = forms.CharField(...) >field2 = forms.Charfield(...) > > And then in a subclass, I had: > > class

Re: Template rendering error

2009-02-20 Thread Alex Koshelev
Do you read an attribute resolution rules [1]? [1]: http://docs.djangoproject.com/en/dev/topics/templates/#variables On Fri, Feb 20, 2009 at 5:53 PM, Timothy <83...@gmx.de> wrote: > > Hi Folks, > > in views: > > return render_to_response('tliste/import.html', {'data': > allWrongData}) > >

Re: Keys composed of multiple fields

2009-02-16 Thread Alex Koshelev
Django doesn't suppurt multi-field PKs. Try to search this group for more diussion. On Mon, Feb 16, 2009 at 12:43 PM, jfmxl wrote: > > Hi again, > > How do I handle multifield keys? > > I have multifield primary keys which are in turn used as foreign keys > in other tables. > >

Re: get_absolute_url always returning empty string

2009-02-15 Thread Alex Koshelev
Why do you wrap two times the same `get_absolute_url` with `models.permalink` decorator? On Sun, Feb 15, 2009 at 10:42 AM, Michael Strickland wrote: > > Completely lost on this... I'm trying to set up permalinks to my > articles, which are using generic views. I've gotten

Re: Strange url tag behaviour

2009-02-11 Thread Alex Koshelev
Leave it empty FORCE_SCRIPT_NAME ='' On Wed, Feb 11, 2009 at 8:36 PM, Leslie Maclachlan wrote: > Thanks Dmitry, > > I entered it as: FORCE_SCRIPT_NAME = '/var/opt/django/projects/ilayer' this > has not resolved it - did I put it in the correct format? > > Regards, >

Re: order_by Ignore case

2009-02-11 Thread Alex Koshelev
You can do the same trick with django: Entry.objects.extra(select={'foo_upper': 'upper(foo)'}, order_by=['foo_upper']) On Wed, Feb 11, 2009 at 7:20 PM, jeffhg58 wrote: > > I currently have a field which has upper and lower case characters. Is > there a way for the django

Re: Adding fields to model objects that don't correspond to database state

2009-02-08 Thread Alex Koshelev
try this: def attach_bar(self, bar): if getattr(self, "bars", None) is None: self.bars = [] self.bars.append(bar) On Mon, Feb 9, 2009 at 12:03 AM, Jack Orenstein wrote: > > I have a model object that looks something like this: > >

Re: get_FOO_display

2009-02-06 Thread Alex Koshelev
get_FOO_display is an instance method not field. So try this: {{ object.get_invoice_type_display }} On Fri, Feb 6, 2009 at 6:09 PM, Alfonso wrote: > > I've got a field called 'invoice_type' which is a ChoiceField. > > In my template I'm trying to pull out the

Re: Model Form Field Ordering

2009-02-04 Thread Alex Koshelev
The is no public/documented API for reorder fields, but you can do some trick with SortedDict: class MyModelForm(forms.ModelForm): mySpecialField = forms.ChoiceField(label='Special', choices=(('a','aa'))) class Meta: model = MyModelType MyModelForm.base_fields.keyOrder =

Re: Displaying the names of executed tests

2009-02-02 Thread Alex Koshelev
Look at the `--verbosity` test command option On Mon, Feb 2, 2009 at 3:16 PM, Julien Phalip wrote: > > Hi, > > I'd find quite useful to have the names of all the tests displayed > after they have been executed. Instead of just having something like > 'Ran 3 tests 0.672s',

Re: "invalid reference to FROM-clause" for nested annotate query

2009-01-31 Thread Alex Koshelev
What database backend do you use? On Sat, Jan 31, 2009 at 6:44 PM, omat wrote: > > Hi all, > > I obtain a list of tag ids by: > tag_ids = TaggedItem.objects.all().order_by('-added__max').annotate(Max > ('added'))[:10] > > and try to use it in the following query to obtain tag

Re: How do I correctly format a Querydict derived list in a url?

2009-01-30 Thread Alex Koshelev
Try this: return HttpResponseRedirect('/activities/%s/' % "-".join(location_filter)) On Fri, Jan 30, 2009 at 10:26 PM, Alfonso wrote: > > I've got a form delivering multiple variables from a checkbox group > via POST to a view that defines where to redirect to. > >

Re: admin list display icons for callable?

2009-01-26 Thread Alex Koshelev
Try this: def photo_ad(self): if self.photo: return True return False photo_ad.boolean = True --- Александр Кошелев daeva...@gmail.com On Tue, Jan 27, 2009 at 8:51 AM, Paddy Joy wrote: > > The admin interface

Re: Django unittest fails to check empty values

2009-01-26 Thread Alex Koshelev
What DB backend do you use? In some cases it rises OperationalError On Mon, Jan 26, 2009 at 2:25 PM, marco sedda wrote: > > Hi, I've a problem with unittest in django: > > I've described a models.py: > >class Season(models.Model): >name =

Re: Issue with save(commit=False). Can't append primary key.

2009-01-26 Thread Alex Koshelev
Form.save() returns an object. So your code may look like this: comment = commentform.save(commit=False) comment.entry = entry comment.save() On Mon, Jan 26, 2009 at 7:28 PM, Ty wrote: > > Here's a snip of my model: > > class Comment(models.Model):

Re: Queryset unexpectedly turning into list

2009-01-24 Thread Alex Koshelev
All magic happens in line: if(queryset):#check if query returned somethin To perform this check QuerySet is evaluated and makes query to DB and stores result in list. After that QuerySet slice operation make real slice on underlying cache and of cource return list. On Sun, Jan 25, 2009 at 1:26

Re: Import Fixtures per test

2009-01-24 Thread Alex Koshelev
Extract this test to its own TestCase with needed fixtures. On Sat, Jan 24, 2009 at 8:15 PM, Vitaly Babiy wrote: > Is there a way to specify which fixtures I want to import per test? > > Vitaly Babiy > > > > --~--~-~--~~~---~--~~ You

Re: Last-Modified headers and render_to_response

2009-01-24 Thread Alex Koshelev
Just now you can store response object for a while and don't return it immediately. When set needed headers response = render_to_response("foobar.html") response["Last-Modified"] = "some value" return response On Sat, Jan 24, 2009 at 8:24 PM, Viktor Nagy wrote: > Hi, >

Re: Several test files

2009-01-23 Thread Alex Koshelev
Yes, you can do that. You can create tests package with some test modules and in `__init__.py` import needed test cases into package namespace. On Fri, Jan 23, 2009 at 12:29 PM, gderazon wrote: > > My tests.py has become too big, I want to split it to several test > files >

Re: Refresh Queryset - I know the answer is there somewhere

2009-01-23 Thread Alex Koshelev
Your query executes in module import time and it happens only one time. So you cannot reevaluate it using choices field param like that. Solution - redefine form `__init__` and manually reassign choices to given field every time form is created. def __init__(self, *args, **kwargs):

Re: Error: 'PersonForm' object is not callable

2009-01-22 Thread Alex Koshelev
You don't need to "call" form second time: pForm = PersonForm(request.POST.copy(), instance=p) And pForm is the ready to use instance of form. On Fri, Jan 23, 2009 at 8:29 AM, waltbrad wrote: > > Hi folks. PersonForm is a modelform. I'm trying to validate data

Re: Error when Resending forgotten password

2009-01-22 Thread Alex Koshelev
Try to check your EMAIL_ settings. On Fri, Jan 23, 2009 at 8:55 AM, Oleg Oltar wrote: > Hi! I am getting a strange error when trying to reset, forgotten password. > I am using it this way > ># Password resend group >

Re: ifequal with floatformat:"0" doesn't work

2009-01-20 Thread Alex Koshelev
Just now {% ifequal %} tag doesn't apply filters to its operands. On Tue, Jan 20, 2009 at 2:58 PM, ltcstyle wrote: > > is this a bug or what? > > {{float_number|floatformat:"0"}} give me correct number 1 > > but > {% ifequal float_number|floatformat:"0" 1 %} > never match >

Re: meet issue in Django tutorail

2009-01-16 Thread Alex Koshelev
Do you have the `__init__.py` file in mysite directory? On Fri, Jan 16, 2009 at 2:21 PM, syo wrote: > > hi , i'm now reading a Django tutorail naming: > "Writing your first Django app, part 1" > > In the "Activating models" part , it asks me to: > 1. add

Re: Aggregation across foreign keys / complex aggregation and annotation

2009-01-16 Thread Alex Koshelev
Try this: Process.objects.filter(exchange__input__unit__unit="kilogram")\ .annotate(sum_amount=Sum("exchange__amount"))\ .filter(sum_amount__gt=1) On Fri, Jan 16, 2009 at 12:38 PM, Christopher Mutel wrote: > > Following the

Re: editing multiple records using admin list view

2009-01-11 Thread Alex Koshelev
There is an application: http://code.google.com/p/django-batchadmin/ On Sun, Jan 11, 2009 at 1:53 PM, sateeshk...@gmail.com wrote: > > Hi, > I want to edit multiple records of users ( say selecting the user > records which I want to edit ) and then say if I press >

Re: subquery has too many columns

2009-01-07 Thread Alex Koshelev
And what is `groupadmins`? On Wed, Jan 7, 2009 at 8:36 PM, timc3 wrote: > > I updated my django version to revision 9710 today and now I am > getting the following error message on screen: > > Caught an exception while rendering: subquery has too many columns > > This is the

Re: Newbie: Help to understand string handling

2009-01-06 Thread Alex Koshelev
Yes. Django is just Python On Tue, Jan 6, 2009 at 11:14 PM, phoebebright wrote: > > As a newbie to both python and django (ex PHP) I am not clear on when > I can use python functions and when I can't. > > I want to do some simple string handling in a view, search and

Re: strip_tags in django admin issues

2009-01-06 Thread Alex Koshelev
Form class really doesn't have `strip_tags` method. I think you are interested in `strip_tags` functon from `django.utils.html`(and your comment says the same). So your method may look like this: def clean_title(self): from django.utils.html import strip_tags

Re: request.FILES always empty

2009-01-05 Thread Alex Koshelev
You don't set proper `enctype` to the form [1] [1]: http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form On Mon, Jan 5, 2009 at 11:34 PM, Glimps wrote: > > I'm using ModelForm to render my form. I have a FileField in my model > that shows

Re: unbalanced parenthesis

2009-01-05 Thread Alex Koshelev
You've forgotten ")" after `(?P\d{4}` On Mon, Jan 5, 2009 at 7:30 PM, mangamonk wrote: > > I'm trying to complete the practical django applications tutorial.. > > error at /weblog/ > unbalanced parenthesis > Request Method: GET > Request URL:

Re: form validation does not work

2008-12-30 Thread Alex Koshelev
Please post here entire view code On Wed, Dec 31, 2008 at 8:18 AM, Chuck22 wrote: > > class ContactForm(forms.Form): > email = forms.EmailField(required=True, > widget=forms.TextInput(attrs= > {'size':'30'}), >

Re: Django in runfcgi mode does not have log even is daemonize=false

2008-12-30 Thread Alex Koshelev
How do you put messages to log? On Tue, Dec 30, 2008 at 7:08 AM, CG wrote: > > Hi, all I am using Django 1.02 + lighttpd , and I run my django app in > fastCGI mode using the following > > runfcgi method=prefork socket=/tmp/socket.sock > pidfile=/var/run/process.pid

Re: Sites and Auth apps not visible on using custom AdminSite

2008-12-29 Thread Alex Koshelev
Right here: http://code.djangoproject.com/browser/django/trunk/django/contrib/auth/admin.py http://code.djangoproject.com/browser/django/trunk/django/contrib/sites/admin.py On Mon, Dec 29, 2008 at 8:50 PM, raj wrote: > > Yes, I've found the way out. Adding these lines to

Re: Sites and Auth apps not visible on using custom AdminSite

2008-12-29 Thread Alex Koshelev
How have you created custom AdminSite? Have you registered auth and site models to it? On Mon, Dec 29, 2008 at 1:41 PM, raj wrote: > > In the usual admin index at http://host:port/admin/ page, there are > the auth and sites app visible on top of our custom app list. I'd

Re: Field.default optional attribute is not working properly

2008-12-29 Thread Alex Koshelev
Default values stay only on python layer. For example you can specify any callable as default value so it cannot be "mapped" into DLL. On Mon, Dec 29, 2008 at 3:50 PM, Rama wrote: > i have a model class as below. *(please observe the red color lines)* > > class

Re: enumerate in templates

2008-12-27 Thread Alex Koshelev
{% for %} itself On 12/27/08, Vicky wrote: > > Is there a way to access the previous value of a for loop in > templates. Can anyone tell the template representation for the python > code like: > > for i,j in enumerate(item): >

Re: cross table querying II

2008-12-26 Thread Alex Koshelev
tb1.objects.extra(select={"tb2_name": "app_tb2.name"},where=["app_tb1.name= app_tb2.name"], tables=["app_tb2"]).values("name", "tb2_name") On Sat, Dec 27, 2008 at 7:16 AM, Shuge Lee wrote: > > class tb1( models.Model ): >name = models.CharField(max_length=32) >tb2 =

Re: sql translation error in django?

2008-12-26 Thread Alex Koshelev
Paper.objects.filter(Journal__Name='Science').order_by("-PublishedDate") Read the documentation please. On Fri, Dec 26, 2008 at 8:43 PM, 夏恺 wrote: > > Hi all! > > I'm working on an app which has two classes: > > # This one records acedemic journal name and related

Re: How to implement code that runs in the background?

2008-12-26 Thread Alex Koshelev
Use cron and custom manage.py commands On Fri, Dec 26, 2008 at 10:58 AM, Fluoborate wrote: > > I have a philosophical question. How should I implement code that runs > in the background, automatically, and continuously? What is a safe and > kosher way to do that? > > >

Re: Get model name

2008-12-25 Thread Alex Koshelev
Foo._meta.object_name On Thu, Dec 25, 2008 at 2:44 PM, Kless wrote: > > How to know the name of the model? i.e. > > class Foo(models.Model): > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the

Re: invalid syntax - install django 1.0.2

2008-12-17 Thread Alex Koshelev
tro/install/#intro-install On Wed, Dec 17, 2008 at 22:02, Richard <ric...@gmx.de> wrote: > > Im running Python 3.0 > > and the line 70 is correct in my file: > > "if u'SVN' in version:" > > > On Dec 17, 3:35 pm, "Alex Koshelev" <da

Re: invalid syntax - install django 1.0.2

2008-12-17 Thread Alex Koshelev
What is your version of python? On Wed, Dec 17, 2008 at 21:26, Richard wrote: > > Hi, > > when im running the "setup.py install" command in my shell under > Windows Vista > it returns an syntax error in Line 70 > > if u'SVN' > ^ > > anybody knows what im doing wrong? >

Re: db API where ...or...

2008-12-15 Thread Alex Koshelev
http://docs.djangoproject.com/en/dev/topics/db/queries/#complex-lookups-with-q-objects On Mon, Dec 15, 2008 at 18:35, Lars Stavholm wrote: > > Hi all, > > when combining Django ORM criteria you get > the "...WHERE...AND..." clauses. > > How do I get the "...WHERE...OR..."

Re: Reusing a python model

2008-12-14 Thread Alex Koshelev
You don't need to define it else where.Just write a django model once and use it any where in you project. On Sun, Dec 14, 2008 at 18:40, JULIO Cayo wrote: > > Hi, I want to start with django framework. I've never used it. ( I'm > sorry, I'm learning english) > > My

Re: remove object from queryset

2008-12-14 Thread Alex Koshelev
http://docs.djangoproject.com/en/dev/ref/models/querysets/#exclude-kwargs On Sun, Dec 14, 2008 at 16:03, Alfredo Alessandrini wrote: > > Hi, > > can I remove an objects from the queryset: > > In [138]: from CHALLENGE.models import start_game > > In [139]:

Re: Optional GenricForeigKey: "null=True, blank=True" => unexpected keyword argument

2008-12-13 Thread Alex Koshelev
GenericForeignKey is pseudo-field. It doesn't have any own underlying db field representation, so there is no need to specify it as blank and nullable. On Sat, Dec 13, 2008 at 22:45, mwebs wrote: > > Hello, > > I have a model that I want to have an optional generic

Re: template string formatting

2008-12-13 Thread Alex Koshelev
{{var|slice:"0"}} On 12/13/08, Vicky wrote: > > Is there any way to take out the first letter of a string in django > template system? > ex: > > x("Hai") should give o/p as: "H" > > > -- --- Александр Кошелев daeva...@gmail.com

Re: models.FileField() vs. forms.FileField()

2008-12-11 Thread Alex Koshelev
models.FileField realy requires `upload_to` param. And it can be callable with `instance` argument [1]. Using this feature you can generate upload path by the instance fields. [1]: http://docs.djangoproject.com/en/dev/ref/models/fields/#filefield On Thu, Dec 11, 2008 at 13:47, Alan <[EMAIL

Re: referencing the current instance inside limit_choices_to

2008-12-09 Thread Alex Koshelev
There is no way to have per-instance limit_choices_to. On Wed, Dec 10, 2008 at 03:56, GuyBowden <[EMAIL PROTECTED]> wrote: > > Hi, > > I've looked about but can't find the answer to this. > > I'd like to set the limit_choices_to value of a ForeignKey field based > on another selection in the

Re: how to do redirects with django?

2008-12-09 Thread Alex Koshelev
http://docs.djangoproject.com/en/dev/ref/request-response/#httpresponse-subclasses http://docs.djangoproject.com/en/dev/ref/contrib/redirects/#ref-contrib-redirects On Tue, Dec 9, 2008 at 16:25, nbv4 <[EMAIL PROTECTED]> wrote: > > If the user goes to /foobar, I want it to redirect him to

Re: time it takes django to read database?

2008-12-07 Thread Alex Koshelev
Do you use caching? On Mon, Dec 8, 2008 at 07:34, garagefan <[EMAIL PROTECTED]> wrote: > > ok... i've been able to figure out how long it takes based on the time > stamp... an hour and a half for a new object to have come in. It > appears that the item is not readable by the two templates, one

Re: fields in object.values()

2008-12-07 Thread Alex Koshelev
Manager's `values` method excepts list of field names but you give the string. Try this: tbData = tableName.objects.values(*strFld.split(",")) On Sun, Dec 7, 2008 at 23:48, sotiris.kazakis <[EMAIL PROTECTED]>wrote: > > hello, > > I search a lot about the use of object.values() but don't get

Re: how to create json from template?

2008-12-02 Thread Alex Koshelev
Oh, Yes. Good point. On Wed, Dec 3, 2008 at 09:49, David Zhou <[EMAIL PROTECTED]> wrote: > > On Wed, Dec 3, 2008 at 1:17 AM, Alex Koshelev <[EMAIL PROTECTED]> wrote: > > > > To trim last colon wrap it with if statement: > > > > {% if forloop.revc

Re: how to create json from template?

2008-12-02 Thread Alex Koshelev
To trim last colon wrap it with if statement: {% if forloop.revcounter0 %},{% endif %} On Wed, Dec 3, 2008 at 04:26, Viktor Nagy <[EMAIL PROTECTED]> wrote: > Hi, > > I know about the serialisation framework, but with MultiResponse[1] you > can't really use it (and anyway I don't know how to

Re: Overwriting Django Authentication / Session Logic

2008-12-01 Thread Alex Koshelev
Have you read this - http://docs.djangoproject.com/en/dev/topics/auth/#other-authentication-sources? On Mon, Dec 1, 2008 at 19:02, Devye <[EMAIL PROTECTED]> wrote: > > Hi, > > I am trying to integrate a Django app with an in-house developed > webapp. The biggest hurdle is to consolidate the two

Re: rendering DB text in template

2008-11-28 Thread Alex Koshelev
Look at this: http://docs.djangoproject.com/en/dev/topics/templates/#id2 On Fri, Nov 28, 2008 at 21:43, Django Newbie <[EMAIL PROTECTED]> wrote: > > So I have some text fields in the db that have some embedded html in the > text. How do I get the template to render the text as html? > > The

Re: Passing in dynamic id's to a template tag?

2008-11-28 Thread Alex Koshelev
Standard `simple_tag` shortcut resolves variables well. On Fri, Nov 28, 2008 at 19:29, truebosko <[EMAIL PROTECTED]> wrote: > > Mulling over the docs I can't find an answer to this, say I want to do > something like so: > > {% get_shipping 'ontario' product.id %} > > Parsing ontario is simple

Re: significance of date published

2008-11-26 Thread Alex Koshelev
It is just verbose_name - something like human description or label for field. On Wed, Nov 26, 2008 at 20:40, mahesh_aka_amol <[EMAIL PROTECTED]> wrote: > > Hi > > I have came across a constructor like this > models.DateTimeField('date published') > > What is significance of 'date published'

Re: Using {% url %} with generic views

2008-11-26 Thread Alex Koshelev
Url patterns can have names [1] [1]: http://docs.djangoproject.com/en/dev/topics/http/urls/#id2 On Wed, Nov 26, 2008 at 14:48, dash86no <[EMAIL PROTECTED]> wrote: > > Yesterday I replaced hard coded links on my site with a dotted > notation path to the relevant view using the {% url %} tag. >

Re: Reusable forms!

2008-11-26 Thread Alex Koshelev
form) > > But rather predictably that is showing an error... I'm a bit lost, I > understand the inclusion principle for things like 'last 5 blog posts' > etc but including a form seems more difficult? > > Thanks > > On Nov 25, 5:55 pm, "Alex Koshelev" <[EMAIL PROTECTED

Re: Overriding contrib.auth User save()

2008-11-26 Thread Alex Koshelev
Of course you can monkey-patch the User model but the better way is to use signals pre_ or post_save On Wed, Nov 26, 2008 at 13:54, Paddy Joy <[EMAIL PROTECTED]> wrote: > > I would like to override the save() method on the contrib.auth User > model so that I can run a routine when a user is

Re: App Name in Admin

2008-11-26 Thread Alex Koshelev
Application not model. verbose_name works for model itself Just now there is no way to set custom application name. On Wed, Nov 26, 2008 at 10:40, Daniel Roseman <[EMAIL PROTECTED] > wrote: > > On Nov 26, 6:57 am, "Steve Phillips" <[EMAIL PROTECTED]> wrote: > > Hi All > > > > I have been

Re: Running Django on a shared-hosting provider with Apache in fcgi mode

2008-11-25 Thread Alex Koshelev
You have to start FastCGI demon that will handle request. For example by using `./manage.py runfcgi` command On Tue, Nov 25, 2008 at 20:47, Oleg Oltar <[EMAIL PROTECTED]> wrote: > Hi! > > I have a shared hosting. Need to place there my django application. I > created ./.htaccess in my root

Re: Reusable forms!

2008-11-25 Thread Alex Koshelev
You have to pass form instance to all pages context where it is used. You can do it explicitly or write custom context processor or (the better solution) write custom inclusion tag. On Tue, Nov 25, 2008 at 20:13, Alfonso <[EMAIL PROTECTED]> wrote: > > Hey, > > I've put together a simple search

Re: django query API help

2008-11-24 Thread Alex Koshelev
Values gets onli fields names [1]. Try this: results = Article.objects.filter(qset).values('published_at') [1]: http://docs.djangoproject.com/en/dev/ref/models/querysets/#values-fields On Mon, Nov 24, 2008 at 13:16, kele <[EMAIL PROTECTED]> wrote: > > hi all, > > i have some codes like these:

Re: unicode cipher & generic views

2008-11-22 Thread Alex Koshelev
Hi, Oleg! Show your code to us. Problem is where. On 11/22/08, oleg <[EMAIL PROTECTED]> wrote: > > Hi there! I'm brand new user of django.. So, please, don`t be ugly, > if I`m missing something elementary ^_^ > > I use django.views.generic.create_update to generate an editing/ > inserting form

Re: NoReverseMatch question

2008-11-21 Thread Alex Koshelev
You have an underscore in slug - "second_post" but your regex doesn't allow it - "[-\w]+". I think it is the problem. And why you did you choose "\w" for day? On Fri, Nov 21, 2008 at 17:16, goblue0311 <[EMAIL PROTECTED]> wrote: > > Hi all: > > I'm receiving this error: > >

Re: Request object from models

2008-11-21 Thread Alex Koshelev
No. Request object does not exist when model classes are created. On Fri, Nov 21, 2008 at 13:47, FT <[EMAIL PROTECTED]> wrote: > > class Document(models.Model): > >created = models.DateTimeField( >help_text='Timestamp when the document is created', > blank=True, >

Re: Problems with file upload and model forms

2008-11-20 Thread Alex Koshelev
Do you use `enctype` attribute[1] of form tag? [1]: http://docs.djangoproject.com/en/dev/ref/forms/api/#binding-uploaded-files-to-a-form On Thu, Nov 20, 2008 at 16:59, Marc Barranco <[EMAIL PROTECTED]> wrote: > > Hi! > I'm trying to upload a file like the example in documentation in > Django

Re: Template custom filter doesn't work

2008-11-19 Thread Alex Koshelev
You have to convert value from string to integer: int(arg) On Wed, Nov 19, 2008 at 13:18, K*K <[EMAIL PROTECTED]> wrote: > > I modified some code so I made mistake again. -_-# > > The right result looks like this: > > $ ./manage.py shell > Python 2.5.1 (r251:54863, Apr 15 2008, 22:57:26) >

Re: Multiple Admin Site and Restricting models available in one AdminSite

2008-11-18 Thread Alex Koshelev
> I understand that we can now have several admin site for the same app. (by proper configuration in the url_conf). Yes with using of several AdminSite instances. So you can register models to needed site instance. That helps you to separate access to models from different admin backends. On

Re: ManyToMany and save method

2008-11-17 Thread Alex Koshelev
Related objects save after `host`. So insertion into M2M table happens after save method of host object has executed. In your example - after `Ticket.save` On Mon, Nov 17, 2008 at 14:49, Marco Minutoli <[EMAIL PROTECTED]>wrote: > > I have this model: > > class Ticket(models.Model): >##

  1   2   3   4   >