> Turns out that's the problem. I wanted to use a field from my Car model:
> car_id, so the link on the website would look like:
> www.blablabla.com/cars/3421, where 3421 is the car_id. Unfortunately, the
> car_id is not the same as <pk>. Can I achieve something like that with class

what's car_id and why isn't it your PK?

you should post your full models when asking for help, in general.

As a general rule, having a car_id field in a Car model is
unnecessary. Models come with ids of their own by default, you don't
need to define them. If you have IDs of your own that you want to
reflect in your database, first of all, I'd call it just "id", so you
can do my_car.id, my_car.car_id sounds a little bit redundant to my
taste, and secondly, you can define it as id =
models.IntegerField(primary_key=True). If you do that, your pk will be
the ID you defined (you can do this with a CharField as well, I think)

-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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

Reply via email to