I accidently hit Send before I was finished.

the development server validates this model, but I can't seem to
figure out how to access the last_name and first_name fields in the
template. When I do the following:

{{object.last_name}}

I get a Template Syntax Error. Caught ValueError while rendering:
invalid literal for int() with base 10: "Smith"

Is there any way around this short of modifying the legacy database?
If I can't find a way around this, my organization will most likely
not start using Django since the initial push is to use it for some
legacy db to implement reports and form.

Thanks!

On Oct 6, 1:55 pm, msbuck <mbuckn...@usgs.gov> wrote:
> I have a legacy Oracle database which I'm trying to model. I used
> inspectdb which did a good job. However, a few of my tables contain
> two fields which combine to form a foreign key constraint. In other
> words the legacy database was created like this:
>
> CREATE TABLE "MY_TABLE"
> ("TRACKING_ID" NUMBER NOT NULL ENABLE,
>  "LAST_NAME" VARCHAR(50 BYTE) NOT NULL ENABLE,
>  "FIRST_NAME" VARCHAR(50 BYTE) NOT NULL ENABLE
> CONSTRAINT 'EMP_REF_FK" FOREIGN KEY ("LAST NAME", "FIRST NAME")
> REFERENCES "EMPLOYEE_REF"("LAST_NAME, "FIRST_NAME") ENABLE
>
> The EMPLOYEE_REF table has a primary key and the last name and first
> name fields.
>
> The models  I'm using is:
>
> class EmployeeRef(models.Model):
>     employee_ref_id = models.IntegerField(primary_key=True)
>     last_name = models.CharField(max_length=50)
>     first_name = models.CharField(max_length=50)
>
> class MyTable(models.Model):
>     hour_tracking_id = models.DecimalField(max_digits=10,
> decimal_places=0, primary_key=True)
>     last_name = models.ForeignKey(EmployeeRef, db_column='last_name',
> related_name='employee.last_name')
>     first_name = models.ForeignKey(EmployeeRef,
> db_column='first_name', related_name='employee.first_name')

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to