Re: database migrations

2019-08-04 Thread Mike Dewhirst
Once I have a database I wish to replicate many times for testing I just 
use pg_dump to create a json file which can be reloaded into an empty 
database as often as required. For that I use a script which 
sequentially calls dropdb, createdb and finally psql which nominates the 
json dump file created earlier.


Have a look at PostgreSQL documentation online for those commands or 
similar docs for similar commands if you use a different RDBMS


Cheers



On 4/08/2019 10:34 pm, Jani Tiainen wrote:

Hi.

To me this sounds more debugging issue than migrations or database 
problem.


Since it is most definitely your code that doesn't work right.

Of course if youre building and testing features that fill thousands 
of entries or relatively complex data there are options.


Personally I use "template database". Rather big db but at least it is 
in known state.


You could have scripts to populate db after creation. Many ways to do 
that as well.


la 3. elok. 2019 klo 13.19 Perceval Maturure > kirjoitti:


Question is what’s the best way forward to avoid situations where
u will have to create a new database if ur applications do not
work with the current databases so as to avoid populating the
database with data again




Sent from my iPhone

On 02 Aug 2019, at 14:39, Perceval Maturure mailto:drperce...@gmail.com>> wrote:


Dear all
creating a new database as applications increase has been one of
the solutions to some of the errors i have encountered especially
after adding a django cms by hand in my development environment.

i cant imagine a situation like that in a production environment
as this will mean re-entry of data.
please share some thought*
Regards
-- 
*Perceval Maturure*

*083 303 9423
*
-- 
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 view this discussion on the web visit

https://groups.google.com/d/msgid/django-users/2D3BA6A6-EDC6-4599-B519-64593AE64A1F%40gmail.com

.

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91od2f91AxBwRKPXDHPG8D0_%3D-aMTReya%2BxH%2B_5K6O%3DWyGA%40mail.gmail.com 
.


--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/76f79730-1895-3f3f-0e03-efd62f85f0f2%40dewhirst.com.au.


Re: database migrations

2019-08-04 Thread Jani Tiainen
Hi.

To me this sounds more debugging issue than migrations or database problem.

Since it is most definitely your code that doesn't work right.

Of course if youre building and testing features that fill thousands of
entries or relatively complex data there are options.

Personally I use "template database". Rather big db but at least it is in
known state.

You could have scripts to populate db after creation. Many ways to do that
as well.

la 3. elok. 2019 klo 13.19 Perceval Maturure 
kirjoitti:

> Question is what’s the best way forward to avoid situations where u will
> have to create a new database if ur applications do not work with the
> current databases so as to avoid populating the database with data again
>
>
>
>
> Sent from my iPhone
>
> On 02 Aug 2019, at 14:39, Perceval Maturure  wrote:
>
> Dear all
> creating a new database as applications increase has been one of the
> solutions to some of the errors i have encountered especially after adding
> a django cms by hand in my development environment.
>
> i cant imagine a situation like that in a production environment as this
> will mean re-entry of data.
> please share some thought*
> Regards
> --
> *Perceval Maturure*
>
> *083 303 9423*
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2D3BA6A6-EDC6-4599-B519-64593AE64A1F%40gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91od2f91AxBwRKPXDHPG8D0_%3D-aMTReya%2BxH%2B_5K6O%3DWyGA%40mail.gmail.com.


Re: database migrations

2019-08-04 Thread Perceval Maturure
Thanks Roger.


On Sun, 04 Aug 2019 at 01:19, RLM  wrote:

> Why try to avoid re populating the database? That's the easy part,
> figuring what went wrong is more difficult.You don't need a lot of data to
> get an app working, you just need to understand what you want and how to
> achieve it.
>
> When I was learning django I rebuilt my events database 20 times sometimes
> using the original data and sometimes by starting afresh.
> If you have valid working data consider writing the data tables to csv
> then write that data into the new tables, it takes a couple of seconds to
> recreate a table once you have the fields the same as the csv. I found that
> when using a csv in spreadsheet it highlighted issues in the data sets
>
> When experimenting, I suggest use SQLite and simply rename the database in
> the /dev app and start a new SQLite database by renaming it in the config
> file. That way you have previous data and new data in the same django
> application.
>
> Also you could simply create new models in the current database and
> repopulate only the fields you need in the new model.
> In all the above the main trouble will be joins. Get one small fields
> wrong and the join fails.
>
> Cheers
> Roger
> On 3/8/19 8:18 pm, Perceval Maturure wrote:
>
> Question is what’s the best way forward to avoid situations where u will
> have to create a new database if ur applications do not work with the
> current databases so as to avoid populating the database with data again
>
>
>
>
> Sent from my iPhone
>
> On 02 Aug 2019, at 14:39, Perceval Maturure  wrote:
>
> Dear all
> creating a new database as applications increase has been one of the
> solutions to some of the errors i have encountered especially after adding
> a django cms by hand in my development environment.
>
> i cant imagine a situation like that in a production environment as this
> will mean re-entry of data.
> please share some thought*
> Regards
> --
> *Perceval Maturure*
>
> *083 303 9423 *
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2D3BA6A6-EDC6-4599-B519-64593AE64A1F%40gmail.com
> 
> .
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/99e1d459-d31f-a527-c461-508bb13147b9%40gmail.com
> 
> .
>
-- 
Sent from Gmail Mobile

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFZtZmCDWc4rPujYWTKKnobWh3NV6J2KZutHa0p548HML6Tk0w%40mail.gmail.com.


Re: database migrations

2019-08-03 Thread RLM
Why try to avoid re populating the database? That's the easy part, 
figuring what went wrong is more difficult.You don't need a lot of data 
to get an app working, you just need to understand what you want and how 
to achieve it.


When I was learning django I rebuilt my events database 20 times 
sometimes using the original data and sometimes by starting afresh.
If you have valid working data consider writing the data tables to csv 
then write that data into the new tables, it takes a couple of seconds 
to recreate a table once you have the fields the same as the csv. I 
found that when using a csv in spreadsheet it highlighted issues in the 
data sets


When experimenting, I suggest use SQLite and simply rename the database 
in the /dev app and start a new SQLite database by renaming it in the 
config file. That way you have previous data and new data in the same 
django application.


Also you could simply create new models in the current database and 
repopulate only the fields you need in the new model.
In all the above the main trouble will be joins. Get one small fields 
wrong and the join fails.


Cheers
Roger

On 3/8/19 8:18 pm, Perceval Maturure wrote:
Question is what’s the best way forward to avoid situations where u 
will have to create a new database if ur applications do not work with 
the current databases so as to avoid populating the database with data 
again





Sent from my iPhone

On 02 Aug 2019, at 14:39, Perceval Maturure > wrote:



Dear all
creating a new database as applications increase has been one of the 
solutions to some of the errors i have encountered especially after 
adding a django cms by hand in my development environment.


i cant imagine a situation like that in a production environment as 
this will mean re-entry of data.

please share some thought*
Regards
--
*Perceval Maturure*
*083 303 9423
*

--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2D3BA6A6-EDC6-4599-B519-64593AE64A1F%40gmail.com 
.


--
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/99e1d459-d31f-a527-c461-508bb13147b9%40gmail.com.


Re: database migrations

2019-08-03 Thread Perceval Maturure
Question is what’s the best way forward to avoid situations where u will have 
to create a new database if ur applications do not work with the current 
databases so as to avoid populating the database with data again




Sent from my iPhone

> On 02 Aug 2019, at 14:39, Perceval Maturure  wrote:
> 
> Dear all
> creating a new database as applications increase has been one of the 
> solutions to some of the errors i have encountered especially after adding a 
> django cms by hand in my development environment.
> 
> i cant imagine a situation like that in a production environment as this will 
> mean re-entry of data.
> please share some thought*
> Regards
> -- 
> Perceval Maturure
> 083 303 9423
> 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2D3BA6A6-EDC6-4599-B519-64593AE64A1F%40gmail.com.


Re: database migrations

2019-08-03 Thread Jani Tiainen
Hi.

So... what is the actual question?

pe 2. elok. 2019 klo 15.40 Perceval Maturure 
kirjoitti:

> Dear all
> creating a new database as applications increase has been one of the
> solutions to some of the errors i have encountered especially after adding
> a django cms by hand in my development environment.
>
> i cant imagine a situation like that in a production environment as this
> will mean re-entry of data.
> please share some thought*
> Regards
> --
> *Perceval Maturure*
>
> *083 303 9423*
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFZtZmBdeYCM0HXUkuM2k1V%3D_6B%3DUUDr%3DNZn77yun0On_gsDuA%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91ofV7kcy60fucbTgQBVXgohhoXLZMtJDFPfJ9zp7qThxFg%40mail.gmail.com.


database migrations

2019-08-02 Thread Perceval Maturure
Dear all
creating a new database as applications increase has been one of the
solutions to some of the errors i have encountered especially after adding
a django cms by hand in my development environment.

i cant imagine a situation like that in a production environment as this
will mean re-entry of data.
please share some thought*
Regards
-- 
*Perceval Maturure*

*083 303 9423*

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAFZtZmBdeYCM0HXUkuM2k1V%3D_6B%3DUUDr%3DNZn77yun0On_gsDuA%40mail.gmail.com.


Database migrations

2016-03-04 Thread Daniel Roseman
What are you expecting to happen? The message is quite clear, and offers the 
only two possible options. Are neither of those suitable? Why not? What other 
action would you like to take?
-- 
DR.

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4dfee0dc-0912-4913-8a6d-b360d442550b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Database migrations

2016-03-04 Thread raoul
Hi all,

I have been playing around with Django now for a couple of weeks

I have been adding apps to my project and one point of frustration is the 
migration. When there are PK and/or FK relations:
You are trying to add a non-nullable field 'user' to user without a 
default; we can't do that (the database needs something to populate 
existing rows).
Please select a fix:
 1) Provide a one-off default now (will be set on all existing rows)
 2) Quit, and let me add a default in models.py

What I'm use to do is DROP the database and migrate it again. I know this 
is not the way to go, because if you are doing this in PROD you will loose 
all your data. I don't get the logic behind this. Some of you must have 
experience with making major change to you PROD web application. How did 
you made sure all the data is preserved?

Cheers,
Raoul

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b89feec8-ede0-4ed0-956e-45dab3963366%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm missing something with Models and database migrations

2016-01-02 Thread Michael Molloy
Thank you both.

--M

On Monday, December 28, 2015 at 1:09:08 AM UTC-6, Peter of the Norse wrote:
>
> OK.  Let’s take a look at the documentation 
> .
>  
>  Here is what you are looking for:
>
> class Invoice(models.Model):
> invoice_date = models.DateField(‘created date’, auto_now=True)
> line_item_set = models.ManyToManyField(LineItem, 
> through=‘InvoiceLineItem’)
>
> class LineItem(models.Model):
> descr = models.CharField(max_length=100)
> cost = models.DecimalField(max_digits=5, decimal_places=2)
>
> class InvoiceLineItem(models.Model):
> created_dt = models.DateField(auto_now=True)
> invoice = models.ForeignKey(Invoice)
> line_item = models.ForeignKey(LineItem)
>
> When you use through with a ManyToManyField, it doesn’t create an extra 
> table; otherwise, it does.  Also, I’ve cleaned up things so that they match 
> Django standards.
>
>
> On Dec 22, 2015, at 10:33 PM, Michael Molloy  > wrote:
>
> I figured it out, again with help from Vijay. Thanks for getting me 
> thinking in the right direction.
>
> So here is my cross reference model:
>
> class Invoice_Line_Items(models.Model):
>  created_dt = models.DateField('created date', auto_now=True)
>  invoice = models.ManyToManyField(Invoices)
>  line_item = models.ManyToManyField(Line_Items)
>
>
>
> I was incorrectly looking for a single table named Invoice_Line_Items because 
> I didn't understand how Django creates multiple tables to deal with 
> ManyToMany relationships like this. The table I was expecting was there, but 
> it didn't have columns for invoice IDs or line_item IDs. Django actually 
> created these three tables to handle this:
>
>
> gpga_invoice_line_items
>
> gpga_invoice_line_items_invoice
>
> gpga_invoice_line_items_line_item  
>
>
> Thanks again.
>
> --M
>
>
>
>
> On Tuesday, December 22, 2015 at 8:49:10 PM UTC-6, Michael Molloy wrote:
>>
>> Still confused. I think I still need to create the cross reference Django 
>> model myself, and then use makemigrations to turn it into a table.
>>
>> I need a place to store invoices and associated line items, so if the 
>> model code I put in my first post is incorrect, what should it look like? 
>>
>> --Michael
>>
>> On Tuesday, December 22, 2015 at 8:29:36 PM UTC-6, Michael Molloy wrote:
>>>
>>> I was trying to create the cross reference table myself. I'm coming at 
>>> this from a java/oracle background where I would create two tables 
>>> (invoices and line_items), and then a third (invoice_line_item_xref) that 
>>> would contain invoice IDs and associated line item IDs. I think you just 
>>> helped me see my misunderstanding of how Django does things.
>>>
>>> So, in the list of tables (now that I know what I'm looking for), I see 
>>> a table called invoice_line_items_xref_invoice_id and another called 
>>> invoice_line_items_xref_line_item_id. Those must be the two tables that 
>>> Django created to handle the many to many relationship. Is that correct? 
>>>
>>> --Michael 
>>>
>>> On Tuesday, December 22, 2015 at 6:29:51 PM UTC-6, Vijay Khemlani wrote:

 You have two pairs of fields with the same name (line_item_id 
 and invoice_id), what are you trying to do exactly? Why the IntegerFields?

 In a Many To Many relation the columns are added to a third table 
 between the models.

 On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy  
 wrote:

> Python 3.3 and Django 1.8 running on Openshift with a Postgresql 
> database
>
> I'm trying to set up an Invoices table, a Line_Item table, and a cross 
> reference between them. Here are the relevant models:
>
>
> class Invoices(models.Model):
>  invoice_date = models.DateField('created date', auto_now=True)
>
> class Line_Items(models.Model):
>  descr = models.CharField(max_length=100)
>  cost = models.DecimalField(max_digits=5, decimal_places=2)
>
> class Invoice_Line_Items_Xref(models.Model):
>  created_dt = models.DateField(auto_now=True)
>  invoice_id = models.IntegerField(default=0)
>  line_item_id = models.IntegerField(default=0)
>  invoice_id = models.ManyToManyField(Invoices)
>  line_item_id = models.ManyToManyField(Line_Items)
>
>
>
>
> I don't think the syntax for the cross reference table above is correct, 
> but it is one of the permutations that I've tried. The layout above 
> resulted in this migration after running makemigrations
>
>
> operations = [
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='invoice_id',
>  field=models.ManyToManyField(to='gpga.Invoices'),
>  ),
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='line_item_id',
>  field=models.ManyToManyField(to='gpga.Line_Items'),
>  ),
> ]
>
>
>

Re: I'm missing something with Models and database migrations

2015-12-27 Thread Peter of the Norse
OK.  Let’s take a look at the documentation 
.
  Here is what you are looking for:

class Invoice(models.Model):
invoice_date = models.DateField(‘created date’, auto_now=True)
line_item_set = models.ManyToManyField(LineItem, through=‘InvoiceLineItem’)

class LineItem(models.Model):
descr = models.CharField(max_length=100)
cost = models.DecimalField(max_digits=5, decimal_places=2)

class InvoiceLineItem(models.Model):
created_dt = models.DateField(auto_now=True)
invoice = models.ForeignKey(Invoice)
line_item = models.ForeignKey(LineItem)

When you use through with a ManyToManyField, it doesn’t create an extra table; 
otherwise, it does.  Also, I’ve cleaned up things so that they match Django 
standards.


> On Dec 22, 2015, at 10:33 PM, Michael Molloy  wrote:
> 
> I figured it out, again with help from Vijay. Thanks for getting me thinking 
> in the right direction.
> 
> So here is my cross reference model:
> 
> class Invoice_Line_Items(models.Model):
>  created_dt = models.DateField('created date', auto_now=True)
>  invoice = models.ManyToManyField(Invoices)
>  line_item = models.ManyToManyField(Line_Items)
> 
> 
> 
> I was incorrectly looking for a single table named Invoice_Line_Items because 
> I didn't understand how Django creates multiple tables to deal with 
> ManyToMany relationships like this. The table I was expecting was there, but 
> it didn't have columns for invoice IDs or line_item IDs. Django actually 
> created these three tables to handle this:
> 
> gpga_invoice_line_items
> gpga_invoice_line_items_invoice
> 
> gpga_invoice_line_items_line_item  
> 
> 
> Thanks again.
> --M
> 
> 
> 
> On Tuesday, December 22, 2015 at 8:49:10 PM UTC-6, Michael Molloy wrote:
> Still confused. I think I still need to create the cross reference Django 
> model myself, and then use makemigrations to turn it into a table.
> 
> I need a place to store invoices and associated line items, so if the model 
> code I put in my first post is incorrect, what should it look like? 
> 
> --Michael
> 
> On Tuesday, December 22, 2015 at 8:29:36 PM UTC-6, Michael Molloy wrote:
> I was trying to create the cross reference table myself. I'm coming at this 
> from a java/oracle background where I would create two tables (invoices and 
> line_items), and then a third (invoice_line_item_xref) that would contain 
> invoice IDs and associated line item IDs. I think you just helped me see my 
> misunderstanding of how Django does things.
> 
> So, in the list of tables (now that I know what I'm looking for), I see a 
> table called invoice_line_items_xref_invoice_id and another called 
> invoice_line_items_xref_line_item_id. Those must be the two tables that 
> Django created to handle the many to many relationship. Is that correct? 
> 
> --Michael 
> 
> On Tuesday, December 22, 2015 at 6:29:51 PM UTC-6, Vijay Khemlani wrote:
> You have two pairs of fields with the same name (line_item_id and 
> invoice_id), what are you trying to do exactly? Why the IntegerFields?
> 
> In a Many To Many relation the columns are added to a third table between the 
> models.
> 
> On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy > wrote:
> Python 3.3 and Django 1.8 running on Openshift with a Postgresql database
> 
> I'm trying to set up an Invoices table, a Line_Item table, and a cross 
> reference between them. Here are the relevant models:
> 
> 
> class Invoices(models.Model):
>  invoice_date = models.DateField('created date', auto_now=True)
> 
> class Line_Items(models.Model):
>  descr = models.CharField(max_length=100)
>  cost = models.DecimalField(max_digits=5, decimal_places=2)
> 
> class Invoice_Line_Items_Xref(models.Model):
>  created_dt = models.DateField(auto_now=True)
>  invoice_id = models.IntegerField(default=0)
>  line_item_id = models.IntegerField(default=0)
>  invoice_id = models.ManyToManyField(Invoices)
>  line_item_id = models.ManyToManyField(Line_Items)
> 
> 
> 
> I don't think the syntax for the cross reference table above is correct, but 
> it is one of the permutations that I've tried. The layout above resulted in 
> this migration after running makemigrations
> 
> operations = [
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='invoice_id',
>  field=models.ManyToManyField(to='gpga.Invoices'),
>  ),
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='line_item_id',
>  field=models.ManyToManyField(to='gpga.Line_Items'),
>  ),
> ]
> 
> 
> 
> However, when I push the code to Openshift, even though the migration runs 
> against the database, the invoice_id and line_item_id columns do not appear 
> on the database table. 
> 
> I have no idea what I'm doing wrong. Thank you for any help.
> 
> --Michael
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Django users" group.
> To 

Re: I'm missing something with Models and database migrations

2015-12-23 Thread Vijay Khemlani
If you want to make the middle table by yourself then those ManyToManyField
need to be ForeignKey instead.

On Wed, Dec 23, 2015 at 2:33 AM, Michael Molloy  wrote:

> I figured it out, again with help from Vijay. Thanks for getting me
> thinking in the right direction.
>
> So here is my cross reference model:
>
> class Invoice_Line_Items(models.Model):
>  created_dt = models.DateField('created date', auto_now=True)
>  invoice = models.ManyToManyField(Invoices)
>  line_item = models.ManyToManyField(Line_Items)
>
>
>
> I was incorrectly looking for a single table named Invoice_Line_Items because 
> I didn't understand how Django creates multiple tables to deal with 
> ManyToMany relationships like this. The table I was expecting was there, but 
> it didn't have columns for invoice IDs or line_item IDs. Django actually 
> created these three tables to handle this:
>
>
> gpga_invoice_line_items
>
> gpga_invoice_line_items_invoice
>
> gpga_invoice_line_items_line_item
>
>
> Thanks again.
>
> --M
>
>
>
>
> On Tuesday, December 22, 2015 at 8:49:10 PM UTC-6, Michael Molloy wrote:
>>
>> Still confused. I think I still need to create the cross reference Django
>> model myself, and then use makemigrations to turn it into a table.
>>
>> I need a place to store invoices and associated line items, so if the
>> model code I put in my first post is incorrect, what should it look like?
>>
>> --Michael
>>
>> On Tuesday, December 22, 2015 at 8:29:36 PM UTC-6, Michael Molloy wrote:
>>>
>>> I was trying to create the cross reference table myself. I'm coming at
>>> this from a java/oracle background where I would create two tables
>>> (invoices and line_items), and then a third (invoice_line_item_xref) that
>>> would contain invoice IDs and associated line item IDs. I think you just
>>> helped me see my misunderstanding of how Django does things.
>>>
>>> So, in the list of tables (now that I know what I'm looking for), I see
>>> a table called invoice_line_items_xref_invoice_id and another called
>>> invoice_line_items_xref_line_item_id. Those must be the two tables that
>>> Django created to handle the many to many relationship. Is that correct?
>>>
>>> --Michael
>>>
>>> On Tuesday, December 22, 2015 at 6:29:51 PM UTC-6, Vijay Khemlani wrote:

 You have two pairs of fields with the same name (line_item_id
 and invoice_id), what are you trying to do exactly? Why the IntegerFields?

 In a Many To Many relation the columns are added to a third table
 between the models.

 On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy 
 wrote:

> Python 3.3 and Django 1.8 running on Openshift with a Postgresql
> database
>
> I'm trying to set up an Invoices table, a Line_Item table, and a cross
> reference between them. Here are the relevant models:
>
>
> class Invoices(models.Model):
>  invoice_date = models.DateField('created date', auto_now=True)
>
> class Line_Items(models.Model):
>  descr = models.CharField(max_length=100)
>  cost = models.DecimalField(max_digits=5, decimal_places=2)
>
> class Invoice_Line_Items_Xref(models.Model):
>  created_dt = models.DateField(auto_now=True)
>  invoice_id = models.IntegerField(default=0)
>  line_item_id = models.IntegerField(default=0)
>  invoice_id = models.ManyToManyField(Invoices)
>  line_item_id = models.ManyToManyField(Line_Items)
>
>
>
>
> I don't think the syntax for the cross reference table above is correct, 
> but it is one of the permutations that I've tried. The layout above 
> resulted in this migration after running makemigrations
>
>
> operations = [
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='invoice_id',
>  field=models.ManyToManyField(to='gpga.Invoices'),
>  ),
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='line_item_id',
>  field=models.ManyToManyField(to='gpga.Line_Items'),
>  ),
> ]
>
>
>
> However, when I push the code to Openshift, even though the migration 
> runs against the database, the invoice_id and line_item_id columns do not 
> appear on the database table.
>
>
> I have no idea what I'm doing wrong. Thank you for any help.
>
>
> --Michael
>
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9953458c-908d-4376-89f9-eb68e37d527a%40googlegroups.com
> 

Re: I'm missing something with Models and database migrations

2015-12-22 Thread Michael Molloy
I figured it out, again with help from Vijay. Thanks for getting me 
thinking in the right direction.

So here is my cross reference model:

class Invoice_Line_Items(models.Model):
 created_dt = models.DateField('created date', auto_now=True)
 invoice = models.ManyToManyField(Invoices)
 line_item = models.ManyToManyField(Line_Items)



I was incorrectly looking for a single table named Invoice_Line_Items because I 
didn't understand how Django creates multiple tables to deal with ManyToMany 
relationships like this. The table I was expecting was there, but it didn't 
have columns for invoice IDs or line_item IDs. Django actually created these 
three tables to handle this:


gpga_invoice_line_items

gpga_invoice_line_items_invoice

gpga_invoice_line_items_line_item  


Thanks again.

--M




On Tuesday, December 22, 2015 at 8:49:10 PM UTC-6, Michael Molloy wrote:
>
> Still confused. I think I still need to create the cross reference Django 
> model myself, and then use makemigrations to turn it into a table.
>
> I need a place to store invoices and associated line items, so if the 
> model code I put in my first post is incorrect, what should it look like? 
>
> --Michael
>
> On Tuesday, December 22, 2015 at 8:29:36 PM UTC-6, Michael Molloy wrote:
>>
>> I was trying to create the cross reference table myself. I'm coming at 
>> this from a java/oracle background where I would create two tables 
>> (invoices and line_items), and then a third (invoice_line_item_xref) that 
>> would contain invoice IDs and associated line item IDs. I think you just 
>> helped me see my misunderstanding of how Django does things.
>>
>> So, in the list of tables (now that I know what I'm looking for), I see a 
>> table called invoice_line_items_xref_invoice_id and another called 
>> invoice_line_items_xref_line_item_id. Those must be the two tables that 
>> Django created to handle the many to many relationship. Is that correct? 
>>
>> --Michael 
>>
>> On Tuesday, December 22, 2015 at 6:29:51 PM UTC-6, Vijay Khemlani wrote:
>>>
>>> You have two pairs of fields with the same name (line_item_id 
>>> and invoice_id), what are you trying to do exactly? Why the IntegerFields?
>>>
>>> In a Many To Many relation the columns are added to a third table 
>>> between the models.
>>>
>>> On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy  
>>> wrote:
>>>
 Python 3.3 and Django 1.8 running on Openshift with a Postgresql 
 database

 I'm trying to set up an Invoices table, a Line_Item table, and a cross 
 reference between them. Here are the relevant models:


 class Invoices(models.Model):
  invoice_date = models.DateField('created date', auto_now=True)

 class Line_Items(models.Model):
  descr = models.CharField(max_length=100)
  cost = models.DecimalField(max_digits=5, decimal_places=2)

 class Invoice_Line_Items_Xref(models.Model):
  created_dt = models.DateField(auto_now=True)
  invoice_id = models.IntegerField(default=0)
  line_item_id = models.IntegerField(default=0)
  invoice_id = models.ManyToManyField(Invoices)
  line_item_id = models.ManyToManyField(Line_Items)




 I don't think the syntax for the cross reference table above is correct, 
 but it is one of the permutations that I've tried. The layout above 
 resulted in this migration after running makemigrations


 operations = [
  migrations.AddField(
  model_name='invoice_line_items_xref',
  name='invoice_id',
  field=models.ManyToManyField(to='gpga.Invoices'),
  ),
  migrations.AddField(
  model_name='invoice_line_items_xref',
  name='line_item_id',
  field=models.ManyToManyField(to='gpga.Line_Items'),
  ),
 ]



 However, when I push the code to Openshift, even though the migration runs 
 against the database, the invoice_id and line_item_id columns do not 
 appear on the database table. 


 I have no idea what I'm doing wrong. Thank you for any help.


 --Michael

 -- 
 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...@googlegroups.com.
 To post to this group, send email to django...@googlegroups.com.
 Visit this group at https://groups.google.com/group/django-users.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/django-users/9953458c-908d-4376-89f9-eb68e37d527a%40googlegroups.com
  
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this 

Re: I'm missing something with Models and database migrations

2015-12-22 Thread Michael Molloy
Still confused. I think I still need to create the cross reference Django 
model myself, and then use makemigrations to turn it into a table.

I need a place to store invoices and associated line items, so if the model 
code I put in my first post is incorrect, what should it look like? 

--Michael

On Tuesday, December 22, 2015 at 8:29:36 PM UTC-6, Michael Molloy wrote:
>
> I was trying to create the cross reference table myself. I'm coming at 
> this from a java/oracle background where I would create two tables 
> (invoices and line_items), and then a third (invoice_line_item_xref) that 
> would contain invoice IDs and associated line item IDs. I think you just 
> helped me see my misunderstanding of how Django does things.
>
> So, in the list of tables (now that I know what I'm looking for), I see a 
> table called invoice_line_items_xref_invoice_id and another called 
> invoice_line_items_xref_line_item_id. Those must be the two tables that 
> Django created to handle the many to many relationship. Is that correct? 
>
> --Michael 
>
> On Tuesday, December 22, 2015 at 6:29:51 PM UTC-6, Vijay Khemlani wrote:
>>
>> You have two pairs of fields with the same name (line_item_id 
>> and invoice_id), what are you trying to do exactly? Why the IntegerFields?
>>
>> In a Many To Many relation the columns are added to a third table between 
>> the models.
>>
>> On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy  
>> wrote:
>>
>>> Python 3.3 and Django 1.8 running on Openshift with a Postgresql database
>>>
>>> I'm trying to set up an Invoices table, a Line_Item table, and a cross 
>>> reference between them. Here are the relevant models:
>>>
>>>
>>> class Invoices(models.Model):
>>>  invoice_date = models.DateField('created date', auto_now=True)
>>>
>>> class Line_Items(models.Model):
>>>  descr = models.CharField(max_length=100)
>>>  cost = models.DecimalField(max_digits=5, decimal_places=2)
>>>
>>> class Invoice_Line_Items_Xref(models.Model):
>>>  created_dt = models.DateField(auto_now=True)
>>>  invoice_id = models.IntegerField(default=0)
>>>  line_item_id = models.IntegerField(default=0)
>>>  invoice_id = models.ManyToManyField(Invoices)
>>>  line_item_id = models.ManyToManyField(Line_Items)
>>>
>>>
>>>
>>>
>>> I don't think the syntax for the cross reference table above is correct, 
>>> but it is one of the permutations that I've tried. The layout above 
>>> resulted in this migration after running makemigrations
>>>
>>>
>>> operations = [
>>>  migrations.AddField(
>>>  model_name='invoice_line_items_xref',
>>>  name='invoice_id',
>>>  field=models.ManyToManyField(to='gpga.Invoices'),
>>>  ),
>>>  migrations.AddField(
>>>  model_name='invoice_line_items_xref',
>>>  name='line_item_id',
>>>  field=models.ManyToManyField(to='gpga.Line_Items'),
>>>  ),
>>> ]
>>>
>>>
>>>
>>> However, when I push the code to Openshift, even though the migration runs 
>>> against the database, the invoice_id and line_item_id columns do not appear 
>>> on the database table. 
>>>
>>>
>>> I have no idea what I'm doing wrong. Thank you for any help.
>>>
>>>
>>> --Michael
>>>
>>> -- 
>>> 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...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/9953458c-908d-4376-89f9-eb68e37d527a%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0586e0cf-36c9-4011-bdad-316db5a16a09%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm missing something with Models and database migrations

2015-12-22 Thread Michael Molloy
I was trying to create the cross reference table myself. I'm coming at this 
from a java/oracle background where I would create two tables (invoices and 
line_items), and then a third (invoice_line_item_xref) that would contain 
invoice IDs and associated line item IDs. I think you just helped me see my 
misunderstanding of how Django does things.

So, in the list of tables (now that I know what I'm looking for), I see a 
table called invoice_line_items_xref_invoice_id and another called 
invoice_line_items_xref_line_item_id. Those must be the two tables that 
Django created to handle the many to many relationship. Is that correct? 

--Michael 

On Tuesday, December 22, 2015 at 6:29:51 PM UTC-6, Vijay Khemlani wrote:
>
> You have two pairs of fields with the same name (line_item_id 
> and invoice_id), what are you trying to do exactly? Why the IntegerFields?
>
> In a Many To Many relation the columns are added to a third table between 
> the models.
>
> On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy  > wrote:
>
>> Python 3.3 and Django 1.8 running on Openshift with a Postgresql database
>>
>> I'm trying to set up an Invoices table, a Line_Item table, and a cross 
>> reference between them. Here are the relevant models:
>>
>>
>> class Invoices(models.Model):
>>  invoice_date = models.DateField('created date', auto_now=True)
>>
>> class Line_Items(models.Model):
>>  descr = models.CharField(max_length=100)
>>  cost = models.DecimalField(max_digits=5, decimal_places=2)
>>
>> class Invoice_Line_Items_Xref(models.Model):
>>  created_dt = models.DateField(auto_now=True)
>>  invoice_id = models.IntegerField(default=0)
>>  line_item_id = models.IntegerField(default=0)
>>  invoice_id = models.ManyToManyField(Invoices)
>>  line_item_id = models.ManyToManyField(Line_Items)
>>
>>
>>
>>
>> I don't think the syntax for the cross reference table above is correct, but 
>> it is one of the permutations that I've tried. The layout above resulted in 
>> this migration after running makemigrations
>>
>>
>> operations = [
>>  migrations.AddField(
>>  model_name='invoice_line_items_xref',
>>  name='invoice_id',
>>  field=models.ManyToManyField(to='gpga.Invoices'),
>>  ),
>>  migrations.AddField(
>>  model_name='invoice_line_items_xref',
>>  name='line_item_id',
>>  field=models.ManyToManyField(to='gpga.Line_Items'),
>>  ),
>> ]
>>
>>
>>
>> However, when I push the code to Openshift, even though the migration runs 
>> against the database, the invoice_id and line_item_id columns do not appear 
>> on the database table. 
>>
>>
>> I have no idea what I'm doing wrong. Thank you for any help.
>>
>>
>> --Michael
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/9953458c-908d-4376-89f9-eb68e37d527a%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8c97e56a-a196-4b73-84cd-76987ba41bf8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: I'm missing something with Models and database migrations

2015-12-22 Thread Vijay Khemlani
You have two pairs of fields with the same name (line_item_id
and invoice_id), what are you trying to do exactly? Why the IntegerFields?

In a Many To Many relation the columns are added to a third table between
the models.

On Tue, Dec 22, 2015 at 9:20 PM, Michael Molloy  wrote:

> Python 3.3 and Django 1.8 running on Openshift with a Postgresql database
>
> I'm trying to set up an Invoices table, a Line_Item table, and a cross
> reference between them. Here are the relevant models:
>
>
> class Invoices(models.Model):
>  invoice_date = models.DateField('created date', auto_now=True)
>
> class Line_Items(models.Model):
>  descr = models.CharField(max_length=100)
>  cost = models.DecimalField(max_digits=5, decimal_places=2)
>
> class Invoice_Line_Items_Xref(models.Model):
>  created_dt = models.DateField(auto_now=True)
>  invoice_id = models.IntegerField(default=0)
>  line_item_id = models.IntegerField(default=0)
>  invoice_id = models.ManyToManyField(Invoices)
>  line_item_id = models.ManyToManyField(Line_Items)
>
>
>
>
> I don't think the syntax for the cross reference table above is correct, but 
> it is one of the permutations that I've tried. The layout above resulted in 
> this migration after running makemigrations
>
>
> operations = [
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='invoice_id',
>  field=models.ManyToManyField(to='gpga.Invoices'),
>  ),
>  migrations.AddField(
>  model_name='invoice_line_items_xref',
>  name='line_item_id',
>  field=models.ManyToManyField(to='gpga.Line_Items'),
>  ),
> ]
>
>
>
> However, when I push the code to Openshift, even though the migration runs 
> against the database, the invoice_id and line_item_id columns do not appear 
> on the database table.
>
>
> I have no idea what I'm doing wrong. Thank you for any help.
>
>
> --Michael
>
> --
> 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 https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/9953458c-908d-4376-89f9-eb68e37d527a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALn3ei19SGbsdnmwgacUu_zqpf9hudYwJYPG9YzEofNPmzvouQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


I'm missing something with Models and database migrations

2015-12-22 Thread Michael Molloy
Python 3.3 and Django 1.8 running on Openshift with a Postgresql database

I'm trying to set up an Invoices table, a Line_Item table, and a cross 
reference between them. Here are the relevant models:


class Invoices(models.Model):
 invoice_date = models.DateField('created date', auto_now=True)

class Line_Items(models.Model):
 descr = models.CharField(max_length=100)
 cost = models.DecimalField(max_digits=5, decimal_places=2)

class Invoice_Line_Items_Xref(models.Model):
 created_dt = models.DateField(auto_now=True)
 invoice_id = models.IntegerField(default=0)
 line_item_id = models.IntegerField(default=0)
 invoice_id = models.ManyToManyField(Invoices)
 line_item_id = models.ManyToManyField(Line_Items)




I don't think the syntax for the cross reference table above is correct, but it 
is one of the permutations that I've tried. The layout above resulted in this 
migration after running makemigrations


operations = [
 migrations.AddField(
 model_name='invoice_line_items_xref',
 name='invoice_id',
 field=models.ManyToManyField(to='gpga.Invoices'),
 ),
 migrations.AddField(
 model_name='invoice_line_items_xref',
 name='line_item_id',
 field=models.ManyToManyField(to='gpga.Line_Items'),
 ),
]



However, when I push the code to Openshift, even though the migration runs 
against the database, the invoice_id and line_item_id columns do not appear on 
the database table. 


I have no idea what I'm doing wrong. Thank you for any help.


--Michael

-- 
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 https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9953458c-908d-4376-89f9-eb68e37d527a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.