Re: Specifying model relationship as string vs concrete model?

2019-04-07 Thread PASCUAL Eric
: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

Re: Specifying model relationship as string vs concrete model?

2019-04-06 Thread Mike Dewhirst
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

Specifying model relationship as string vs concrete model?

2019-04-06 Thread Mohit Solanki
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

Re: Django Model | Relationship question. Student->School Class

2015-12-22 Thread 'Tom Evans' via Django users
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

Django Model | Relationship question. Student->School Class

2015-12-21 Thread Pemby
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):

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-26 Thread shmengie
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 =

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread amarshall
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 >

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread Tim Chase
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

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread amarshall
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

Re: User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread Mario Gudelj
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"

User to Model relationship- implement a "like" feature on a Model

2014-08-25 Thread 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 =

Re: model relationship

2013-07-05 Thread Larry Martell
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

model relationship

2013-07-05 Thread Kakar Arunachal Service
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

Re: model relationship

2013-07-05 Thread Sandro Dutra
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

Re: Model Relationship Causing Error

2009-03-22 Thread Malcolm Tredinnick
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

Re: Model Relationship Causing Error

2009-03-22 Thread Super McFly
> 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

Re: Model Relationship Causing Error

2009-03-22 Thread Malcolm Tredinnick
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

Model Relationship Causing Error

2009-03-22 Thread Super McFly
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

"Simple" Model/relationship Question

2008-04-19 Thread Matt Franz
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

Re: model relationship filtering

2007-03-19 Thread [EMAIL PROTECTED]
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?

Re: model relationship filtering

2007-03-16 Thread Laurie Harper
[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'

model relationship filtering

2007-03-16 Thread [EMAIL PROTECTED]
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 ):

Re: Need advice for model relationship (onetoone inside?)

2007-02-02 Thread Joseph Heck
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

shared model relationship question

2006-10-03 Thread Benjamin Ward
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