Re: query date by string

2010-12-03 Thread owidjaya
so you are saying that  SELECT * FROM some_table WHERE some_date LIKE
"2010%"
is not possible?

On Dec 3, 9:30 am, bruno desthuilliers <bruno.desthuilli...@gmail.com>
wrote:
> On 3 déc, 17:37, owidjaya <owidj...@gmail.com> wrote:
>
> > in php I can run the following query for mysql
>
> > SELECT * FROM some_table WHERE some_date LIKE "2010%"
>
> > How do i do this in django using cursor.execute()?
>
> sql = "SELECT * FROM some_table WHERE YEAR(some_date)=%s"
> cursor.execute(sql, (2010,))

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: query date by string

2010-12-03 Thread owidjaya
It's for mysql
it still does not work. I tried it with the following sql statement
"SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%'

On Dec 3, 9:04 am, wayne <wayne.tuxro...@gmail.com> wrote:
> On Dec 3, 10:47 am, owidjaya <owidj...@gmail.com> wrote:
>
> > It says incorrect date value.
>
> What database are you using?  I'm wondering if this is an issue of
> formatting the sql correctly.  Did you read the snippet near the
> bottom of the page I linked to?  Try:
>
> SELECT * FROM some_table WHERE some_date LIKE "%s" % '2010%'

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: query date by string

2010-12-03 Thread owidjaya
It says incorrect date value.

On Dec 3, 8:44 am, wayne  wrote:
> You should be able to do it just as you mention, passing the query
> string to cursor.execute().
>
> Seehttp://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-...
>
> Have you tried this?  Are you getting an error?  If so, what is it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



query date by string

2010-12-03 Thread owidjaya
in php I can run the following query for mysql

SELECT * FROM some_table WHERE some_date LIKE "2010%"

How do i do this in django using cursor.execute()?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



extends a template that is stored in an app template directory

2010-11-26 Thread owidjaya
How do i extends a template that is stored within an application
template directory from another application?
I have two apps
one is datagrid and the other one is client
I want to use datagrid to display list of clients
but instead of using the datagrid template that comes from the app, i
want to extend that template to modify the datagrid for client display

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: ajax and django

2010-11-22 Thread owidjaya
correction it's "process_response" function not process_request.

On Nov 22, 2:48 pm, owidjaya <owidj...@gmail.com> wrote:
> What is the best way to go about handling ajax request per
> application?
>
> I currently have a middleware that implements "process_request"
> function.
> the function acts as a relay to call "serve_ajax(request)" function
> that is implemented in the application class that wants to respond to
> ajax request. The application object that will respond to the ajax
> request is indicated by a GET variable "object". while every other
> variables to be passed to the application is passed with POST
> variable.
>
> please comments on the method above.
> Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



ajax and django

2010-11-22 Thread owidjaya
What is the best way to go about handling ajax request per
application?

I currently have a middleware that implements "process_request"
function.
the function acts as a relay to call "serve_ajax(request)" function
that is implemented in the application class that wants to respond to
ajax request. The application object that will respond to the ajax
request is indicated by a GET variable "object". while every other
variables to be passed to the application is passed with POST
variable.

please comments on the method above.
Thanks in advance.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: adding field to query set

2010-10-28 Thread owidjaya
Ok the motive is for this reason.
I have a table generator class that display an html table from the
query set depending on the columns that you selected
class TableGenerator(name,mapping,data):

  def __init__(self,name,mapping,data):
 self._mapping = mapping
 self._name = name
 self._data = data
  def render_table(self):
  # pseudo code
  *  iterate through the mapping construct the table header
  *  iterate through self._data queryset and construct the columns
for the table body based on the mapping

-- mapping is a variable that holds the mapping of table header with
the actual field name of the model attribute
-- data is just the queryset object.

so here I want to generate a table to display every attribute in
project while also display the related fields of user.first_name and
user.last_name concatenated.
How can i refer to that field in my TableGenerator class using the
mapping generically?


On Oct 28, 3:27 pm, Jumpfroggy  wrote:
> What's your motive?  Are you worried about performance?
>
> If performance is not an issue, you can just do this:
>
>     for project in Project.objects.all():
>         print project.user.first_name + ' ' + project.user.last_namea
>
> This might speed things up:
>
>     projects = Project.objects.all().select_related('user')
>     for project in projects:
>         print project.user.first_name + ' ' + project.user.last_namea
>
> If that's not fast enough, you may want to do something using .extra()
> or .raw().  I'm not sure how to do this effeciently with .extra().

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



adding field to query set

2010-10-28 Thread owidjaya
If I have such models

class Project(models.Model):
  project = models.CharField(max_length=200)
  user = models.ForeignKey(User) # user is from
django.contrib.auth.models => user

I would like to be able to display an an attribute that is made up of
first_name and last_name concatenated when i iterate the queryset

So in essence, can i create such sql from django without using cursor
class?

SELECT   P.*, CONCAT(A.first_name, A.last_name)
FROM project P
LEFT OUTER JOIN auth_user A ON A.id = P.user_id

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



adding field to query set

2010-10-28 Thread owidjaya
If i have such models

class Project(model.Model):
  project = model.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



delete permission from permission list

2010-09-13 Thread owidjaya
Hi all,
I have a problem with permission list. I deleted the table for a
django model, deleted the permission entries for the model from the
permissions table, restart web server, delete the content type entry
of the model and i still get the permission  appearing in the list in
the admin page. I checked all the tables and everything looks clean.
My question is where does django store the permissions?.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



delete permission from permission list

2010-09-13 Thread owidjaya
Hi all,
I have a problem with permission list. I deleted the table for a
django model, deleted the permission entries for the model from the
permissions table, restart web server, delete the content type entry
of the model and i still get the permission  appearing in the list in
the admin page. I checked all the tables and everything looks clean.
My question is where does django store the permissions?.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



delete permission from permission list

2010-09-13 Thread owidjaya
Hi all,
I have a problem with permission list. I deleted the table for a
django model, deleted the permission entries for the model from the
permissions table, restart web server, delete the content type entry
of the model and i still get the permission  appearing in the list in
the admin page. I checked all the tables and everything looks clean.
My question is where does django store the permissions?.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: accessing a dictionary in template

2010-08-09 Thread owidjaya
Yes i'm trying to display a table with dynamic columns.
my intention was to pass the queryset object to template and pass the
column names so that the template can generate the table dynamically.


On Aug 9, 12:06 pm, Sævar Öfjörð <saeva...@gmail.com> wrote:
> I take it that you absolutely need to dynamically access the values
> through generated keys?
> Not just a regular for loop?
>
> {% for var in some_mapping %}
>     {{ var }}
> {% endfor %}
>
> - Sævar
>
> On Aug 9, 8:56 pm, owidjaya <owidj...@gmail.com> wrote:
>
> > in php i can do this
>
> > $some_mapping = array( "var1" : content_var1,
> >                                      "var2" : content_var2,
> >                                    )
> > for($i =1; $i < 3; $i++){
> >    echo $some_mapping["var"+$i];
>
> > }
>
> > can i do this in django template?
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



accessing a dictionary in template

2010-08-09 Thread owidjaya
in php i can do this

$some_mapping = array( "var1" : content_var1,
 "var2" : content_var2,
   )
for($i =1; $i < 3; $i++){
   echo $some_mapping["var"+$i];
}

can i do this in django template?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



accessing a dictionary in template

2010-08-09 Thread owidjaya
in php i can do this

$some_mapping = array( "var1" : content_var1,

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: queryset field order

2010-08-06 Thread owidjaya
okay that's great but is there a way to get the list of fields from a
model instance instead of from the Model class itself?
My thought is that if I pass in the list of model instance into the
template, the order should be still there. so why pass in another
variable which contains the model fields.


On Aug 6, 11:04 am, Alec Shaner <asha...@chumpland.org> wrote:
> You can't use a dictionary if you expect a certain order of key/value pairs.
>
> Given model A you could get a list of field objects in the same order (I
> think) as defined in the model class
>
> A._meta.fields
>
> At least with that information you could programatically produce a list of
> data in matching order with a little code.
>
> On Fri, Aug 6, 2010 at 1:34 PM, owidjaya <owidj...@gmail.com> wrote:
> > is there a way that i can get the a list of dictionaries as a result
> > with the dictionary having the same field order as the table?
>
> > On Aug 6, 10:18 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> > > On Aug 6, 6:08 pm, owidjaya <owidj...@gmail.com> wrote:
>
> > > > I checked it and the field order still not the same.
> > > > Just to clarify. I want the to do this A.objects.all().values()
> > > > and still get the each list in the result to have the same "field
> > > > order" as the database table defined.
>
> > > `values()` returns a set of dictionaries. Dictionaries are unordered
> > > by definition.
>
> > > `values_list()` returns a set of tuples, which should be in the same
> > > order as the model definition, however you don't get the fieldnames.
> > > --
> > > 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-us...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: queryset field order

2010-08-06 Thread owidjaya
is there a way that i can get the a list of dictionaries as a result
with the dictionary having the same field order as the table?

On Aug 6, 10:18 am, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Aug 6, 6:08 pm, owidjaya <owidj...@gmail.com> wrote:
>
> > I checked it and the field order still not the same.
> > Just to clarify. I want the to do this A.objects.all().values()
> > and still get the each list in the result to have the same "field
> > order" as the database table defined.
>
> `values()` returns a set of dictionaries. Dictionaries are unordered
> by definition.
>
> `values_list()` returns a set of tuples, which should be in the same
> order as the model definition, however you don't get the fieldnames.
> --
> 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-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: queryset field order

2010-08-06 Thread owidjaya
I checked it and the field order still not the same.
Just to clarify. I want the to do this A.objects.all().values()
and still get the each list in the result to have the same "field
order" as the database table defined.

On Aug 6, 9:57 am, kostia  wrote:
> use table = ModelName.objects.all().order_by("filter_name")
>
> It is ordered by id field apriori.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



queryset field order

2010-08-06 Thread owidjaya
Hi All,
I was just wondering is there a way to get queryset to return result
of a database lookup
to list the fields in the same order as it is defined in the database
table?
so for example in my
TABLE A
--
A
B
C

the query set result will return
exactly
[ {A: some value, B: some value, C: some value},.]

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: single point of entry to a webpage

2010-07-26 Thread owidjaya
how do i write custom template tag that is available to all my apps.
not tied to a particular app?

On Jul 26, 7:05 am, bruno desthuilliers
<bruno.desthuilli...@gmail.com> wrote:
> On 25 juil, 00:25, owidjaya <owidj...@gmail.com> wrote:
>
> > if i have a page with sections say the home page. It has section for
> > news, it has section for blog, comments and etc.
> > I have apps for every one of those section. Now how do i add the
> > output of the view for each of those apps on the same page?
>
> You don't. A Django "view" is just a callable that takes an HTTP
> request and returns an HTTP response. The solution to your problem is
> to write custom templatetags for news, blog, comments etc and call
> these templatetags from the templates that needs them.
>
> HTH

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: single point of entry to a webpage

2010-07-24 Thread owidjaya
if i have a page with sections say the home page. It has section for
news, it has section for blog, comments and etc.
I have apps for every one of those section. Now how do i add the
output of the view for each of those apps on the same page?

On Jul 24, 1:07 pm, Dennis Kaarsemaker <den...@kaarsemaker.net> wrote:
> On vr, 2010-07-23 at 12:50 -0700, owidjaya wrote:
>
> > I was thinking of creating a single point of entry to my webpage
> > through an app call "core" from there, depending on the url pattern,
> > it can pass the processing to different apps. how do i do that while
> > staying in the workflow of the framework?
>
> This sounds really weird to me as django already does this 'call an app
> depending on the url' for you. No need for a 'core' app.
> --
> Dennis K.
>
> They've gone to plaid!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



single point of entry to a webpage

2010-07-23 Thread owidjaya
Hi All,

I was thinking of creating a single point of entry to my webpage
through an app call "core" from there, depending on the url pattern,
it can pass the processing to different apps. how do i do that while
staying in the workflow of the framework?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



custom tag and filtered value

2010-07-20 Thread owidjaya
how can i pass a filtered value to a custom tag?

ie
if i do this


{% somecustomtag template_variable|lower %}

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: what kind i acces from django template variable?

2010-07-19 Thread owidjaya
yes that is what i meant. can i sort the related objects in the
template?
instead of passing another variable from the views.py
other than that what other built in variables can i access from the
template?

On Jul 19, 11:37 am, Venkatraman S <venka...@gmail.com> wrote:
> On Mon, Jul 19, 2010 at 11:06 PM, owidjaya <owidj...@gmail.com> wrote:
> > How can i find out what variable is accessible from the template?
>
> You need to pass the result of the query to the template.
> Or did you mean accessing the 'related' objects from the passed objects to
> the template?
>
> -V

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



what kind i acces from django template variable?

2010-07-19 Thread owidjaya
Hi All,
How can i find out what variable is accessible from the template?
If I have 2 models
Model A:
  Name = text
Model B:
  Name = text
  a = ForeignKey(A)


how can i order the list of "objectA.b_set.all" from the template?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.