:43
To: Django users
Subject: Specifying model relationship as string vs concrete model?
Since Django provides two ways of specifying model relationship,
models.ForeignKey('User') vs models.ForeignKey(User)
Which one is more preferred and recommended? Is there any upside or downside of
choosing
des two ways of specifying model relationship,
>
>
>models.ForeignKey('User') vs models.ForeignKey(User)
>
>
>Which one is more preferred and recommended? Is there any upside or downside
>of choosing one over the other? In Django documentation, all the example are
>of the
Since Django provides two ways of specifying model relationship,
models.ForeignKey('User') vs models.ForeignKey(User)
Which one is more preferred and recommended? Is there any upside or
downside of choosing one over the other? In Django documentation, all the
example are of the second form
On Tue, Dec 22, 2015 at 6:50 AM, Pemby wrote:
> With this code for example.
>
> class Students(models.Model):
> first_name = models.CharField(max_length=30)
> last_name = models.CharField(max_length=30)
> classChoice1 = ?
> classChoice2
With this code for example.
class Students(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
classChoice1 = ?
classChoice2 = ?
classChouce3 = ?
class Class(models.Model):
models.py:
class Like(models.Model):
event = models.ForeignKey(Event)
user = model.ForeignKey(User)
class Meta:
unique_together = ("event", "user")
Now you can count Likes for a given event
likes =
Thanks ! I'll get to work on that and see how it goes!
On Monday, August 25, 2014 8:26:35 PM UTC-4, Tim Chase wrote:
>
> On 2014-08-25 17:00, amarshall wrote:
> > Hmm, That may work. I should have also noted one thing. I'm
> > actually using Django as the backend for mobile application. Both
>
On 2014-08-25 17:00, amarshall wrote:
> Hmm, That may work. I should have also noted one thing. I'm
> actually using Django as the backend for mobile application. Both
> *Android* and iOS. So I'd like to do something like this, in the
> simplest matter:
>
> pseudocode:
>
> get
Hmm, That may work. I should have also noted one thing. I'm actually using
Django as the backend for mobile application. Both *Android* and iOS. So
I'd like to do something like this, in the simplest matter:
pseudocode:
get information from the server.
if this_user HAS NOT
The other way would be to simply wire a cookie to user's browser and use js
to disable the the like button if the cookie is present if you can get away
with it. Not sure if you need to store that info against the user to see
which items they liked...
On 26/08/2014 8:41 am, "amarshall"
Hi,
I'm trying to implement likes on a Model in which 1 user will be able to
like an a model (named "event") "once" and only once.
so, I have a model like this:
class Event(models.Model):
user = models.ForeignKey(User)
. #other fields
.
likes =
On Fri, Jul 5, 2013 at 7:44 AM, Kakar Arunachal Service
<kakararunachalserv...@gmail.com> wrote:
> Hello,
> Please guide me in model relationship. When to use many to many, many to
> one, one to one relationships??? I'm all confused.
> Thank you.
http://www.datanamic.com
Hello,
Please guide me in model relationship. When to use many to many, many to
one, one to one relationships??? I'm all confused.
Thank you.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop
https://docs.djangoproject.com/en/1.5/topics/db/models/#relationships
2013/7/5 Kakar Arunachal Service <kakararunachalserv...@gmail.com>
> Hello,
> Please guide me in model relationship. When to use many to many, many to
> one, one to one relationships??? I'm all confus
On Sun, 2009-03-22 at 22:17 -0700, Super McFly wrote:
[...]
> Of course I was just doing something silly. I was using
> 'myproject.media.models.Image' when I only needed 'media.Image'. It's
> still not clear to me why this format is used but it works.
That's what this bit of the documentation
> The solutions isn't too hard, though. Use the "string format" for
> referencing from, say, Image -> Container.
> Seehttp://docs.djangoproject.com/en/dev/ref/models/fields/#foreignkeyfor
> documentation about this.
Thank you for replying. I tried that method before but I received an
error
On Sun, 2009-03-22 at 14:37 -0700, Super McFly wrote:
> This is a bit of a tricky one but I need help solving the following
> error:
>
> ImportError: cannot import name Container
>
> I'm sure it has something to do with the unusual relationships I have
> between two models. I'll put a
This is a bit of a tricky one but I need help solving the following
error:
ImportError: cannot import name Container
I'm sure it has something to do with the unusual relationships I have
between two models. I'll put a simplified version below.
It started when I added the 'image' field to the
I've written a quick django app (mostly using the wonderful admin
interface) to store content for some courses I'm developing.
I have a number of models defined already: Modules, Objectives,
Questions, Labs, etc.
Basically a content module consists of multiple objectives (define X,
list Y, Use
Hello,
> If a gallery is unique to a rantal, why use a n:m relationship? You
> should be able to use a 1:m if each photo is associated with exactly one
> rental. As to putting the images in rental-specific sub-directories, can
> you make the association from photo to rental explicit and do this?
[EMAIL PROTECTED] wrote:
> Hello,
>
> I have a site that offers a bunch of appartments for rent. Each of
> these rentals has a image gallery showing the look of that place.
> My models currently look like this:
>
> class Photo( models.Model ):
> name = models.ImageField( upload_to='rentals'
Hello,
I have a site that offers a bunch of appartments for rent. Each of
these rentals has a image gallery showing the look of that place.
My models currently look like this:
class Photo( models.Model ):
name = models.ImageField( upload_to='rentals' )
class Rental( model.Model ):
The relationship you've set up - one template can have many associated
documents, do I understand correctly? So every document will have a
reference to the Template that it's associated with. If that's the case,
you've only set it up for one template per Document. A default doesn't make
sense in
Im very new to this so please forgive if this is an obvious question:
How do you describe these relationships in a model in Django:
1)
UserProfile extends User. UserProfile has_a Address. Event has_a
Address.
Where Address has a common data-structure shared by Event and
UserProfile, but
24 matches
Mail list logo