2 Questions: Passing Filter Options to a View & Efficient QuerySet Evaluation

2013-05-26 Thread JJ Zolper
Hello,

So my question is a 2 part question. The first part leads into the second 
part.

So my first question goes like this. Say I'm on a webpage and I go through 
about 3 drop down selection filter menu's/options. I then hit submit. My 
question is how would I pass these arguments to the view that then would 
take those requested filter values and actually evaluate the database to 
return the correct objects from the database to a template? Initially, I 
thought maybe some sort of url generation/parsing/passing would be involved 
but I really don't know how to create a dynamic interchange here. I really 
don't think defining a set of standard querysets against in a view to go 
against a database is the best option. Like for example if I wanted to 
filter my database by 3 different criteria and each criteria had 4 filters 
that would be 3 x 4 possiblities and 12 unique view methods/queries I would 
have to write. Not good by any means.

My second question spans off of the first question. So let's say now I have 
these criteria (Let's call it 3 specific criteria following the first 
paragraph's direction) and I want to go ahead and efficiently query the 
database given the populated queryset I have formed. How can I ensure these 
queries will be of the utmost efficiency? I need each query by each user on 
the site to have an extremely low footprint on the sites 
bandwith/resoures/etc. The reason being: Let's say I have 1,000,000 objects 
in the database. Say all the entries are geographically related. So maybe 
points in lat lon across the US. And say I'm filtering by distance off a 
location. That to me is a heck of a lot of queries that have to be done and 
surely how I write that has to be really efficient. 

Again on question 2 I would be chaining queries so:

Chaining 
filters

The result of refining a 
QuerySet
 is 
itself a 
QuerySet,
 
so it’s possible to chain refinements together. For example:

>>> Entry.objects.filter(... headline__startswith='What'... ).exclude(...   
>>>   pub_date__gte=datetime.date.today()... ).filter(... 
>>> pub_date__gte=datetime(2005, 1, 30)... )


and so one of those queries would indeed by geo related so of this nature:

.objects.filter(point__distance_lte=(pnt, D(km=7)))


and I then I would still break the query down by a few other criteria for 
example. So any advice on how to make my chained queries extremely 
efficient would be great!

If I have no given enough information I would be more then happy to dive 
into more detail on each specific thing. The django community is the best 
in my opinion so I'm willing to go the extra mile and try to explain myself 
more for the chance for more great help!

Thanks so much,

JJ Zolper

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




Re: 2 questions about Django

2011-12-14 Thread Ivo Brodien


> 1) Can I make a site like this one (http://www.tamarawobben.nl) with
> Django.
> Till now I find no solution which I can have different numbers of
> articles on pages.

Yes, of course you can. You can almost do anything with Django as django to put 
it simply mainly will output HTML Code which is what you want for a webpage.

It looks like you are looking for a blogging app for django.

Just search for it with your favorite search engine.

cheers
Ivo

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



2 questions about Django

2011-12-14 Thread roelof
Hello,

1) Can I make a site like this one (http://www.tamarawobben.nl) with
Django.
Till now I find no solution which I can have different numbers of
articles on pages.
The only thing I want to change is a collapse year/month menu

2) Does anyone know if I can work with Django on my shared hosting
account on the Dutch provider pcextreme ?

Regards,

Roelof Wobben

-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: 2 Questions about feeds

2009-08-09 Thread Léon Dignòn

Please try to change the Sitename in the backend at /admin/sites/site/
Per default its example.com

On Aug 8, 8:46 pm, When ideas fail  wrote:
> Hi, i'm developing a feed but i still have a couple of questionss.
>
> 1. I have this in my models:
>
> def get_absolute_url(self):
>         return "/blog/%s/" % self.post_slug
>
> but the rss has the links down as:http://example.com/blog/post_3/,
> the blog/post_3/ is correct, how can i make sure its linked to right
> domain name? for example have it go to andrew.com/blog/post_3?
>
> 2. What does the  element do?
> I've changed it a few times and i can't see what difference it makes?
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



2 Questions about feeds

2009-08-08 Thread When ideas fail

Hi, i'm developing a feed but i still have a couple of questionss.

1. I have this in my models:

def get_absolute_url(self):
return "/blog/%s/" % self.post_slug

but the rss has the links down as: http://example.com/blog/post_3/,
the blog/post_3/ is correct, how can i make sure its linked to right
domain name? for example have it go to andrew.com/blog/post_3?

2. What does the  element do?
I've changed it a few times and i can't see what difference it makes?

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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: 2 questions on Model

2008-04-01 Thread Malcolm Tredinnick


On Tue, 2008-04-01 at 22:10 -0700, PENPEN wrote:
> 1. About select_related():
> It is said that it will automatically "follow" foreign-key
> relationships, selecting that additional related-object data when it
> executes its query. So it is not applicable for ManyToMany
> relationship, isn't it?

That's correct. It only follows non-nullable many-to-one relations.

> And if select_related() is used,  will the queryset method on the
> related Manager access the DB later? For example:
> b = Book.objects.select_related().get(id=4)
> p = b.author # Doesn't hit the database.
> p.get(pk=3) # Will this action hit the database?

If 'author' is marked as a ForeignKey on the Book model, then b.author
is an Author object. So b.author.get() makes no sense.

> 2.  About iterator(), 'for' and 'enumerate' on queryset:
> There is a snippet from the django document page(http://
> www.djangoproject.com/documentation/db-api/):

[... snip ...]

> It seems that 'for' loop and enumerate on a QuerySet will use its
> iterator. Then if I use 'for' loop or enumerate() on a queryset to do
> some logical task and in the template it will iterate the QuerySet
> again to display all the data, will the database be hit again?

Looping over an iterable object does not call the "iterator()" method.
It calls the __iter__() method. If you have a look at the definition of
__iter__ in query.py, you'll notice that it doesn't call iterator() if
the result_cache is populated.

Regards,
Malcolm

-- 
I've got a mind like a... a... what's that thing called? 
http://www.pointy-stick.com/blog/


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



2 questions on Model

2008-04-01 Thread PENPEN

1. About select_related():
It is said that it will automatically "follow" foreign-key
relationships, selecting that additional related-object data when it
executes its query. So it is not applicable for ManyToMany
relationship, isn't it?

And if select_related() is used,  will the queryset method on the
related Manager access the DB later? For example:
b = Book.objects.select_related().get(id=4)
p = b.author # Doesn't hit the database.
p.get(pk=3) # Will this action hit the database?

2.  About iterator(), 'for' and 'enumerate' on queryset:
There is a snippet from the django document page(http://
www.djangoproject.com/documentation/db-api/):
  iterator()
  Evaluates the QuerySet (by performing the query) and returns an
iterator over the results. ...
  Note that using iterator() on a QuerySet which has already been
evaluated will force it to evaluate again, repeating the query.

And I found the following document of python on iterater and
enumarate:
iterater http://www.python.org/dev/peps/pep-0234/
This document proposes an iteration interface that objects can
provide to control the behaviour of 'for' loops.
enumerate() http://www.python.org/dev/peps/pep-0279/
It provides all iterable collections with the same advantage that
iteritems() affords to
dictionaries -- a compact, readable, reliable index notation.

It seems that 'for' loop and enumerate on a QuerySet will use its
iterator. Then if I use 'for' loop or enumerate() on a queryset to do
some logical task and in the template it will iterate the QuerySet
again to display all the data, will the database be hit again?
--~--~-~--~~~---~--~~
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: 2 Questions!

2007-02-01 Thread Michael Radziej

Sebastien Armand [Pink]:
> This time it's done. The ticket is here:
> http://code.djangoproject.com/ticket/3412 I hope it's enough documented.

Merci! I finally realized that it's not about a ForeignKey, sorry
for the confusion. Can you check if you can work around it with a

entreprise_list=entreprise_list.filter(domaine=data['domaine'].encode(settings.DEFAULT_CHARSET))

etc.?

Hope that helps!

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-02-01 Thread Sebastien Armand [Pink]
This time it's done. The ticket is here:
http://code.djangoproject.com/ticket/3412 I hope it's enough documented.

2007/2/1, Sebastien Armand [Pink] <[EMAIL PROTECTED]>:
>
> Oooops didn't read enaough from the #3387 ticket. So I'll open one!
> Thanks a lot for your explanations.
>
> 2007/2/1, Michael Radziej <[EMAIL PROTECTED] >:
> >
> >
> > Sebastien Armand [Pink]:
> > > No problem, thanks!
> > >
> > > There's already a ticket, it's here:
> > > http://code.djangoproject.com/ticket/3387
> >
> > No, thanks for searching, but it's not. #3387 was triggered by using
> >
> > queryset.filter(unicode_string)
> >
> > You didn't use a unicode_string within filter(), though the
> > traceback is similar. It happened because Django's ORM internal code
> > looks up the related records to a foreign key with filter(), and
> > uses a unicode string because because newforms put it in the model.
> >
> > It's a new bug, but the patch in the #3387 should heal it. Funny.
> > Please *do* open a ticket. #3387 is closed. I'm now pretty sure that
> > your case has not been reported before.
> >
> > > But though, is there another encoding I could use and how do I specify
> > it?
> >
> > Short answer: No, unless you want to patch Django or python ;-)
> >
> > The concept of a default encoding is doomed, and python has finally
> > learned the lesson. I guess that you can use unicode(bytestring)
> > without giving an encoding at all is a trap that stems from times
> > when python had a settable default encoding. ASCII is used as a
> > default encoding in these circumstances. The same applies for
> > str(unicode_string) or for (bytestring == unicode_string). All these
> > are traps, traps, traps.
> >
> > There is a hook in site.py, but this was left in for experiments. If
> > you use it, you'll probably get into devil's kitchen.
> >
> >
> > Michael
> >
> >
> > --
> > noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
> > Tel +49-911-9352-0 - Fax +49-911-9352-100
> >
> > http://www.noris.de - The IT-Outsourcing Company
> >
> > > >
> >
>

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-02-01 Thread Sebastien Armand [Pink]
Oooops didn't read enaough from the #3387 ticket. So I'll open one!
Thanks a lot for your explanations.

2007/2/1, Michael Radziej <[EMAIL PROTECTED]>:
>
>
> Sebastien Armand [Pink]:
> > No problem, thanks!
> >
> > There's already a ticket, it's here:
> > http://code.djangoproject.com/ticket/3387
>
> No, thanks for searching, but it's not. #3387 was triggered by using
>
> queryset.filter(unicode_string)
>
> You didn't use a unicode_string within filter(), though the
> traceback is similar. It happened because Django's ORM internal code
> looks up the related records to a foreign key with filter(), and
> uses a unicode string because because newforms put it in the model.
>
> It's a new bug, but the patch in the #3387 should heal it. Funny.
> Please *do* open a ticket. #3387 is closed. I'm now pretty sure that
> your case has not been reported before.
>
> > But though, is there another encoding I could use and how do I specify
> it?
>
> Short answer: No, unless you want to patch Django or python ;-)
>
> The concept of a default encoding is doomed, and python has finally
> learned the lesson. I guess that you can use unicode(bytestring)
> without giving an encoding at all is a trap that stems from times
> when python had a settable default encoding. ASCII is used as a
> default encoding in these circumstances. The same applies for
> str(unicode_string) or for (bytestring == unicode_string). All these
> are traps, traps, traps.
>
> There is a hook in site.py, but this was left in for experiments. If
> you use it, you'll probably get into devil's kitchen.
>
>
> Michael
>
>
> --
> noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
> Tel +49-911-9352-0 - Fax +49-911-9352-100
>
> http://www.noris.de - The IT-Outsourcing Company
>
> >
>

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-02-01 Thread Michael Radziej

Sebastien Armand [Pink]:
> No problem, thanks!
> 
> There's already a ticket, it's here:
> http://code.djangoproject.com/ticket/3387

No, thanks for searching, but it's not. #3387 was triggered by using

queryset.filter(unicode_string)

You didn't use a unicode_string within filter(), though the
traceback is similar. It happened because Django's ORM internal code
looks up the related records to a foreign key with filter(), and
uses a unicode string because because newforms put it in the model.

It's a new bug, but the patch in the #3387 should heal it. Funny.
Please *do* open a ticket. #3387 is closed. I'm now pretty sure that
your case has not been reported before.

> But though, is there another encoding I could use and how do I specify it?

Short answer: No, unless you want to patch Django or python ;-)

The concept of a default encoding is doomed, and python has finally
learned the lesson. I guess that you can use unicode(bytestring)
without giving an encoding at all is a trap that stems from times
when python had a settable default encoding. ASCII is used as a
default encoding in these circumstances. The same applies for
str(unicode_string) or for (bytestring == unicode_string). All these
are traps, traps, traps.

There is a hook in site.py, but this was left in for experiments. If
you use it, you'll probably get into devil's kitchen.


Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-02-01 Thread Sebastien Armand [Pink]
No problem, thanks!

There's already a ticket, it's here:
http://code.djangoproject.com/ticket/3387

But though, is there another encoding I could use and how do I specify it?

2007/2/1, Michael Radziej <[EMAIL PROTECTED]>:
>
>
> Hi Sebastien,
>
> I don't see where the exact problem is and whether there's already a
> ticket, but this is a bug within the newforms package. It is caused
> due to newforms putting unicode into the models, but most parts of
> Django are not unicode ready. You can search in the existing tickets
> (with category == 'newforms') whether there's already a patch.
>
> If not, could you please open a new ticket and provide exactly the
> information from the mail I'm replying to? If you put {{{ and }}}
> around the traceback and the code, it won't look as bad as in email
> (it's always like this in mail). And please put a link to this
> thread's google archive, if you can.
>
> Sebastien Armand [Pink]:
> > So the exact unicode error is:
> >
> > UnicodeEncodeError at /entreprise/search/ 'ascii' codec can't encode
> > character u'\xe9' in position 1: ordinal not in range(128) Request
> Method:
> > POST  Request URL: http://localhost/entreprise/search/  Exception Type:
> > UnicodeEncodeError  Exception Value: 'ascii' codec can't encode
> character
> > u'\xe9' in position 1: ordinal not in range(128)  Exception Location:
> > c:\Python25\lib\site-packages\django\db\models\fields\__init__.py
> > in , line 25
> >
> > with the following traceback:
> >
> > Traceback (most recent call last):
> > File "c:\Python25\lib\site-packages\django\template\__init__.py" in
> > render_node
> >   712. result = node.render(context)
> > File "c:\Python25\lib\site-packages\django\template\defaulttags.py" in
> > render
> >   100. len_values = len(values)
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> __len__
> >   100. return len(self._get_data())
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> _get_data
> >   430. self._result_cache = list(self.iterator())
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> iterator
> >   171. select, sql, params = self._get_sql_clause()
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> > _get_sql_clause
> >   444. joins2, where2, params2 = self._filters.get_sql(opts)
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> get_sql
> >   574. joins2, where2, params2 = val.get_sql(opts)
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> get_sql
> >   622. return parse_lookup(self.kwargs.items(), opts)
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> > parse_lookup
> >   743. joins2, where2, params2 = lookup_inner(path, lookup_type, value,
> > opts, opts.db_table, None)
> > File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> > lookup_inner
> >   915. params.extend(field.get_db_prep_lookup(lookup_type, value))
> > File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py"
> in
> > get_db_prep_lookup
> >   172. return ["%%%s%%" % prep_for_like_query(value)]
> > File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py"
> in
> >   25. prep_for_like_query = lambda x: str(x).replace("\\",
> > "").replace("%", "\%").replace("_", "\_")
>
> the str(x) throws this exception when x is not an ASCII character.
>
> >
> >   UnicodeEncodeError at /entreprise/search/
> >   'ascii' codec can't encode character u'\xe9' in position 1: ordinal
> not in
> > range(128)
>
> Michael
>
> --
> noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
> Tel +49-911-9352-0 - Fax +49-911-9352-100
>
> http://www.noris.de - The IT-Outsourcing Company
>
> >
>

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-01-31 Thread Sebastien Armand [Pink]
Wow, sorry, I copied paste and didn't see the font was so awful!

2007/1/31, Sebastien Armand [Pink] <[EMAIL PROTECTED]>:
>
> So the exact unicode error is:
>
> UnicodeEncodeError at /entreprise/search/ 'ascii' codec can't encode
> character u'\xe9' in position 1: ordinal not in range(128) Request Method:
> POST  Request URL: http://localhost/entreprise/search/  Exception Type:
> UnicodeEncodeError  Exception Value: 'ascii' codec can't encode character
> u'\xe9' in position 1: ordinal not in range(128)  Exception Location: 
> c:\Python25\lib\site-packages\django\db\models\fields\__init__.py
> in , line 25
>
> with the following traceback:
>
> Traceback (most recent call last):
> File "c:\Python25\lib\site-packages\django\template\__init__.py" in
> render_node
>   712. result = node.render(context)
> File "c:\Python25\lib\site-packages\django\template\defaulttags.py" in
> render
>   100. len_values = len(values)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in __len__
>   100. return len(self._get_data())
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> _get_data
>   430. self._result_cache = list(self.iterator())
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in iterator
>   171. select, sql, params = self._get_sql_clause()
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> _get_sql_clause
>   444. joins2, where2, params2 = self._filters.get_sql(opts)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in get_sql
>   574. joins2, where2, params2 = val.get_sql(opts)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in get_sql
>   622. return parse_lookup(self.kwargs.items(), opts)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> parse_lookup
>   743. joins2, where2, params2 = lookup_inner(path, lookup_type, value,
> opts, opts.db_table, None)
> File "c:\Python25\lib\site-packages\django\db\models\query.py" in
> lookup_inner
>   915. params.extend(field.get_db_prep_lookup(lookup_type, value))
> File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py"
> in get_db_prep_lookup
>   172. return ["%%%s%%" % prep_for_like_query(value)]
> File "c:\Python25\lib\site-packages\django\db\models\fields\__init__.py"
> in
>   25. prep_for_like_query = lambda x: str(x).replace("\\",
> "").replace("%", "\%").replace("_", "\_")
>
>   UnicodeEncodeError at /entreprise/search/
>   'ascii' codec can't encode character u'\xe9' in position 1: ordinal not
> in range(128)
>
> ___
> And finally, here's my search view:
>
> def search_entreprise(request):
> form = EntrepriseSearchForm()
> if request.method=='POST':
> new_data = request.POST.copy()
> form = EntrepriseSearchForm(new_data)
> if form.is_valid():
> data = form.clean_data
> entreprise_list = Entreprise.objects.all()
> if data['domaine']:
>
> entreprise_list=entreprise_list.filter(domaine=data['domaine'])
> if data['entrepriseMere']:
>
> entreprise_list=entreprise_list.filter(entrepriseMere=data['entrepriseMere'])
> if data['nom']:
>
> entreprise_list=entreprise_list.filter(nom__icontains=data['nom'])
> return
> render_to_response('stagesECL/entreprise_list.html',{'list':entreprise_list,})
> return
> render_to_response('stagesECL/entreprise_search.html',{'form':form,})
>
>
> where in this case the only information given is the entreprise name (nom)
> which had the value "hé".
>
> I tried to change the encoding in the html but this doedn't seem to
> help
> Hope somebody knows how to do this!
>
> 2007/1/31, Kenneth Gonsalves <[EMAIL PROTECTED]>:
> >
> >
> >
> > On 30-Jan-07, at 6:26 PM, Sebastien Armand [Pink] wrote:
> >
> > > Example with a school and a student class. Each student has a
> > > foreign key linking to the school where he studies. Through a form,
> > > I get the informations to create the student including the school's
> > > id. When I want to create and save the student, am I obliged to
> > > first hit the database to get the school object and then pass it to
> > > student(school=school_object) or is there a way to just use the ID
> > > as it is?
> >
> > in the database django stores this as school_id - and when you save
> > you can use that by specificaly setting school_id on the save instead
> > of school where django will automatically get and insert the id
> >
> > --
> >
> > regards
> > kg
> > http://lawgon.livejournal.com
> > http://nrcfosshelpline.in/web/
> >
> >
> >
> > > >
> >
>

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-01-30 Thread Michael Radziej

Sebastien Armand [Pink]:
> - When I search something in my database, using icontains on a field, it
> doesn't work when there are non-asccii characters: a product field may
> contain (in french so with accents!!) télévision but when I look for "télé"
> I get a unicode error. If I look for "vision" everything works just fine.
> Any idea why?

What did you do exactly to search, and what is the exact backtrace?

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100

http://www.noris.de - The IT-Outsourcing Company

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-01-30 Thread Sebastien Armand [Pink]
As you talk about this, if I remember well, the database is UTF-8 but the
web page which contains the form has no encoding declared. May this be the
source of troubles?

2007/1/30, James Tauber <[EMAIL PROTECTED]>:
>
>
>
> On Tue, 30 Jan 2007 13:56:12 +0100, "Sebastien Armand [Pink]"
> <[EMAIL PROTECTED]> said:
> > - When I search something in my database, using icontains on a field, it
> > doesn't work when there are non-asccii characters: a product field may
> > contain (in french so with accents!!) télévision but when I look for
> > "télé"
> > I get a unicode error. If I look for "vision" everything works just
> fine.
> > Any idea why?
>
> Sounds like one is a Unicode object and the other an encoded string
> (maybe UTF-8 or Latin-1).
>
> James
> --
>   James Tauber   http://jtauber.com/
>   journeyman of somehttp://jtauber.com/blog/
>
>
> >
>

--~--~-~--~~~---~--~~
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: 2 Questions!

2007-01-30 Thread James Tauber


On Tue, 30 Jan 2007 13:56:12 +0100, "Sebastien Armand [Pink]"
<[EMAIL PROTECTED]> said:
> - When I search something in my database, using icontains on a field, it
> doesn't work when there are non-asccii characters: a product field may
> contain (in french so with accents!!) télévision but when I look for
> "télé"
> I get a unicode error. If I look for "vision" everything works just fine.
> Any idea why?

Sounds like one is a Unicode object and the other an encoded string
(maybe UTF-8 or Latin-1).

James
-- 
  James Tauber   http://jtauber.com/
  journeyman of somehttp://jtauber.com/blog/


--~--~-~--~~~---~--~~
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: 2 Questions!

2007-01-30 Thread Sebastien Armand [Pink]
It helps!

I'll check better for the encoding problems...

2007/1/30, [EMAIL PROTECTED] <[EMAIL PROTECTED]>:
>
>
> 1. No, you can create a student with: Student.objects.create(name="Foo
> Bar", school_id=2)
>
> 2. Not sure... I have a Django application here, and when I search for
> "è", it returns the restaurant "Les Deux Frères" without problems.
> Could be an encoding problem with your database or with your terminal
> or with Python.  That's the problem with encoding issues: they take a
> lot of time to figure out and properly fix.
>
> Hope this helps.
>
> Vincent.
>
> On Jan 30, 7:56 am, "Sebastien Armand [Pink]" <[EMAIL PROTECTED]>
> wrote:
> > I've been trying Django and have 2 small problems:
> >
> > - When I have a foreign key field in a model, is it possible to use just
> the
> > id of the foreign object or do we always have to use the object itself?
> > Example with a school and a student class. Each student has a foreign
> key
> > linking to the school where he studies. Through a form, I get the
> > informations to create the student including the school's id. When I
> want to
> > create and save the student, am I obliged to first hit the database to
> get
> > the school object and then pass it to student(school=school_object) or
> is
> > there a way to just use the ID as it is?
> >
> > - When I search something in my database, using icontains on a field, it
> > doesn't work when there are non-asccii characters: a product field may
> > contain (in french so with accents!!) télévision but when I look for
> "télé"
> > I get a unicode error. If I look for "vision" everything works just
> fine.
> > Any idea why?
> >
> > 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: 2 Questions!

2007-01-30 Thread [EMAIL PROTECTED]

1. No, you can create a student with: Student.objects.create(name="Foo 
Bar", school_id=2)

2. Not sure... I have a Django application here, and when I search for 
"è", it returns the restaurant "Les Deux Frères" without problems.  
Could be an encoding problem with your database or with your terminal 
or with Python.  That's the problem with encoding issues: they take a 
lot of time to figure out and properly fix.

Hope this helps.

Vincent.

On Jan 30, 7:56 am, "Sebastien Armand [Pink]" <[EMAIL PROTECTED]> 
wrote:
> I've been trying Django and have 2 small problems:
>
> - When I have a foreign key field in a model, is it possible to use just the
> id of the foreign object or do we always have to use the object itself?
> Example with a school and a student class. Each student has a foreign key
> linking to the school where he studies. Through a form, I get the
> informations to create the student including the school's id. When I want to
> create and save the student, am I obliged to first hit the database to get
> the school object and then pass it to student(school=school_object) or is
> there a way to just use the ID as it is?
>
> - When I search something in my database, using icontains on a field, it
> doesn't work when there are non-asccii characters: a product field may
> contain (in french so with accents!!) télévision but when I look for "télé"
> I get a unicode error. If I look for "vision" everything works just fine.
> Any idea why?
>
> 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
-~--~~~~--~~--~--~---



2 Questions!

2007-01-30 Thread Sebastien Armand [Pink]
I've been trying Django and have 2 small problems:

- When I have a foreign key field in a model, is it possible to use just the
id of the foreign object or do we always have to use the object itself?
Example with a school and a student class. Each student has a foreign key
linking to the school where he studies. Through a form, I get the
informations to create the student including the school's id. When I want to
create and save the student, am I obliged to first hit the database to get
the school object and then pass it to student(school=school_object) or is
there a way to just use the ID as it is?


- When I search something in my database, using icontains on a field, it
doesn't work when there are non-asccii characters: a product field may
contain (in french so with accents!!) télévision but when I look for "télé"
I get a unicode error. If I look for "vision" everything works just fine.
Any idea why?

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: 2 questions

2006-10-05 Thread dgk

Thanks RajeshD


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: 2 questions

2006-10-04 Thread RajeshD

1. I am not sure about this one.

2. You will also need blank=True in addition to null=True in those
nullable fields.


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



2 questions

2006-10-04 Thread dgk

1. I've changed the TIME_ZONE in settings.py to 'Europe/Moscow'. Time
values saved in the database are 3 hours lesser than the times of
writing (now should be 4 hours of difference). When I open records in
the admin I see the same values as in the database. Can I see the local
time values in the admin?

2. There are nullable fields in my models.py (an option null = True was
used), but I can't add a record with an empty field using the admin.
There're no problems to do it In the "python manage.py shell".


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---