Re: Unit test is written but coverage report says there are missing statements

2023-01-13 Thread shahil joshi
report says there are missing > statements. > > *The model:* > > from django.db import models > from model_utils import FieldTracker > > from generics.base_model import BaseModelMixin > > class AModel(BaseModelMixin): > record_name = models.CharField(max_length=255)

how to fix in Missing statements in pytest

2021-03-05 Thread Salima Begum
Hi all, I am using pytest for testing my django application. I have written test cases for models, views, urls all test cases are running successfully but In the coverage report of pytest I am getting some missing statements. Is there any packages or plugin to resolve this missing statements issue

Re: Need the create statements for my Django models

2020-08-11 Thread Derek
"I was recently porting a legacy DB to Django by using the inspectdb command" - is there any reason why you cannot just stop here? Why do you think the "inspectdb" would fail? I would just go on creating the app and if any issues arise, I'd look at the specific model and see if it is because

Need the create statements for my Django models

2020-08-07 Thread Saahitya E
Hi, I was recently porting a legacy DB to Django by using the inspectdb command and then manually comparing the model to the corresponding table description. I want to confirm that I have not made any mistakes by getting the corresponding SQL create commands that migrate would have used to

RE: SQL select statements to Django ORM

2018-05-14 Thread Matthew Pava
se, I would use the annotation for a report that shows counts based on certain criteria. -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Melvyn Sopacua Sent: Monday, May 14, 2018 4:32 PM To: django-users@googlegroups.com Subject: Re: SQL s

Re: SQL select statements to Django ORM

2018-05-14 Thread Melvyn Sopacua
On maandag 14 mei 2018 16:42:49 CEST Matthew Pava wrote: > But if in your use case, you had a million records in which you were trying > to filter Full stop right there. No one is filtering anything in the original use case, so you're comparing apples and oranges. Filtering you would do in the

RE: SQL select statements to Django ORM

2018-05-14 Thread Matthew Pava
[mailto:django-users@googlegroups.com] On Behalf Of Melvyn Sopacua Sent: Monday, May 14, 2018 9:29 AM To: django-users@googlegroups.com Subject: Re: SQL select statements to Django ORM On maandag 14 mei 2018 15:38:01 CEST Matthew Pava wrote: > You could use the ORM to get the difference of two dates like

Re: SQL select statements to Django ORM

2018-05-14 Thread Melvyn Sopacua
On maandag 14 mei 2018 15:38:01 CEST Matthew Pava wrote: > You could use the ORM to get the difference of two dates like so: > Person.objects.annotate(age=ExpressionWrapper(Cast(Now(), DateField()) - > F('dob'), output_field=DurationField())) >

RE: SQL select statements to Django ORM

2018-05-14 Thread Matthew Pava
/models/database-functions/#now -Original Message- From: django-users@googlegroups.com [mailto:django-users@googlegroups.com] On Behalf Of Melvyn Sopacua Sent: Monday, May 14, 2018 5:56 AM To: django-users@googlegroups.com Subject: Re: SQL select statements to Django ORM On zondag 13 mei

Re: SQL select statements to Django ORM

2018-05-14 Thread Melvyn Sopacua
On zondag 13 mei 2018 03:44:37 CEST Gerald Brown wrote: > As I have said previously, I am new to Django ORM so I would like to know > howto/find reference to Django ORM Query to the following SQL Select > statements: Do you want to use SQL or use Django? Pick one. > 1. From Mariadb.

Re: SQL select statements to Django ORM

2018-05-13 Thread Todor Velichkov
, 2018 at 4:44:37 AM UTC+3, Gerald Brown wrote: > > As I have said previously, I am new to Django ORM so I would like to know > howto/find reference to Django ORM Query to the following SQL Select > statements: > > 1. From Mariadb. > > SELECT name, date_of_birth, *TIMESTAMP

SQL select statements to Django ORM

2018-05-12 Thread Gerald Brown
As I have said previously, I am new to Django ORM so I would like to know howto/find reference to Django ORM Query to the following SQL Select statements: 1. From Mariadb. SELECT name, date_of_birth, *TIMESTAMPDIFF(YEAR,date_of_birth,'2014-08-02'/or curdate())* AS age FROM some table. 2

Re: How i can hide statements {% IF hide %} on html template ... also {{ model.name }}

2017-04-09 Thread Camilo Torres
Can you show an example of one of these templates and the corresponding view? On Sunday, April 9, 2017 at 1:41:27 PM UTC-4, ZS ELECTRONICA wrote: > > Hello > > > I have a problem, i have a page with backbone + jquery+bootstrap+css, with > templates but , i don't now why when i see the "source

How i can hide statements {% IF hide %} on html template ... also {{ model.name }}

2017-04-09 Thread ZS ELECTRONICA
Hello I have a problem, i have a page with backbone + jquery+bootstrap+css, with templates but , i don't now why when i see the "source of page" i can see the statments {% IF some %} ... .also {{ tag.title }} , i need hide this , in other pages i cant see this. please help me --

Re: Renaming fields in values statements django 1.8

2016-03-04 Thread Simon Charette
Hi Jonty, There's a ticket tracking the addition of this feature[1] but it has not been fixed yet. Cheers, Simon [1] https://code.djangoproject.com/ticket/16735 Le vendredi 4 mars 2016 08:09:20 UTC-5, Jonty Needham a écrit : > > Is there a way to do it? I've seen the method with extra, but

Re: Renaming fields in values statements django 1.8

2016-03-04 Thread Simon Charette
Hi Jonty, There's a ticket tracking the addition of this feature[1] but it has not been fixed yet. Cheers, Simon [1] https://code.djangoproject.com/ticket/16735 Le vendredi 4 mars 2016 08:09:20 UTC-5, Jonty Needham a écrit : > > Is there a way to do it? I've seen the method with extra, but

Renaming fields in values statements django 1.8

2016-03-04 Thread Jonty Needham
Is there a way to do it? I've seen the method with extra, but that doesn't seem to work for me. Does the 1.8 ORM support this out of the box? Thanks in advance. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and

Re: Logging transaction statements?

2015-02-10 Thread Carl Meyer
On 02/10/2015 04:03 PM, Erik Cederstrand wrote: >> But `self.connection.set_isolation_level()` is called in >> `_set_autocommit()`, and that should be sufficient. (The >> `_set_isolation_level()` method is dead code in 1.7 and has since >> been removed, but what really matters is that >>

Re: Logging transaction statements?

2015-02-10 Thread Erik Cederstrand
> Den 10/02/2015 kl. 23.45 skrev Carl Meyer : > > Yes, that's what I said :-) Thanks for the great explanations; I didn't see your previous answer before posting my latest reply, hence the duplicate explanations :-) > >> My code relies on isolation level "Serializable" for a

Re: Logging transaction statements?

2015-02-10 Thread Carl Meyer
Hi Erik, On 02/10/2015 03:30 PM, Erik Cederstrand wrote: > Den 10/02/2015 kl. 21.27 skrev Erik Cederstrand > : >> >> Running this in parallel in two processes on the same machine >> returns this after a while: >> >> Process A: [...] >> >> Process B: [...] Traceback

Re: Logging transaction statements?

2015-02-10 Thread Erik Cederstrand
Den 10/02/2015 kl. 21.27 skrev Erik Cederstrand : > > Running this in parallel in two processes on the same machine returns this > after a while: > > Process A: > [...] > > Process B: > [...] > Traceback (most recent call last): > File "tmp.py", line 30, in >

Re: Logging transaction statements?

2015-02-10 Thread Carl Meyer
On 02/10/2015 02:46 PM, Carl Meyer wrote: > On 02/10/2015 01:27 PM, Erik Cederstrand wrote: >>> Den 10/02/2015 kl. 18.34 skrev Carl Meyer >> >: >>> >>> I assume you're using the 'db' cache backend? Otherwise, it wouldn't >>> make sense to expect

Re: Logging transaction statements?

2015-02-10 Thread Carl Meyer
On 02/10/2015 01:27 PM, Erik Cederstrand wrote: >> Den 10/02/2015 kl. 18.34 skrev Carl Meyer > >: >> >> I assume you're using the 'db' cache backend? Otherwise, it wouldn't >> make sense to expect transactions to affect cache calls at all. > > Yes, I'm

Re: Logging transaction statements?

2015-02-10 Thread Erik Cederstrand
Hi Carl, > Den 10/02/2015 kl. 18.34 skrev Carl Meyer >: > > I assume you're using the 'db' cache backend? Otherwise, it wouldn't > make sense to expect transactions to affect cache calls at all. Yes, I'm using the db backend. > The difference

Re: Logging transaction statements?

2015-02-10 Thread Carl Meyer
Hi Erik, On 02/10/2015 10:28 AM, Erik Cederstrand wrote: > Hmm, I'm beginning to think I don't understand Django transactions. I > have the following two snippets, boiled down from my original code. The > first one calls cache methods via helper functions, the other one calls > the cache methods

Re: Logging transaction statements?

2015-02-10 Thread Erik Cederstrand
> Den 10/02/2015 kl. 17.15 skrev Erik Cederstrand <erik+li...@cederstrand.dk>: > > Hi list, > > I'm tracking down a bug in my app that shouldn't be happening with the > transaction statements I added in my code. In my logging settings, I can set > 'django.d

Logging transaction statements?

2015-02-10 Thread Erik Cederstrand
Hi list, I'm tracking down a bug in my app that shouldn't be happening with the transaction statements I added in my code. In my logging settings, I can set 'django.db.backends' to DEBUG to log the queries (I'm using the postresql backend). I see 'SAVEPOINT' statements logged, but I also need

sql query to annotation values e aggretate statements

2015-01-29 Thread Mauro Ziliani
Hi all. My name's Mauro and I start to work with Django 1.7.3 I work on my project which tracks my accounting. I need to translate a SQL query to annoteta values aggretate statements. The application is named accounting The models involved are: class Nominativo(models.Model): nome

Not getting create table statements as described in the tutorial

2014-08-09 Thread Daniel Grace
I am following the tutorial at https://docs.djangoproject.com/en/1.6/intro/tutorial01/ I typed in the command: python manage.py sql polls but there were no messages, and I did not get the create statements that are mentioned in the tutorial. I'm not sure what is going on. -- You received

Order of WHERE statements in filter

2011-03-11 Thread galgal
I want to make a specific odrer of WHERE statements in my query to use multicolumn index in database. But oder in code is not the same as result query: code: filter(user=self.user, province=self.province, city=self.city) Mysql result: WHERE (`accounts_usercity`.`province_id` = 6

Re: which statements are right?

2011-03-08 Thread Bill Freeman
I'll take a shot. On Mon, Mar 7, 2011 at 11:43 AM, yongzhen zhang <4...@live.cn> wrote: > Hi, > When i am doing some exercises, i found some questions are very to > understand, Could you tell me which sentiences are correct? > 1. Models convert data from relational database form to objects and >

which statements are right?

2011-03-07 Thread yongzhen zhang
Hi, When i am doing some exercises, i found some questions are very to understand, Could you tell me which sentiences are correct? 1. Models convert data from relational database form to objects and vice versa. 2. Django model has to be written for a specific relation database 3. Foreignkey are

Re: Any way to select which Model to initialize without resorting to "if-elfi" statements?

2010-10-03 Thread Michael
You can always pre-define them all in a dict: cat2form = {'TV': TVForm, 'Laptop': LaptopForm} model_form = cat2form[category] model_form_instance = model_form() This way you forms don't have to follow a strict naming convention. -- Michael On Sun, 2010-10-03 at 01:04

Re: Any way to select which Model to initialize without resorting to "if-elfi" statements?

2010-10-03 Thread Steve Holden
On 10/3/2010 4:04 AM, Andy wrote: > I need to model many different product categories such as TV, laptops, > women's apparel, men's shoes, etc. > > Since different product categories have different product attributes, > each category has its own separate Model: TV, Laptop, WomensApparel, >

Any way to select which Model to initialize without resorting to "if-elfi" statements?

2010-10-03 Thread Andy
I need to model many different product categories such as TV, laptops, women's apparel, men's shoes, etc. Since different product categories have different product attributes, each category has its own separate Model: TV, Laptop, WomensApparel, MensShoes, etc. And for each Model I created a

Re: select statements with specific fields across multiple tables...

2010-08-17 Thread Cindy
Ah *geez* not the "bug due to typo which you can't see b/c you've been looking at the code nonstop for way to long" problem *headdesk* That's what I get for looking at the django tables directly in mysql to recall the columns. Thanks, guys. Dammit, I hate it when I do that. So, I'm

Re: select statements with specific fields across multiple tables...

2010-08-17 Thread Daniel Roseman
On Aug 17, 1:57 pm, Cindy wrote: > But that filter will just give me a list of tuples with > RaidPhysicalDrive's values.  I want to understand how I can include > in the list I send to my template, the *additional* values for system > name, storage name, and array name, so I can

Re: select statements with specific fields across multiple tables...

2010-08-17 Thread Cindy
But that filter will just give me a list of tuples with RaidPhysicalDrive's values. I want to understand how I can include in the list I send to my template, the *additional* values for system name, storage name, and array name, so I can display/dump all the info in a table. I don't want to put

Re: select statements with specific fields across multiple tables...

2010-08-16 Thread Alec Shaner
1. What is your code for doing the filters? If you want to start with physical drives it would be something like: RaidPhysicalDrive.objects.filter(in_array__in_storage__in_system__id=) 2. In your template you've referenced pd.in_array_id, but don't you just want pd.in_array if you're wanting to

select statements with specific fields across multiple tables...

2010-08-16 Thread Cindy
I'm having some trouble constructing a filter that's intended to work across multiple tables with selected fields. Here's a simplified outline of my models: class System(models.Model): name = models.CharField(max_length=16) domain = models.CharField(max_length=255, default='example.com')

Re: Trouble constructing raw SQL requiring multiple LIKE statements

2010-04-29 Thread Bill Freeman
ects using description__contains='ultraviolet' and title__contains='ultraviolet'. filter(description__contains= On Thu, Apr 29, 2010 at 6:12 PM, Daniel <unagimiy...@gmail.com> wrote: > Hi guys, > > I am having trouble getting multiple LIKE statements to work using > cursor.execute(SQL, [

Trouble constructing raw SQL requiring multiple LIKE statements

2010-04-29 Thread Daniel
Hi guys, I am having trouble getting multiple LIKE statements to work using cursor.execute(SQL, [params]). Here is my raw SQL query which I have confirmed is working directly at the mysql command line: "SELECT samples.number from samples WHERE samples.description LIKE samples.description

Re: Grouped statements in debug_toolbar

2010-03-26 Thread Peter Bengtsson
On 26 March 2010 11:09, Daniel Roseman <dan...@roseman.org.uk> wrote: > On Mar 25, 7:17 pm, Peter Bengtsson <pete...@gmail.com> wrote: >> The old django debug-toolbar used to make it possible to group >> statements that were the same so you can see if a particu

Re: Grouped statements in debug_toolbar

2010-03-26 Thread Daniel Roseman
On Mar 25, 7:17 pm, Peter Bengtsson <pete...@gmail.com> wrote: > The old django debug-toolbar used to make it possible to group > statements that were the same so you can see if a particular statement > was called repeatedly. This does not appear to be possible in the > lates

Grouped statements in debug_toolbar

2010-03-25 Thread Peter Bengtsson
The old django debug-toolbar used to make it possible to group statements that were the same so you can see if a particular statement was called repeatedly. This does not appear to be possible in the latest version; or am I wrong? -- You received this message because you are subscribed

Re: If Statements inside For Loops

2010-01-11 Thread Karen Tracey
On Mon, Jan 11, 2010 at 1:02 PM, Dave Merwin wrote: > First of all, thanks to everyone for the help!!! > > I'm not getting any output after the else. Nothing displays in the > template. > > That is what is confusing. > > "Nothing displays in the template" sounds like

Re: If Statements inside For Loops

2010-01-11 Thread Dave Merwin
First of all, thanks to everyone for the help!!! I'm not getting any output after the else. Nothing displays in the template. That is what is confusing. Dave On Jan 11, 8:58 am, Karen Tracey wrote: > On Mon, Jan 11, 2010 at 2:39 AM, Dave Merwin

Re: If Statements inside For Loops

2010-01-11 Thread Karen Tracey
On Mon, Jan 11, 2010 at 2:39 AM, Dave Merwin wrote: > I have the following: > > {% for group in user.groups.all %} >{{ group.name }} >{% ifequal group.name "subscribed" %} >I'm subscribed >{% else %} >{{ group.name }} >{% endifequal %} > {%

Re: If Statements inside For Loops

2010-01-11 Thread G B Smith
If the docs are to be believed, {% ifequal %} does provide an option for an {% else %} clause. See http://docs.djangoproject.com/en/dev/ref/templates/builtins/#ifequal That said, I can't tell from the code above why it would not work. But if you are using Django dev version (post 1.1) then go

If Statements inside For Loops

2010-01-10 Thread Dave Merwin
I have the following: {% for group in user.groups.all %} {{ group.name }} {% ifequal group.name "subscribed" %} I'm subscribed {% else %} {{ group.name }} {% endifequal %} {% endfor %} The else part of the statement is not rendering. What am I missing? Any help

Re: print statements don't show up

2010-01-09 Thread Ishwor Gurung
2010/1/10 aditya : > Ok, I figured it out...it turns out urls.py doesn't get executed by > runserver until I actually try a url. All I needed to do was point my > browser to localhost:8000, and everything worked as expected : Glad you figured it out :) [...] -- Regards

Re: print statements don't show up

2010-01-09 Thread Ishwor Gurung
2010/1/10 aditya <bluemangrou...@gmail.com>: > Ishwor, > The print statement is actually in a core Django file. I'm trying to > get familiar with Django's source code. Unfortunately my print > statements dont seem to run. You want to make sure the monkey patching business

Re: print statements don't show up

2010-01-09 Thread aditya
> > 2010/1/10 aditya <bluemangrou...@gmail.com>: > > > Hi, > > Has anyone run into issues with print statements in Django? I was > > curious about the core Django code, so I was poking around. My way of > > discovering how things work is to run some print st

Re: print statements don't show up

2010-01-09 Thread aditya
Ishwor, The print statement is actually in a core Django file. I'm trying to get familiar with Django's source code. Unfortunately my print statements dont seem to run. On Jan 9, 8:10 pm, Ishwor Gurung <ishwor.gur...@gmail.com> wrote: > Hi Aditya, > > 2010/1/10 aditya <bluema

Re: print statements don't show up

2010-01-09 Thread Ishwor Gurung
Hi Aditya, 2010/1/10 aditya <bluemangrou...@gmail.com>: > Hi, > Has anyone run into issues with print statements in Django? I was > curious about the core Django code, so I was poking around. My way of > discovering how things work is to run some print statements and see >

print statements don't show up

2010-01-09 Thread aditya
Hi, Has anyone run into issues with print statements in Django? I was curious about the core Django code, so I was poking around. My way of discovering how things work is to run some print statements and see their output...But my print statements aren't being printed to the Terminal. I've got

Re: where to place import statements

2009-09-24 Thread Kevin Teague
imports don't usually take up too much memory. I'd guess that even importing a very large number of modules isn't going to grow your process size by more than 10 MB. imports are only evaluated once. So if you nest the import into a view, your process will be smaller until the first time that

where to place import statements

2009-09-24 Thread Some Guy
Hi group, I was wondering about how to structure my import statements and it's impact, if any, on the memory footprint of mod_python. I'm importing some modules that i'm sure are huge in memory for certain views. My question is: does it make any difference whether I put the import statement

Re: with statements

2009-08-16 Thread GuyBowden
Alex, It's a Tag, so will give the filter route a go - shouldn't take too much to swap it over.. at the moment this is the only place I'm using the tag/filter.. Guy On Aug 16, 1:37 pm, Alexander Dutton wrote: > On 16/08/09 09:50, GuyBowden wrote: > > > > > Hi All, > > >

Re: with statements

2009-08-16 Thread Alexander Dutton
On 16/08/09 09:50, GuyBowden wrote: > Hi All, > > Just wondering what the best way to do this sort of thing is: > > {% with last_tweet_sent this_user as sent_at %} > {{ sent_at|naturalday:_("MONTH_DAY_FORMAT")|capfirst}} > {% endwith %} > > I've got a function "last_tweet_sent" in a

with statements

2009-08-16 Thread GuyBowden
Hi All, Just wondering what the best way to do this sort of thing is: {% with last_tweet_sent this_user as sent_at %} {{ sent_at|naturalday:_("MONTH_DAY_FORMAT")|capfirst}} {% endwith %} I've got a function "last_tweet_sent" in a templatetags module that takes a user and spits back the

Re: syncdb with ForeignKey to_field outputs statements in wrong order

2009-08-12 Thread physicsnick
Hmm. It seems to be database-specific. PostgreSQL and Oracle require that foreign key references be unique, while MySQL and SQLite do not (although for SQLite that's mainly due to it not actually implementing foreign key constraints). The MySQL documentation has this to say: >> Additionally,

Re: syncdb with ForeignKey to_field outputs statements in wrong order

2009-08-11 Thread Malcolm Tredinnick
On Tue, 2009-08-11 at 12:00 -0700, physicsnick wrote: > Actually they don't need to be unique (and I don't want them to be > unique). MySQL does not require that foreign keys be unique; only that > they be indexed. > > I am actually using this for a temporal database. There are many > instances

Re: syncdb with ForeignKey to_field outputs statements in wrong order

2009-08-11 Thread physicsnick
t; fail because the target columns of foreign keys need to be indexed. > > When I run syncdb, it fails with the following error (which you can > > see if you just paste the above sql into a temporary database): > > > _mysql_exceptions.OperationalError: (1005, "Can't create table &

Re: syncdb with ForeignKey to_field outputs statements in wrong order

2009-08-10 Thread Karen Tracey
case I need to run syncdb and wait for it to fail, then manually > create the index I need, then run syncdb again (and repeat, since I > have many foreign keys with custom columns). Or I need to not use > syncdb at all, and instead use the sqlall command and reorder the > statements myself.

syncdb with ForeignKey to_field outputs statements in wrong order

2009-08-10 Thread physicsnick
dex I need, then run syncdb again (and repeat, since I have many foreign keys with custom columns). Or I need to not use syncdb at all, and instead use the sqlall command and reorder the statements myself. Is this a django bug? Am I doing something wrong? --~--~-~--~~~

Re: Need two response statements on same def

2009-03-19 Thread Jesse
Thanks everyone for the suggestions! I will get started on redoing the functions and views. On Mar 19, 9:29 am, Andy Mckay wrote: > On 19-Mar-09, at 8:35 AM, Jesse wrote: > > > My concern is that each view has 87 lines of duplicate code from the > > "GET" data to get the

Re: Need two response statements on same def

2009-03-19 Thread Andy Mckay
On 19-Mar-09, at 8:35 AM, Jesse wrote: > My concern is that each view has 87 lines of duplicate code from the > "GET" data to get the appended list (shown here as: data retrieved to > create a list .list.append(publications)). Anytime I make a > change in one view I have to remember to make

Re: Need two response statements on same def

2009-03-19 Thread Daniel Roseman
On Mar 19, 3:35 pm, Jesse wrote: > My concern is that each view has 87 lines of duplicate code from the > "GET" data to get the appended list (shown here as: data retrieved to > create a list .list.append(publications)).  Anytime I make a > change in one view I have to

Re: Need two response statements on same def

2009-03-19 Thread Baxter
> > > In the view.py I have  (def Bypub) that sends data to a template and > > > paginates it.  I have a second (def TextFile) that uses the same data > > > to send to a CSV file.  I would like to combine the two (def Bypub and > > > def TextFile) together into def Bypub, but

Re: Need two response statements on same def

2009-03-19 Thread Jesse
) together into def Bypub, but I'm not sure how to write > > the statements to combine two responses. > > What problem are you trying to solve here? You already have two views > where the common stuff is in a separate function (the bit you've marked > as retrieving the data

Re: Need two response statements on same def

2009-03-18 Thread Malcolm Tredinnick
her into def Bypub, but I'm not sure how to write > the statements to combine two responses. What problem are you trying to solve here? You already have two views where the common stuff is in a separate function (the bit you've marked as retrieving the data in a list) and the distinct stuff is

Re: Need two response statements on same def

2009-03-18 Thread Andy Mckay
to def Bypub, but I'm not sure how to write > the statements to combine two responses. You can only send one response to a request, so it can be either HTML or a CSV. -- Andy McKay Clearwind Consulting: www.clearwind.ca Blog: www.agmweb.ca/blog/andy Twitter: twitte

Need two response statements on same def

2009-03-18 Thread Jesse
In the view.py I have (def Bypub) that sends data to a template and paginates it. I have a second (def TextFile) that uses the same data to send to a CSV file. I would like to combine the two (def Bypub and def TextFile) together into def Bypub, but I'm not sure how to write the statements

Re: Dynamic OR statements

2009-01-06 Thread Bluemilkshake
n 5, 10:52 am, Bluemilkshake <bluemilksh...@googlemail.com> > wrote: > > > > > Hello. Django noob here, pretty much. > > > I understand how one can use Q objects to construct OR statements > > within a QuerySet, but (how) is it possible to do this dynamically? > >

Re: Dynamic OR statements

2009-01-05 Thread bruno desthuilliers
On 5 jan, 18:09, "alex.gay...@gmail.com" wrote: > You need to build up the Q object and then filter on it so: > results = RelatedModel.objects.all() > q = Q() > for category in category_list: > q |= Q(categories__slug = category.slug) > results = results.filter(q)

Re: Dynamic OR statements

2009-01-05 Thread Enrico
Hi Mark, I think you could use the Q object like this: q_filter = Q() for category in category_list: q_filter = q_filter | Q(categories__slug=category.slug) results = RelatedModel.objects.filter(q_filter) Best regards, Enrico --~--~-~--~~~---~--~~ You

Re: Dynamic OR statements

2009-01-05 Thread alex.gay...@gmail.com
o. Django noob here, pretty much. > > I understand how one can use Q objects to construct OR statements > within a QuerySet, but (how) is it possible to do this dynamically? > > I have a list of categories, and I want to find items that match ANY > of those categories. The curren

Re: Dynamic OR statements

2009-01-05 Thread Ronny Haryanto
On Mon, Jan 5, 2009 at 11:59 PM, Ronny Haryanto wrote: > On Mon, Jan 5, 2009 at 11:52 PM, Bluemilkshake > wrote: >> for category in category_list: >>results = results.filter(categories__slug = category.slug) > > How about

Re: Dynamic OR statements

2009-01-05 Thread Ronny Haryanto
On Mon, Jan 5, 2009 at 11:52 PM, Bluemilkshake wrote: > for category in category_list: >results = results.filter(categories__slug = category.slug) How about results.filter(category__in=category_list)? Ronny

Dynamic OR statements

2009-01-05 Thread Bluemilkshake
Hello. Django noob here, pretty much. I understand how one can use Q objects to construct OR statements within a QuerySet, but (how) is it possible to do this dynamically? I have a list of categories, and I want to find items that match ANY of those categories. The current solution doesn't work

Proxy SQL statements for some models

2008-05-28 Thread wermut
can catch the sql statements for these two models, so I could send them to the remote server and give the models latter the result back. Local Django > Django data models > local sqlite3 database for the main models > remote php proxy

Re: sql_queries does not include all the sql statements

2008-04-29 Thread Simon Willison
On Apr 29, 9:31 am, leopay <[EMAIL PROTECTED]> wrote: > oh,sorry ,I made a mistake,it is Entry.objects.all()[0:1] > I means when I write like this Entry.objects.all()[0:1],I cannot find the > this raw sql like 'select col_name from entry_table limit 1' in > sql_queries,but if I write like this

Re: sql_queries does not include all the sql statements

2008-04-29 Thread leopay
oh,sorry ,I made a mistake,it is Entry.objects.all()[0:1] I means when I write like this Entry.objects.all()[0:1],I cannot find the this raw sql like 'select col_name from entry_table limit 1' in sql_queries,but if I write like this Entry.objects.all()[0],I could the sql in sql_queries when use

Re: sql_queries does not include all the sql statements

2008-04-29 Thread Amit Ramon
* leopay <[EMAIL PROTECTED]> [2008-04-29 00:07 -0700]: > > I use django.core.context_processors.debug to see the sql_queries in > template. > The raw sql of query > > Entry.objects.all()[0,1] > > does not in the sql_queries,but if I change the query like this > > Entry.objects.all()[0] > >

sql_queries does not include all the sql statements

2008-04-29 Thread leopay
I use django.core.context_processors.debug to see the sql_queries in template. The raw sql of query Entry.objects.all()[0,1] does not in the sql_queries,but if I change the query like this Entry.objects.all()[0] and then the sql is in the sql_queries. why?

Re: 'for' statements with five words should end in 'reversed': for key, value in obj.items

2008-04-18 Thread Salim Fadhley
Great - I upgraded to dev - it works fine. On Apr 18, 12:02 pm, Dan Ellis <[EMAIL PROTECTED]> wrote: > You can't do "key, value" in Django 0.96. You need to do "for item in > obj.items" and then use item.0 and item.1, or use a development > version.

'for' statements with five words should end in 'reversed': for key, value in obj.items

2008-04-18 Thread Salim Fadhley
When rendering this template: {% block objcontent %} {% for key, value in obj.items %} {{ key }} {{ repr(value) }} {% endfor %} {% endblock objcontent %} I get this error: 'for' statements with five words should end in 'reversed': for key, value in obj.items Any idea what is going on here

Re: 'for' statements with five words should end in 'reversed': for key, value in obj.items

2008-04-18 Thread Dan Ellis
You can't do "key, value" in Django 0.96. You need to do "for item in obj.items" and then use item.0 and item.1, or use a development version. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group.

Re: Nested in statements

2007-10-16 Thread Thomas Guettler
Am Dienstag, 16. Oktober 2007 15:48 schrieb Jeremy Dunck: > On 10/16/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > Hi, > > > > you can use the extra() method of QuerySet: > > > > Example: Entry.objects.extra(where=['id IN (3, 4, 5, 20)']) > > How is this different from __in, and where did

Re: ***SPAM*** Nested in statements

2007-10-16 Thread Jeremy Dunck
On 10/16/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > Hi, > > you can use the extra() method of QuerySet: > > Example: Entry.objects.extra(where=['id IN (3, 4, 5, 20)']) > How is this different from __in, and where did that list of numbers come from? :)

Re: ***SPAM*** Nested in statements

2007-10-16 Thread Thomas Guettler
Hi, you can use the extra() method of QuerySet: Example: Entry.objects.extra(where=['id IN (3, 4, 5, 20)']) http://www.djangoproject.com/documentation/db-api/#extra-select-none-where-none-params-none-tables-none Am Dienstag, 16. Oktober 2007 14:29 schrieb Rufman: > in SQL terms this is what

Re: Nested in statements

2007-10-16 Thread Jeremy Dunck
On 10/16/07, Rufman <[EMAIL PROTECTED]> wrote: > > in SQL terms this is what i want to do: > SELECT * > FROM `build` > WHERE `iKeyBuildNr` > IN ( > >SELECT `iFKeyBuildNr` >FROM `package` >WHERE `strPackageName` > IN ("denon_AVR4306") >) > > How can i do

Re: Nested in statements

2007-10-16 Thread Rufman
in SQL terms this is what i want to do: SELECT * FROM `build` WHERE `iKeyBuildNr` IN ( SELECT `iFKeyBuildNr` FROM `package` WHERE `strPackageName` IN ("denon_AVR4306") ) How can i do this with the django db api? I tried it with __in, but it doesn't seem to

Re: Nested in statements

2007-10-16 Thread Rufman
: in SQL terms this is what i want to do: SELECT * FROM `build` WHERE `iKeyBuildNr` IN ( SELECT `iFKeyBuildNr` FROM `package` WHERE `strPackageName` IN ("denon_AVR4306") ) How can i do this with the Django db API? I tried it with __in, but it doen't seem to take

Re: Nested in statements

2007-10-16 Thread Rufman
in SQL terms this is what i want to do: SELECT * FROM `build` WHERE `iKeyBuildNr` > IN ( > > SELECT `iFKeyBuildNr` > FROM `package` > WHERE `strPackageName` > IN ( > & quot; > > denon_AVR4306 & quot; > > ) > ) --~--~-~--~~~---~--~~ You received this message

Nested in statements

2007-10-16 Thread Rufman
in SQL terms this is what i want to do: SELECT * FROM `build` WHERE `iKeyBuildNr` IN ( SELECT `iFKeyBuildNr` FROM `package` WHERE `strPackageName` IN ( & quot; denon_AVR4306 & quot; ) ) --~--~-~--~~~---~--~~ You received this message because you are subscribed

Re: duplicate SQL statements

2007-07-31 Thread Kevin Menard
On 7/31/07, Thomas Guettler <[EMAIL PROTECTED]> wrote: > > Hi, > > with SQLLogMiddleware (http://www.djangosnippets.org/snippets/344/) I see, > that there are many statements executed twice in a single request. > > This links explains it: > http://www.djangopr

duplicate SQL statements

2007-07-31 Thread Thomas Guettler
Hi, with SQLLogMiddleware (http://www.djangosnippets.org/snippets/344/) I see, that there are many statements executed twice in a single request. This links explains it: http://www.djangoproject.com/documentation/db-api/#caching-and-querysets How can I cache the result

Re: include statements for non-dynamic pages

2007-05-28 Thread Kenneth Gonsalves
On 29-May-07, at 8:34 AM, Russell Keith-Magee wrote: > Note that for simple cases, you may be able to use a generic view. > These are views that cover simple use cases (just render a template, > render a template for a single database object, render a template for > a list of database objects,

  1   2   >