Re: get all columns as a list

2016-05-23 Thread James Schneider
On Mon, May 23, 2016 at 9:20 AM, Larry Martell wrote: > They're not identical - there's a timestamp - that is not one of the > columns compared. > > The data is status data from a piece of equipment and we only want to > store changes. If 2 consecutive rows come in that

Re: How to aggregate on insert?

2016-05-23 Thread James Schneider
On Mon, May 23, 2016 at 12:58 PM, Erik Cederstrand < erik+li...@cederstrand.dk> wrote: > Hi, > > I have inherited a legacy Item model that has a composite unique key > consisting of a Customer ID and a per-customer, incrementing Item ID. > Assume I can't change the model. > > On inserts, the

Re: UserProfile Pattern (extending User model); Migrations; New fields/columns on models.

2016-05-23 Thread Gergely Polonkai
Hello, did you run manage.py migrate? When you add a ForeignKey or OneToOne to a model, what actually gets stored in the DB is the ID of the referenced object (in this case, a auth.models.User). So the user_id column should be created for you during the next makemigrations+migrate combo. On a

Re: How to aggregate on insert?

2016-05-23 Thread Erik Cederstrand
> Den 23. maj 2016 kl. 22.49 skrev Ketan Bhatt : > > Hey Erik, > > What Django version are you on? I'm on Django 1.9. Erik -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop

Re: Complicated relationships

2016-05-23 Thread Gergely Polonkai
I would make Restaurant.dishes a @property that returns all dishes the restaurant's chefs can make: return Dish.objects.filter(chef__restaurant=self) On May 23, 2016 14:46, "Jani Tiainen" wrote: > Something like > > Chef: > # Nothing special here, reverse relations will

Re: How to aggregate on insert?

2016-05-23 Thread Ketan Bhatt
Hey Erik, What Django version are you on? On Tuesday, May 24, 2016 at 1:28:57 AM UTC+5:30, Erik Cederstrand wrote: > > Hi, > > I have inherited a legacy Item model that has a composite unique key > consisting of a Customer ID and a per-customer, incrementing Item ID. > Assume I can't change

Reportlab no module named pdfgen

2016-05-23 Thread david rodgers
Hello All, I am trying to use reportlab to generate pdfs from html. When I pip install reportlab it say its installed correctly. However, when I try 'from reportlab.pdfgen import canvas' I get an error saying no module named pdfgen. Any ideas to help solve this would be much appreciated.

How to aggregate on insert?

2016-05-23 Thread Erik Cederstrand
Hi, I have inherited a legacy Item model that has a composite unique key consisting of a Customer ID and a per-customer, incrementing Item ID. Assume I can't change the model. On inserts, the legacy code would let the database increment the Item ID to avoid race conditions. Something like

UserProfile Pattern (extending User model); Migrations; New fields/columns on models.

2016-05-23 Thread McKinley
I have a Users table inside of a postgresql database in which auth_user also lives. I want the Users objects to have a OneToOne to the auth_user model. I added a line to my models.py under my Users class: user = models.OneToOneField(User, unique=True) There are probably other things wrong,

Re: get all columns as a list

2016-05-23 Thread Ketan Bhatt
Can you not do something like `qs.filter(...info that is coming in...).exists()` If ^ is True, then update it, otherwise create a new object? -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving

Re: get all columns as a list

2016-05-23 Thread Larry Martell
They're not identical - there's a timestamp - that is not one of the columns compared. The data is status data from a piece of equipment and we only want to store changes. If 2 consecutive rows come in that are the same (excluding the timestamp) I don't want to store the second one. On Mon, May

Re: get all columns as a list

2016-05-23 Thread Derek
OK - I don't really understand that; there should not be any 2 identical records in a database, but anyway, that was not the issue in this thread. On Monday, 23 May 2016 11:52:06 UTC+2, larry@gmail.com wrote: > > It's only 2 consecutive rows identical rows I need to exclude. > > On Mon, May

Re: Query and order by time difference of a specified time.

2016-05-23 Thread Fabio C. Barrionuevo da Luz
it would probably be better to use a custom "Func"[1] and a custom "Query Expression" [2] than user QuerySet.extra [1] https://docs.djangoproject.com/en/1.9/ref/models/database-functions [2] https://docs.djangoproject.com/en/1.9/ref/models/expressions/ On Mon, May 23, 2016 at 11:16 AM, Ketan

Query and order by time difference of a specified time.

2016-05-23 Thread Ketan Bhatt
Take a look at the `extra` method of the queryset in Django. It allows you to do what you are trying to do by raw SQL. https://docs.djangoproject.com/en/1.9/ref/models/querysets/#django.db.models.query.QuerySet.extra Check the above link, the example with `annotate` will be interesting for

Re: Aggregation / annotation over results of a subquery

2016-05-23 Thread Malcolm Box
Thanks Simon, that's exactly what I needed. I had read the aggregation documentation, but hadn't figured out how to get it to do what I needed. Cheers, Malcolm On Friday, 20 May 2016 16:52:01 UTC+1, Simon Charette wrote: > > Hi Malcom, > > I suggest you look into the conditionnal aggregation

Re: Complicated relationships

2016-05-23 Thread Jani Tiainen
Something like Chef: # Nothing special here, reverse relations will be done automatically Dish: chef = ForeignKey(Chef) Restaurant: chefs = ManyToMany(Chef) dishes = ManyToMany(Dish) Of course, you need to build something to make sure that restaurant doesn't serve dishes that

Re: about django framework execution sequence

2016-05-23 Thread Paulo Afonso
Hi You can using tutorial from base project, that was what I did to understand. https://docs.djangoproject.com/en/1.9/intro/tutorial01/ Another way, is was very useful for me the PDF book Pro Django 2nd Version. But for what I know is: a) First start with Setting.py, b) urls to call the view

Query and order by time difference of a specified time.

2016-05-23 Thread ap.d...@x76.eu
Hi. I am looking for a way to find a row which is closest to a specified point in time, no matter if the row is before or after. In plain SQL (using SQLite as example), it's very easy to do; SELECT *, abs( strftime('%s','2015-05-21 23:05:00') - strftime('%s',`created`) ) AS timdif

Re: django 1.8 or 1.9.2 is not installed in my window 7

2016-05-23 Thread Paulo Afonso
Can you specify what you did! What do you install, and How? You can clone github, and install since there... You can use easy_install, pip, and so one. First what is your platform? Which version. That is basic you get help from others, we can advice but need your help too. domingo, 22 de

Django Deployment: Polls Tutorial: Advanced Tutorial: How to write reuseable apps

2016-05-23 Thread Kern Goretzky
New to Django. I have some Python programming experience (beginner-intermediate). I was taking the Django Polls tutorial and can't resolve deployment problem in the Advanced Tutorial: How to write reuseable apps: https://docs.djangoproject.com/en/1.9/intro/reusable-apps/ In the Using Your Own

Complicated relationships

2016-05-23 Thread Mlati Mudan
I read the django documentation for a simple many-to-many relationship and I get it, but I'm stuck with this kind of complexity. Each restaurant employs many chefs and serves many dishes. Each chef can work for many restaurants and prepare many dishes. Each dish can only be prepared by a

Re: Displaying single-line progress while a management command runs

2016-05-23 Thread Phil Gyford
Belated thanks for this Erik - that does work nicely. It gets complicated/annoying trying to untangle other kinds of logging too, including logging from third-party modules, but that's a separate problem :) On 9 May 2016 at 21:33, Erik Cederstrand wrote: > > > Den 9.

Re: get all columns as a list

2016-05-23 Thread Larry Martell
It's only 2 consecutive rows identical rows I need to exclude. On Mon, May 23, 2016 at 4:53 AM, Derek wrote: > "When new data comes in I want to ... only add a new row if it differs." > > Pardon my curiosity, but isn't that the role of the set of unique keys for > each

Re: Displaying a document

2016-05-23 Thread Derek
The users will need a browser which is capable of rendering the file or knowing what app it has to use - for example, on my machine (Linux) an XLS file is rendered directly by LibreOffice; but on a colleague's machine with Windows/IE they have to first download the file and then open it. So,

Re: get all columns as a list

2016-05-23 Thread Derek
*"When new data comes in I want to ... only add a new row if it differs."* Pardon my curiosity, but isn't that the role of the set of unique keys for each record - to determine if it is "different"? On Friday, 20 May 2016 19:57:38 UTC+2, larry@gmail.com wrote: > > On Fri, May 20, 2016 at

Re: PDF page break

2016-05-23 Thread Derek
You need to let the list know what formats and what technology you are using to generate the PDF. When I use rst (reStructuredText) as my input to the generation process, the markup I use for a Page Break is: .. raw:: pdf PageBreak On Sunday, 22 May 2016 10:57:15 UTC+2, Monu wrote: > >