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.


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.