Re: New user - struggling with database design

2014-09-02 Thread Derek
That looks like a database error - check in your database as to which 
tables have been created.

On Thursday, 28 August 2014 18:05:01 UTC+2, Jason G wrote:
>
> Ok - here is where I am stuck now. Any thoughts?
>
> If I try to render {{ vessel.CurrentBrew }} in a view, I get something 
> like this:
>  0x7f76f0088e10>
>
> and this errors out:
>
> {% for Brew in vessel.CurrentBrew.all %}X{{ Brew.ActualName }}{% 
> endfor %}
>
> (1146, "Table 'dbLunawireBrewing.brewlog_vessel_CurrentBrew' doesn't exist")
>
>
>
> The vessel model looks like this:
>
> class Vessel(models.Model):
> Name = models.CharField(max_length=20)
> ShortName = models.CharField(max_length=4)
> Gallons = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
> blank=True)
> Weight = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
> blank=True)
> CurrentBrew  = models.ManyToManyField('Brew', related_name="brew")
> def __unicode__(self):
> return self.Name
>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/41928000-f83d-4403-aa9d-086429f1fa80%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user - struggling with database design

2014-08-28 Thread Jason G
Ok - here is where I am stuck now. Any thoughts?

If I try to render {{ vessel.CurrentBrew }} in a view, I get something like 
this:


and this errors out:

{% for Brew in vessel.CurrentBrew.all %}X{{ Brew.ActualName }}{% 
endfor %}

(1146, "Table 'dbLunawireBrewing.brewlog_vessel_CurrentBrew' doesn't exist")



The vessel model looks like this:

class Vessel(models.Model):
Name = models.CharField(max_length=20)
ShortName = models.CharField(max_length=4)
Gallons = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
blank=True)
Weight = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
blank=True)
CurrentBrew  = models.ManyToManyField('Brew', related_name="brew")
def __unicode__(self):
return self.Name


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2363ed3e-a787-46a0-b887-7706d0a9c315%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user - struggling with database design

2014-08-28 Thread Jason G
Hi Gerald - thanks for the quick reply! Turns out it was just an issue with 
quotes...not sure I am doing it right just yet, but at least I've passed 
the error.

>  

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7b725cda-6078-4859-8e20-4ef05d2d2c8d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: New user - struggling with database design

2014-08-28 Thread Gerald Klein
their order if I am understanding you right does not effect this, the last
part is just  a join between the tables, you don't have to create another
table


On Thu, Aug 28, 2014 at 8:46 AM, Jason G  wrote:

> Hi all,
>
> I am building an app to track my home brewing.
>
> I have two tables, one for vessels, and another for brews.
>
> I want the Brew table to have a pick-list, relation to Vessels so I can
> say what vessel the brew is in.
>
> I also want to render a table that shows all Vessels and what Brew is in
> each. There should be a one-to-one relationship until the Brew is 'Kicked',
> which could be a vessel or maybe a null value in the Brew table.
>
> My code currently doesn't work, but looks something like this:
>
> class Vessel(models.Model):
> Name = models.CharField(max_length=20)
> Gallons = models.DecimalField(max_digits=4, decimal_places=2,
> null=True, blank=True)
> Weight = models.DecimalField(max_digits=4, decimal_places=2,
> null=True, blank=True)
> CurrentBrew  = models.ForeignKey(Brew, db_column='Vessel')
>  <--this is what I'm trying to add
> def __unicode__(self):
> return self.Name
>
> class Brew(models.Model):
> ...
> Name = models.CharField(max_length=40, null=True, default='TBD')
> InformalName = models.CharField(max_length=40)
> Status = models.IntegerField(max_length=1, choices=STATUS_CHOICES,
> default=1, null=False, blank=False)
> Gallons = models.DecimalField(max_digits=4, decimal_places=2,
> null=True, blank=True)
> Vessel = models.ForeignKey(Vessel)
> Style = models.ForeignKey(Style)
> Event = models.CharField(max_length=40, null=True, blank=True)
>
> In this model, which I'm not sure is the best way to do it, the Vessel
> class does not yet know about the Brew model that is below it.
>
> I'm starting to grasp this language (and love it, coming from doing
> asp/sql several years ago) but I'm stuck here. Help!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/dd40f53a-c398-4806-b09d-1605d3f15ead%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Gerald Klein DBA

contac...@geraldklein.com

www.geraldklein.com 

geraldklein.wordpress.com

j...@zognet.com

708-599-0352


Arch, Gentoo I3, Ranger & Vim the coding triple threat.

Linux registered user #548580

Brought to you by the Amish Mafia

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP8NtCz9%2BURQG23wR%3DXSkUozJ7vFvDXOnp5cfyRPMFdXTOJ%2BzQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


New user - struggling with database design

2014-08-28 Thread Jason G
Hi all,

I am building an app to track my home brewing.

I have two tables, one for vessels, and another for brews.

I want the Brew table to have a pick-list, relation to Vessels so I can say 
what vessel the brew is in.

I also want to render a table that shows all Vessels and what Brew is in 
each. There should be a one-to-one relationship until the Brew is 'Kicked', 
which could be a vessel or maybe a null value in the Brew table.

My code currently doesn't work, but looks something like this:

class Vessel(models.Model):
Name = models.CharField(max_length=20)
Gallons = models.DecimalField(max_digits=4, decimal_places=2, 
null=True, blank=True)
Weight = models.DecimalField(max_digits=4, decimal_places=2, null=True, 
blank=True)
CurrentBrew  = models.ForeignKey(Brew, db_column='Vessel') 
 <--this is what I'm trying to add
def __unicode__(self):
return self.Name

class Brew(models.Model):
...
Name = models.CharField(max_length=40, null=True, default='TBD')
InformalName = models.CharField(max_length=40)
Status = models.IntegerField(max_length=1, choices=STATUS_CHOICES, 
default=1, null=False, blank=False)
Gallons = models.DecimalField(max_digits=4, decimal_places=2, 
null=True, blank=True)
Vessel = models.ForeignKey(Vessel)
Style = models.ForeignKey(Style)
Event = models.CharField(max_length=40, null=True, blank=True)

In this model, which I'm not sure is the best way to do it, the Vessel 
class does not yet know about the Brew model that is below it.

I'm starting to grasp this language (and love it, coming from doing asp/sql 
several years ago) but I'm stuck here. Help!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dd40f53a-c398-4806-b09d-1605d3f15ead%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.