I'd suggest taking a step back from the data structure of your application,
decide what you want to do with your data, and then take another stab at
it.
If you have more questions, I'd recommend posting your questions using your
application's real domain instead of continuing to use "similar" idea
That's exactly what I want. Should I use 'through' or just make a new Model?
As I said before, with your car example.. if you just want to know how
> many of a part are in a car, Then what you did is enough, then you
> could have some cars, and some pieces, say
>
> Cars = (Motorcycle, 4x4, Car)
oh, and the advantage is that you could have a car, for example
car = Car.objects.get(name="4x4")
car.parts.get(name="Transmission").partsincar.amount >> 2
The difference with doing it with another model is that you cannot do
this, for example (or not as easily)
Car.objects.filter(parts__name="
> Thanks, but damn, isn't that overly complicated (for me). Using through
> looks like a easier way, but then I have to add Wheel four times and can't
> just type '4' in some field, since I don't need it to exist in database four
> time, just an information that there are four wheels.
as I said, i
On 12-07-06 10:14 AM, Soviet wrote:
Thanks, but damn, isn't that overly complicated (for me). Using
through looks like a easier way, but then I have to add Wheel four
times and can't just type '4' in some field, since I don't need it to
exist in database four time, just an information that ther
If I'll do something like:
class Car(models.Model):
name = models.CharField(max_length=100)
parts = models.ManyToManyField('Part', through = 'PartsInCar')
class Part(models.Model):
name = models.CharField(max_length=100)
class PartsInCar(models.Model):
car = models.ForeignKey('Ca
Thanks, but damn, isn't that overly complicated (for me). Using through
looks like a easier way, but then I have to add Wheel four times and can't
just type '4' in some field, since I don't need it to exist in database
four time, just an information that there are four wheels.
W dniu piątek, 6
> I don't understand. It's the same wheel added four times, not four
> different wheels.
I guess you could implement it either way. The thing is that doing it
this way would become complicated at the time you need to define what
is attached where. For Lego pieces, I'd do this:
class LegoType(Mode
> You don't. You get all wheel objects and count them.
>
I don't understand. It's the same wheel added four times, not four
different wheels.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To view this discussion on the web visit
https:/
On 6-7-2012 15:17, Soviet wrote:
> Lets try LEGO pieces. I have a LEGO set that has many pieces (ManyToMany).
> But I have 4 wheels and 1 brick in that set. The 'brick' can be added with
> no problem, but how do I save the information that there's 4 'wheel'
> objects and not only one?
You don'
Alright, bad example.
Lets try LEGO pieces. I have a LEGO set that has many pieces (ManyToMany).
But I have 4 wheels and 1 brick in that set. The 'brick' can be added with
no problem, but how do I save the information that there's 4 'wheel'
objects and not only one?
W dniu czwartek, 5 lipca 2
> But! I do have another problem. Lets ditch our football example. Let's say
> that I have something like that:
>
> class CherryTree(models.Model):
> name = models.IntegerField()
> cherries = models.ManyToManyField('CherryFruit')
>
> class CherryFruit(models.Model):
> name = models.Char
Thanks a lot! After few experiments I think I get it :).
But! I do have another problem. Lets ditch our football example. Let's say
that I have something like that:
class CherryTree(models.Model):
name = models.IntegerField()
cherries = models.ManyToManyField('CherryFruit')
class Cherry
>
>
> Let me follow up on this. Say I want to add list of all Teams my Players
> played for. What you're saying is that I don't have to add ForeignKey to
> Team and just use team_name field from Team model? Will it work?
>
> This relations stuff is confusing :P.
>
> Haha, no problem! It'll come nat
W dniu poniedziałek, 25 czerwca 2012 18:54:48 UTC+2 użytkownik Kurtis
napisał:
>
> Actually, I'm pretty confused about this part :) A ForeignKey is used to
> relate to another Model -- not just a Model Field -- in Django's ORM.
>
> So for example, if you have a Team Model and a Player Model, you'
>
>
>> The mechanism must involve deferred resolution of the second model by
> passing the model class name in as a string. Without string syntax python
> insists on knowing what that class is at the time it sees the reference.
> Don't know more than that though ;)
>
>
https://github.com/django/dj
On 12-06-25 10:02 AM, Adrian Bool wrote:
On 25 Jun 2012, at 17:53, Soviet wrote:
Thank you kind sir for your fast response, that worked brilliantly.
Can I be cheeky and ask why does it work? :)
Magic! ;-)
The mechanism must involve deferred resolution of the second model by
passing the model
On 25 Jun 2012, at 17:53, Soviet wrote:
> Thank you kind sir for your fast response, that worked brilliantly.
> Can I be cheeky and ask why does it work? :)
Magic! ;-)
Although seriously, Django obviously has some code in there to handle just the
situation you have come across. Sorry, I don't
>
> [...]
> > Let's say I have two models and in each I have field with ForeignKey
> > relating to field in other model (hope it's clear). [...]
>
Actually, I'm pretty confused about this part :) A ForeignKey is used to
relate to another Model -- not just a Model Field -- in Django's ORM.
So for
Thank you kind sir for your fast response, that worked brilliantly.
Can I be cheeky and ask why does it work? :)
On 25 Cze, 18:43, Adrian Bool wrote:
> On 25 Jun 2012, at 17:41, Soviet wrote:
>
> > I'm new to this Django thing and I run into first problem :).
>
> > Let's say I have two models and
On 25 Jun 2012, at 17:41, Soviet wrote:
> I'm new to this Django thing and I run into first problem :).
>
> Let's say I have two models and in each I have field with ForeignKey
> relating to field in other model (hope it's clear). Now that I want to
> run migrate with South, I'm getting "NameErr
patrickk írta:
>maybe this helps:
>http://www.djangoproject.com/documentation/model_api/#blank
>
>
Helps? Works!
Thank you, Patrick.
Charlie.
--
"...s minden mestert kinevettem, ki nem nevetett önmagán."
GPG public key: http://www.rendszergazda.com/gpg/charlie-gpg-public-key.asc
--~--~---
maybe this helps:
http://www.djangoproject.com/documentation/model_api/#blank
patrick
Am 13.06.2006 um 15:54 schrieb Nagy Károly:
>
> I have a tree model data and a foreign key is defined with a
> null=True.
> Generated db table is correct (field is NULL instead of NOT NULL), but
> in the adm
23 matches
Mail list logo