On Wed, Apr 4, 2012 at 4:07 AM, Tom Evans wrote:
> One pretty cool method I've used for live debugging in the past is to
> 'log' to rabbitmq (Note - not celery - raw amqp), and send messages to
> a logging exchange. You can use a topic key so that different
> processes can be distinguished.
a sim
On Tue, Apr 3, 2012 at 11:25 PM, Andre Terra wrote:
> Hey Javier,
>
> Thanks for the reply. My problem with the logs in the past was that they
> tended to make the task even slower (due to recursion) but I guess that's
> probably because I didn't call the logging from the appropriate places in
> t
On Tue, Apr 3, 2012 at 5:25 PM, Andre Terra wrote:
> To make things a little more complicated, the task involves writing a large
> amount of data to a temp database, handling it and then saving some
> resulting queries to the permanent DB. This makes it a tad harder to analyze
> what goes on in th
Hey Javier,
Thanks for the reply. My problem with the logs in the past was that they
tended to make the task even slower (due to recursion) but I guess that's
probably because I didn't call the logging from the appropriate places in
the code.
To make things a little more complicated, the task inv
On Tue, Apr 3, 2012 at 8:21 AM, Andre Terra wrote:
> I have some complex and database intensive asynchronous tasks running under
> celery which take a LONG time to complete and I'd just love to be able to
> keep track of the queries they generate in order to optimize and possibly
> remove the bigg
While I know of the two methods mentioned by Anssi, I've often wondered how
to profile my code from a project level.
I have some complex and database intensive asynchronous tasks running under
celery which take a LONG time to complete and I'd just love to be able to
keep track of the queries they
(edit existing methods, add new methods..) the generated
database api it would be good.
Thanks again,
Kasun
On Apr 3, 1:41 pm, akaariai wrote:
> On Apr 3, 11:27 am, KasunLak wrote:
>
> > Hi,
>
> > No, sorry for not giving more details. What I am asking is once we
> > syn
On Apr 3, 11:27 am, KasunLak wrote:
> Hi,
>
> No, sorry for not giving more details. What I am asking is once we
> syncdb the generated scripts (create table). Can we see the method
> implementation of database access api?
>
> For example: If we have created and deployed a model called Poll
> (tut
; python manage.py sql APPNAME
>
>
>
>
>
>
>
> On Tue, Apr 3, 2012 at 8:45 AM, KasunLak wrote:
> > Hi all,
>
> > I just wonder is there a way to browse/view the code of database api
> > methods generated? Is there any tool for this?
>
> > Thanks
Hi,
Do you mean the SQL generated by your model?
In this case you can use
python manage.py sql APPNAME
On Tue, Apr 3, 2012 at 8:45 AM, KasunLak wrote:
> Hi all,
>
> I just wonder is there a way to browse/view the code of database api
> methods generated? Is there any t
Hi all,
I just wonder is there a way to browse/view the code of database api
methods generated? Is there any tool for this?
Thanks in advance,
Kasun
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email
Ah, most enlightening and makes perfect sense, thanks Tom!
? 11 ?.?. 2553 21:45 Tom Evans ?:
> 2010/10/11 Jonathan Barratt :
>> On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:
>> Note also that, AFAIK, multiple where criteria are accomplished by chaining
>> filters rather than
@Jonathan, thanks. That does the trick.
@Tom, thanks for bringing the subtle, yet important, difference between the
two forms of that expression to my attention.
2010/10/11 Tom Evans
> 2010/10/11 Jonathan Barratt :
> > On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:
> > Note also that
2010/10/11 Jonathan Barratt :
> On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:
> Note also that, AFAIK, multiple where criteria are accomplished by chaining
> filters rather than providing them as a list to one filter call.
> But I am new to Django myself, so if anyone corrects this advi
On 11 ?.?. 2010, at 21:05, Sithembewena Lloyd Dube wrote:
> Hi all,
>
> How does one filer objects by "smaller than" criteria in the data access API?
> For example, in the following line:
I believe it's by appending the field name with _lte
> MySite.objects.filter(rank < 11, display_on_site =
Hi all,
How does one filer objects by "smaller than" criteria in the data access
API? For example, in the following line:
MySite.objects.filter(*rank < 11*, display_on_site = 1).order_by('rank') -
how would one handle the highlighted criterion?
Thanks.
--
Regards,
Sithembewena Lloyd Dube
http:
Hi everybody,
I'm writing an open source asset,resource and project manager for animation
and vfx studios. And I want to use Django's database api to handle all the
db stuff. In my system every project is going to have its own database
(probably sqlite3 files in project root folder).
database? I'm hoping to have the Django app
> >>>> sitting on the web server, with the source tree inaccessible to a bunch
> >>>> of workstations. ...
>
> >>> If you just want the Django database API, then put the Django code
> >>> (i.e., django.
James Bennett wrote:
On Sun, Oct 26, 2008 at 9:19 PM, Steve Holden <[EMAIL PROTECTED]> wrote:
Here's a specific example of a piece of code that uses a web app's
models. It should get you started - just dive in and write some code!
The tricky bit is providing the settings without u
On Sun, Oct 26, 2008 at 9:19 PM, Steve Holden <[EMAIL PROTECTED]> wrote:
> Here's a specific example of a piece of code that uses a web app's
> models. It should get you started - just dive in and write some code!
> The tricky bit is providing the settings without using a "settings"
> module. I ca
>>>> My question is how to package up and deploy the Django python code for
>>>> external tools to access the database? I'm hoping to have the Django app
>>>> sitting on the web server, with the source tree inaccessible to a bunch
>>>> of w
de for
>>> external tools to access the database? I'm hoping to have the Django app
>>> sitting on the web server, with the source tree inaccessible to a bunch
>>> of workstations. ...
>> If you just want the Django database API, then put the Django code
>>
sitting on the web server, with the source tree inaccessible to a bunch
>> of workstations. ...
> If you just want the Django database API, then put the Django code
> (i.e., django.*) on the workstations, and just write your tools to
> import that code, setting up DJANGO_SETTINGS_M
> looking at Django is because I also need python access to all the same
> data that the web app is dealing with. The Django database API seems
> great, but I can only easily run it on the web app server.
I'm not sure why you think this. The Django database API is just a
bunch of Python
jango database API seems
great, but I can only easily run it on the web app server.
My question is how to package up and deploy the Django python code for
external tools to access the database? I'm hoping to have the Django app
sitting on the web server, with the source tree inaccessible
On 2 Sep., 23:14, Malcolm Tredinnick <[EMAIL PROTECTED]> wrote:
> On Tue, 2008-09-02 at 13:12 -0700,janedenonewrote:
> > Hi,
>
> > I am in the process of moving my handmade website to a Django-based
> > version. One of my SQL queries returns all articles by a certain
> > author if this article is
On Tue, 2008-09-02 at 13:12 -0700, janedenone wrote:
> Hi,
>
> I am in the process of moving my handmade website to a Django-based
> version. One of my SQL queries returns all articles by a certain
> author if this article is not a chapter or section of an article by
> the same author:
>
> SELE
FROM pages, pages AS motherpages
WHERE motherpages.page_id = pages.mother_id
AND pages.author_id = 1234
AND pages.author_id <> motherpages.author_id
Is it possible to do this with the Django database API, or do I need
to retreat to custom SQL?
Kind regard
On Tue, Aug 26, 2008 at 4:41 PM, Andrew D. Ball <[EMAIL PROTECTED]>wrote:
>
> Is there a convenient way to get all objects related to
> a given model instance? I want to check for objects
> that would be deleted with a cascading delete before
> actually performing a deletion.
>
The admin does th
Is there a convenient way to get all objects related to
a given model instance? I want to check for objects
that would be deleted with a cascading delete before
actually performing a deletion.
Peace,
Andrew
--
===
Andrew D. Ball
[EMAIL PROTECTED]
Software Enginee
On Sat, Jun 14, 2008 at 8:26 PM, LB <[EMAIL PROTECTED]> wrote:
>
> Thanks for the fast replies !
No problems.
> So I think I only have three options now :
>
> 1) change my model and replace the naissance field with three fields
> corresponding to birth day, birth month and birth year.
This is
Thanks for the fast replies !
> So - what you were trying to do was combine the `month` and `gt`
> operators - you can't do that. Django interpreted your query as 'join
> the Contact with the naissance table, and check that the month
> attribute is greater than 5'. Obviously, this doens't work be
On Sat, Jun 14, 2008 at 7:36 PM, LB <[EMAIL PROTECTED]> wrote:
>
> Thanks,
>
> Another question :
>
> why does
> anniv = Contact.objects.filter(naissance__month=5)
> works
>
> and
> anniv = Contact.objects.filter(naissance__month__gt=5)
> raise this exception :
> : Join on field 'naissance'
> not
Thanks,
Another question :
why does
anniv = Contact.objects.filter(naissance__month=5)
works
and
anniv = Contact.objects.filter(naissance__month__gt=5)
raise this exception :
: Join on field 'naissance'
not permitted.
--~--~-~--~~~---~--~~
You received this mess
On Sat, Jun 14, 2008 at 6:56 PM, LB <[EMAIL PROTECTED]> wrote:
>
> 1 ) how to get all contacts with a known birthday ? I tried :
>
> m = Contact.objects.filter(naissance__is_null=False)
> but I got the following exception :
> : Join on field 'naissance'
> not permitted.
You are close - but with
Hi,
I'm new to django and also new to databases. I'm trying to make a
simple contact editor.
So I created the following model :
class Contact(models.Model):
nom_famille = models.CharField("nom de famille", max_length=30)
# french for last name
prenom = models.CharField("prénom",
Aaah, I missed another dict... Thanks for setting it right.
--~--~-~--~~~---~--~~
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
You forgot to use person in front of the values of course, since
they're still attributes of that dict :)
So instead of pnr which is just printing static text "pnr",
you need to do {{ person.pnr }} just like every other
variable access :)
--~--~-~--~~~---~--~~
You
On Apr 2, 7:08 pm, Jaap <[EMAIL PROTECTED]> wrote:
> Still Greek to me... So far I did it like this:
>
> [view]
> def start(request):
> group = Staff.objects.values('pnr', 'last_name')
> return render_to_response('tlist.html', group)
>
> [template]
>
> {% for person in group %}
>
>
Still Greek to me... So far I did it like this:
[view]
def start(request):
group = Staff.objects.values('pnr', 'last_name')
return render_to_response('tlist.html', group)
[template]
{% for person in group %}
pnr
last_name
{% endfor %}
Where did I go wrong?
In [3]: Page.objects.values('id', 'title')
Out[3]: [{'id': 1, 'title': u'This is a test page'}]
In [4]: Page.objects.values('id', 'title').filter(id__gt=1)
Out[4]: []
On Apr 2, 12:22 pm, Jaap <[EMAIL PROTECTED]> wrote:
> QuerySet methods that return new QuerySets:
> values(*fields)
>
> Could an
QuerySet methods that return new QuerySets:
values(*fields)
Could anyone please give an example of this, using view and template?
I have read the example using the interpreter, and cannot get it to
work in view/template. FYI: I use version 0.96.1, Windows XP.
--~--~-~--~~
That would be User_Friend.objects.filter(from_user=user, active=True,
to_user__name__startswith=q)
On Jan 25, 12:44 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hello,
>
> I need help making a query with django with I'm not sure it's
> possible.
>
> I have
>
> model:
> class User_Friend(m
Hello,
I need help making a query with django with I'm not sure it's
possible.
I have
model:
class User_Friend(models.Model):
from_user = models.ForeignKey(User, related_name='from_user')
to_user = models.ForeignKey(User, null=True,
related_name='to_user')
active = models.BooleanFie
On 2007-12-17 22:41:08 -0700, Kenneth Gonsalves <[EMAIL PROTECTED]> said:
>
>
> On 18-Dec-07, at 10:33 AM, MrJogo wrote:
>
>> What's the practical difference between calling
>> DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
>> **kwargs can be whichever paramenters)? I understa
I understand now. Thanks.
On Dec 17, 9:11 pm, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote:
> On 18-Dec-07, at 10:33 AM, MrJogo wrote:
>
> > What's the practical difference between calling
> > DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
> > **kwargs can be whichever paramenters
On 18-Dec-07, at 10:33 AM, MrJogo wrote:
> What's the practical difference between calling
> DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
> **kwargs can be whichever paramenters)? I understand that filter
> returns a QuerySet, but I don't really get how that affects me or my
>
What's the practical difference between calling
DB.objects.filter(**kwargs) and DB.objects.get(**kwargs) (where
**kwargs can be whichever paramenters)? I understand that filter
returns a QuerySet, but I don't really get how that affects me or my
code.
--~--~-~--~~~---~-
On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:
>
> Ok, thank you... that's standard python stuff. It's no secret, that
> I'm new to python :-(
> But I found another solution. I don't really now which on is the
> better one?!
>
> partnerlist = [ep.partner for ep in
> Event.objects.latest
> ('date').eve
On Nov 4, 7:02 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:
>
>
>
> > > partner_list = [ep.partner for ep in Event.objects.latest
> > > ('date').eventpartner_set.all()]
>
> > Ok, that works! But there is another problem now. I would like to sort
> >
On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:
>
> >
> > partner_list = [ep.partner for ep in Event.objects.latest
> > ('date').eventpartner_set.all()]
>
> Ok, that works! But there is another problem now. I would like to sort
> the list of partners.
> The sort-criteria should be a field from the part
On Nov 4, 4:14 pm, "Karen Tracey" <[EMAIL PROTECTED]> wrote:
> On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:[snip]
>
> To get the last event I use:
>
> > Event.objects.latest('date')
>
> > To get a list of EventPartners i use:
> > Event.objects.latest('date').eventpartner_set.all()
>
> > But how d
On 11/4/07, Brot <[EMAIL PROTECTED]> wrote:[snip]
To get the last event I use:
> Event.objects.latest('date')
>
> To get a list of EventPartners i use:
> Event.objects.latest('date').eventpartner_set.all()
>
> But how do I get a list of my Partners? I tried a few things, but I
> didn't find a solu
dels.Model):
event = models.ForeignKey(Event)
partner = models.ForeignKey(Partner)
relationtype = models.CharField(max_length=2,
choices=RELATIONTYPE_CHOICES)
...
I want to have all Partners from the last event.
Is there a simple query-solution with the django database-api? With a
st
Also, if I'm not mistaken, when you use the database api, the input
validation steps are taken care of by the framework, you don't just
tell in the models what format fields should be in the database, but
at the same time are telling the framework what input it should accept
for that f
> >>> users = User.objects.filter(groups__contains="Staff") ?
This line doesn't work because "groups" is a ManyToManyField, not a
CharField, so __contains="Staff" doesn't make any sense.
Something like users = User.objects.filter(groups__name="Staff")
should work a little better :)
--~--~-
On 8/13/07, Amirouche <[EMAIL PROTECTED]> wrote:
> What do you mean, I can't understand.
OK, suppose you are running an online store, so you have a database
table "orders", which lists orders customers have placed, and another
"addresses" which lists the addresses to ship the orders to. To
calcul
On Aug 13, 3:19 pm, "James Bennett" <[EMAIL PROTECTED]> wrote:
> On 8/13/07, sagi s <[EMAIL PROTECTED]> wrote:
>
> > Surely not. It is... darn - Can I just use SQL and be done with it?
>
> Of course.
>
> But keep in mind that, when programming in an object-oriented
> language, it's often more us
On 8/13/07, sagi s <[EMAIL PROTECTED]> wrote:
> Surely not. It is... darn - Can I just use SQL and be done with it?
Of course.
But keep in mind that, when programming in an object-oriented
language, it's often more useful to get back a set of domain-specific
objects -- which requires using Djang
I've been playing around with Django for a couple of weeks.
I'm finding myself spending most of my type tinkering with the
Database API to try to wrestle the information I need out of my
database.
At this point it looks to me like I have replaced one set of
incantations (SQL) f
> Apparently it's a bug in the version of sqlite that's bundled with the
> Windows installer (3.3.4).
The Python 2.5 installer, that is. . .
--
-Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
"Django use
I see where this has already been addressed in ticket #2457
http://code.djangoproject.com/ticket/2457
Apparently it's a bug in the version of sqlite that's bundled with the
Windows installer (3.3.4).
The command line version of sqlite that I'm running is much more
recent, which explains the dif
> Might be worthwhile having a look at the SQL Django is generating. From
> the shell prompt import db.connection and have a look at
> db.connection.queries after running the query.
>
> I wouldn't be too surprised to discover this is a bug caused by using a
> left outer join here, in which case it
On Wed, 2007-05-16 at 20:53 -0500, Ben Jones wrote:
> Thanks for the help, Russ.
>
>
> > > For test data, I have entered 3 categories and 3 pieces of content
> > > (one in each of the 3 categories).
> >
> > You have 3 categories and 3 content objects, but what is in the m2m
> > table between the
Thanks for the help, Russ.
> > For test data, I have entered 3 categories and 3 pieces of content
> > (one in each of the 3 categories).
>
> You have 3 categories and 3 content objects, but what is in the m2m
> table between them? What is the matrix of category/content
> relationships?
It's the
On 5/17/07, Ben Jones <[EMAIL PROTECTED]> wrote:
>
> I have 2 models that I'm using "for training": Content and Category
> with a ManyToMany field in Content to relate them.
>
> For test data, I have entered 3 categories and 3 pieces of content
> (one in each of the 3 categories).
You have 3 cate
First, since this is my first post to this group, let me say that
Django is phenomenal. So serious. In fact, "phenomenal" doesn't even
begin to scratch the surface . . . using that phrase to describe it is
an insult! Many, many thanks to everyone who has contributed!
On to business . . .
I have
On Wed, 2007-04-18 at 19:57 -0300, Luiz Carlos Geron wrote:
> Hi,
> I have three models, listed at [1], that I want to get data from with
> only one query, because of performance issues with my app. The way
> that worked so far is:
>
> league_ids = [12, 21]
> bets =
> models.Bet.objects.filter(g
Any ideas on how I can do this with one query?
On 4/18/07, Luiz Carlos Geron <[EMAIL PROTECTED]> wrote:
> Hi,
> I have three models, listed at [1], that I want to get data from with
> only one query, because of performance issues with my app. The way
> that worked so far is:
>
> league_ids = [12,
Hi,
I have three models, listed at [1], that I want to get data from with
only one query, because of performance issues with my app. The way
that worked so far is:
league_ids = [12, 21]
bets =
models.Bet.objects.filter(game__league__id__in=league_ids).order_by('bet__game__league.id',
'game_part'
On 1/22/07, Tim Chase <[EMAIL PROTECTED]> wrote:
> Or, alternatively, one could do something like
>
> SELECT c.* FROM camps c INNER JOIN application a ON c.id = a.camp_id
>
> which might also be another way to let the optimizer take a crack
> at doing it well.
Yeah, though AFAIK the 'extra' metho
> SELECT * FROM camps where id in (SELECT DISTINCT camp_id FROM application);
Computing the DISTINCT portion here may be superfluous, and
possibly (depending on your DB) a premature mis-optimization.
Whether DISTINCT or not, membership via IN will still behave the
same, but DISTINCT will requi
On 1/22/07, Chris Brand <[EMAIL PROTECTED]> wrote:
> I have an app with Applications, each of which is for a single Camp.
> What I want to do is retrieve all the Camps for which there exists an
> Application.
The straightforward way is to retrieve a list of distinct values for
'camp_id' from the
I have the feeling that this is something that should be straightforward,
but I can't see how to do it.
I have an app with Applications, each of which is for a single Camp.
What I want to do is retrieve all the Camps for which there exists an
Application.
Thanks,
Chris
--~--~-~--~--
On 12/10/06, Darin Lee <[EMAIL PROTECTED]> wrote:
> In the console, if I populate the Contest, the instance produces a
> "category_set" method/property (as expected and documented). However,
> if you "dir(c.category_set)" there is no "finalist_set" method/
> property in the category_set's namespac
Hi All,
Just curious, does the Django Database API support nested
relationships more than one level deep? It's starting to look like it
doesn't... for example, let's say I have three tables: Contest,
Categories, and Finalists; related as such: Contest, Category foreign
>
> p.id = ??? (max_id in table + 1 or NOT SET > but how can i do
> this)
> p.save()
Try:
p.id = None
p.save()
Django will select the next id in the sequence for your new product.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to
Hi,
to those who are experienced in django: i just want to avoid making
mistakes at the database level.
intro: I have an existing produkt p (class produkt) in the database. It
has a few other keys to the table attribute. So attribute (class
attribute) has a ForeignKey to produkt.
todo: Take the
DavidA wrote:
> Suriya,
>
> You will probably have to do this in custom SQL or using extra(). Your
> query requires a subselect to get the "current B's" (B's with max(date)
> for each A).
>
> Here's the SQL that I think you need (if I understand the problem
> correctly):
>
> select * from _A join
Suriya wrote:
> This returns the list of rows in table A that have status
> in table B set to 1 at some point in the past. What I want
> is the latest status from table B.
I see. Yes, you can either use a (grouping) custom SQL query or
refactor.
How I would do it is to have just one model (B)
Suriya,
You will probably have to do this in custom SQL or using extra(). Your
query requires a subselect to get the "current B's" (B's with max(date)
for each A).
Here's the SQL that I think you need (if I understand the problem
correctly):
select * from _A join _B on _B.a_id = _A.id
where _B.
SmileyChris wrote:
> How about just making the query like this:
>
> A.objects.filter(b__status=1)
This returns the list of rows in table A that have status
in table B set to 1 at some point in the past. What I want
is the latest status from table B. For example, if table B
has the two entries:
How about just making the query like this:
A.objects.filter(b__status=1)
--~--~-~--~~~---~--~~
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 u
Hi all,
I have a situation here where I do not know how to use
the filter() function in the database API to obtain a
QuerySet. I am describing the schema and what I have
done, below. I hope you have an answer to my question.
# Only the necessary fields are shown here
class A(models.Model
On 7/29/06, Gennan Chen <[EMAIL PROTECTED]> wrote:
> I will like to django's ORM in my standalone app (not web app). Do I always
> its admin tool to create tables? Or it can reuse the table structure I
> create in the db?
You should be able to use the Django ORM on an existing database (not
that
Hi!I will like to django's ORM in my standalone app (not web app). Do I always its admin tool to create tables? Or it can reuse the table structure I create in the db? Gen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Group
Jeremy Dunck wrote:
> I've seen some situations where multiple encodings were stuck into the
> same column, and you don't want to go there.
I can believe that :-/
That for the advice. Things seem to be working now I've encoded into
utf-8. Even Django's admin interface seems to understand utf-8
On 6/30/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote:
> On 6/30/06, Paul <[EMAIL PROTECTED]> wrote:
> > The string I'm assigning to the field is a unicode string. Django is
> > trying to do a .encode('ascii') on it and failing. Understandable
> > really
>
> Are you sure it's the unicode type, and no
On 6/30/06, Paul <[EMAIL PROTECTED]> wrote:
> The string I'm assigning to the field is a unicode string. Django is
> trying to do a .encode('ascii') on it and failing. Understandable
> really
Are you sure it's the unicode type, and not just a byte string?
> I assume I have to do a .encode('utf-8
Ok, I've dug a little more and I realised I'd got the wrong end of the
stick.
The string I'm assigning to the field is a unicode string. Django is
trying to do a .encode('ascii') on it and failing. Understandable
really
I assume I have to do a .encode('utf-8') on it before I store it. Does
that
Hi,
I'm in need of a little education. This may be a python issue rather
than a Django one, but is anybody can help I'd appreciate it.
I've written an a little script which gets external data and inserts it
into the database using the Django models. Unfortunately (or
fortunately, depending on yo
simple SQL query:
SELECT name, consultant_id FROM users INNER JOIN consultants ORDER BY
name;
How do I do that with the database API?
I've tried these statements, and some variations, but they all fail:
- Consultant.objects.all().order_by('name')
- Consultant.objects.all().order
An easier way would be to use the codecs module to open the file for
reading or writing in a particular encoding (the system default
encoding is assumed when using open() or file(), which is apparently
different from iso-8859-1 in the case above). I have to deal with
encoded files quite frequently
Thank you Ivan,
Happy to see that in any case my pb would have been solved today.
;-)
--~--~-~--~~~---~--~~
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@googlegro
yml wrote:
>f = open("departments.txt")
>regexobj = re.compile("([0-9]+)\s+([\w\s?]+)",re.UNICODE)
>
>
>for l in f.readlines():
>fileencoding = "iso-8859-1"
>
>
Ah! I was just about to suggest this. Your file seems to be not in utf-8
actually. And since you were opening it with codecs.open
> =Department(department=matches[1].encode('utf-8','replace')
hi,
you can remove that ['replace']. there shouldn't be any unicode
character that cannot be represented in utf-8, so the error-condition
for which you specify the behaviour is never going to happen.
gabor
--~--~-~--~~
Here it is the script that is working for me.
This was done thanks to this great pages
(http://effbot.org/zone/unicode-objects.htm) it took me 3 days to find
it on internet.
Thank you google and of course thank you to the author :-)
# -*- coding: utf8 -*-
import os,codecs
from django.models.ann
Hello Thank you for your help but so far I do not have any success.
I am reading form a the lines from a file.
Here it is the kind of error I am getting :
the current line is :07 ArdFche
matches ('07', 'Ard\xe8che\r\n')
Traceback (most recent call last):
File
"E:\instal\django\view_serviceala
[EMAIL PROTECTED] wrote:
from django.models.page import pages
p = pages.Page(path=u"/föö", source=u"/bär")
p.save()
Interesting. I get here a 'Segmentation fault'. Both in in m-r and trunk...
q = pages.get_object(path__exact=u"/föö")
q.path
Ivan Sagalaev wrote:
> It depends very much on the definition of "correctly". Django's ORM
> expect single-byte strings which for unicode means utf-8.
>>> from django.models.page import pages
>>> p = pages.Page(path=u"/föö", source=u"/bär")
>>> p.save()
>>> q = pages.get_object(path__exact=u"/f
1 - 100 of 117 matches
Mail list logo