Re: How to do a generic field in an app.

2016-09-20 Thread Jonty Needham
So now, I'd like to do the following:

class AppConfig(models.Model):
my_content_type = ForeighnKey(ContentType)

wrote:

> Awesome -- thanks!
>
> On Mon, Sep 19, 2016 at 6:48 PM, Tim Graham  wrote:
>
>> Do you know about https://docs.djangoproject.com
>> /en/stable/ref/contrib/contenttypes/#generic-relations ?
>>
>>
>> On Monday, September 19, 2016 at 12:30:01 PM UTC-4, Jonty Needham wrote:
>>>
>>> I want to have a model that has a foreignkey to a model from another
>>> app. The app can be one of many.
>>>
>>> So far I've come up with a two field solution with:
>>>
>>> model_type = ForeignKey(ContentType)
>>> pk_field = PositiveIntegerField()
>>>
>>>
>>> with an appropriate getter. Is there a better way to do this? It feels
>>> like this has already been solved in a known "good" way.
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/a81b5dee-3a80-4a05-a3c1-d82b92d0395a%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANOQRbwMSakFjmT1UnQsU7ZKoQKWQu1FiYJA4p2P%2Bq494iNORQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to do a generic field in an app.

2016-09-20 Thread Jonty Needham
Awesome -- thanks!

On Mon, Sep 19, 2016 at 6:48 PM, Tim Graham  wrote:

> Do you know about https://docs.djangoproject.com/en/stable/ref/contrib/
> contenttypes/#generic-relations ?
>
>
> On Monday, September 19, 2016 at 12:30:01 PM UTC-4, Jonty Needham wrote:
>>
>> I want to have a model that has a foreignkey to a model from another app.
>> The app can be one of many.
>>
>> So far I've come up with a two field solution with:
>>
>> model_type = ForeignKey(ContentType)
>> pk_field = PositiveIntegerField()
>>
>>
>> with an appropriate getter. Is there a better way to do this? It feels
>> like this has already been solved in a known "good" way.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/a81b5dee-3a80-4a05-a3c1-d82b92d0395a%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANOQRbzBGw2-04bGirRTgbDUCCHt%2BS0cN1X9V2kt%2BHX9V%2BdR9w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to do a generic field in an app.

2016-09-19 Thread Tim Graham
Do you know about 
https://docs.djangoproject.com/en/stable/ref/contrib/contenttypes/#generic-relations
 
?

On Monday, September 19, 2016 at 12:30:01 PM UTC-4, Jonty Needham wrote:
>
> I want to have a model that has a foreignkey to a model from another app. 
> The app can be one of many.
>
> So far I've come up with a two field solution with:
>
> model_type = ForeignKey(ContentType)
> pk_field = PositiveIntegerField()
>
>
> with an appropriate getter. Is there a better way to do this? It feels 
> like this has already been solved in a known "good" way.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a81b5dee-3a80-4a05-a3c1-d82b92d0395a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.