Re: Can't create editable foreign key field in Django admin: going to give up on django

2016-09-20 Thread Hanh Kieu
I tried using this, but it doesn't necessarily work or let me enter in two 
words that get turned into a translation. Could you elaborate on how inline 
would help?

On Monday, September 12, 2016 at 10:39:29 PM UTC-7, ludovic coues wrote:
>
> Have you looked at 
> https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#inlinemodeladmin-objects
>  
> ?
> It's still early morning here so I haven't to it with your specific use 
> case but the django tutorial use this feature to create a poll and its 
> response in the same form. 
>
> 2016-09-13 7:29 GMT+02:00 Luis Zárate :
>
>> See https://github.com/django-parler/django-parler
>>
>> 2016-09-12 23:02 GMT-06:00 Hanh Kieu :
>>
>>> Hey guys, I'm creating a translation app that allows you to translate 
>>> from one object to the other. My translation model has two foreign keys 
>>> that links to two words, and on the admin site I want the Admin to be able 
>>> to input two different words. The words they enter should be saved as 
>>> individual words, as well as a translation. However, it looks like this 
>>> isn't possible at all in Django. I've been trying so hard to read 
>>> documentation but I am struggling. My Models look like this:
>>>
>>> class Language(models.Model):
>>> language_text = models.CharField(max_length=200)
>>>
>>> def __str__(self):
>>> return self.language_text
>>>
>>>
>>> class Word(models.Model):
>>> language = models.ForeignKey(Language, on_delete=models.CASCADE)
>>> word_text = models.CharField(max_length=200)
>>>
>>> def __str__(self):
>>> return self.word_text
>>>
>>>
>>> class Translation(models.Model):
>>> #word1 belongs to one word
>>> word1 = models.OneToOneField(Word, on_delete=models.CASCADE, 
>>> related_name="Translation_word1")
>>> #word2 belongs to another word
>>> word2 = models.OneToOneField(Word, on_delete=models.CASCADE, 
>>> related_name="Translation_word2")
>>>
>>>
>>>
>>>
>>> I want the admin page for Translation to be able to take in two words and 
>>> two languages and create a translation from them (rather than individually 
>>> creating one word, then individually creating another word, then 
>>> indiviudally creating a translation)
>>>
>>> I've tried using TranslationForm(models.ModelForm), however when I submit 
>>> it gives me an error that there are NULL values for my models :C. Help I am 
>>> really lost and no one has been of help, I'm getting really frustrated with 
>>> this aspect of django.
>>>
>>> If someone could take time to actually understand my problem and help out 
>>> that would be great please :C
>>>
>>> -- 
>>> 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...@googlegroups.com .
>>> To post to this group, send email to django...@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/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%40googlegroups.com
>>>  
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> "La utopía sirve para caminar" Fernando Birri
>>
>>
>> -- 
>> 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...@googlegroups.com .
>> To post to this group, send email to django...@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/CAG%2B5VyNZOT2-Hp2i2yC_MO7R73P%2BBiDoP%3D%3DrX-aiy35THfxO%3Dw%40mail.gmail.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>

-- 
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/6d2aabd3-525b-4616-95e9-a209aa3b103e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't create editable foreign key field in Django admin: going to give up on django

2016-09-20 Thread Hanh Kieu
Thank You Mike, I understand what you mean and I've made the changes, but 
it doesn't help me with my original problem, unfortunately.

On Tuesday, September 13, 2016 at 12:53:51 AM UTC-7, Mike Dewhirst wrote:
>
> On 13/09/2016 4:06 PM, Hanh Kieu wrote: 
> > "So your Translation needs a FK to each of two different words. " 
> > What would this look like? 
>
> class Translation(models.Model): 
>  #word1 belongs to one word 
>  word1 = models.ForeignKey(Word, on_delete=models.CASCADE, 
> related_name="Translation_word1") 
>  #word2 belongs to another word 
>  word2 = models.ForeignKey(Word, on_delete=models.CASCADE, 
> related_name="Translation_word2") 
>  def __str__(self): 
>  return "{0} - {1}".format(word1.language, word2.language) 
>
>
> > 
> > On Monday, September 12, 2016 at 10:42:10 PM UTC-7, Mike Dewhirst wrote: 
> > 
> > On 13/09/2016 3:02 PM, Hanh Kieu wrote: 
> > > Hey guys, I'm creating a translation app that allows you to 
> > translate 
> > > from one object to the other. My translation model has two foreign 
> > > keys that links to two words, and on the admin site I want the 
> > Admin 
> > > to be able to input two different words. The words they enter 
> > should 
> > > be saved as individual words, as well as a translation. However, 
> it 
> > > looks like this isn't possible at all in Django. I've been 
> > trying so 
> > > hard to read documentation but I am struggling. My Models look 
> > like this: 
> > > 
> > > class Language(models.Model): 
> > > Â  Â  Â language_text = models.CharField(max_length=200) 
> > > 
> > > Â  Â  Â def __str__(self): 
> > > Â  Â  Â  Â  Â return self.language_text 
> > > 
> > > 
> > > class Word(models.Model): 
> > > Â  Â  Â language = 
> > models.ForeignKey(Language,on_delete=models.CASCADE) 
> > > Â  Â  Â word_text = models.CharField(max_length=200) 
> > > 
> > > Â  Â  Â def __str__(self): 
> > > Â  Â  Â  Â  Â return self.word_text 
> > > 
> > > 
> > > class Translation(models.Model): 
> > > Â  Â  Â #word1 belongs to one word word1 = 
> > 
> models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word1")
>  
>
> > 
> > > Â  Â  Â #word2 belongs to another word word2 = 
> > 
> models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word2")
>  
>
> > 
> > 
> > Word has a FK to Language so a word exists in a language and 
> > presumably 
> > language_text will contain the name of the language like Ruby or 
> > French etc. 
> > 
> > So for that word to exist in another language, another word in that 
> > other language must have a FK to that other language. So if you have 
> > enough words in enough languages it would certainly be useful to 
> > connect 
> > them via a translation record. 
> > 
> > But perhaps 1:1 is not what you want? 
> > 
> > Maybe a particular word can be translated into two or three 
> > languages? 
> > 
> > If so, you need an intermediate table which connects any one word 
> > with 
> > many other words which belong in different languages. Sometimes 
> > too, the 
> > same word is in more than one language with the same meaning. 
> > 
> > One translation record needs to make a single connection between 
> > any two 
> > word records. So your Translation needs a FK to each of two 
> > different words. 
> > 
> > Because you probably want to enter words for which you don't have 
> the 
> > translation immediately to hand, it might be worthwhile permitting 
> > Null=True and blank=True. 
> > 
> > Hth 
> > 
> > > I want the admin page for Translation to be able to take in two 
> > words 
> > > and two languages and create a translation from them (rather than 
> > > individually creating one word, then individually creating another 
> > > word, then indiviudally creating a translation) 
> > > 
> > > I've tried using TranslationForm(models.ModelForm), however when I 
> > > submit it gives me an error that there are NULL values for my 
> > models 
> > > :C. Help I am really lost and no one has been of help, I'm getting 
> > > really frustrated with this aspect of django. 
> > > 
> > > If someone could take time to actually understand my problem and 
> > help 
> > > out that would be great please :C 
> > > 
> > > -- 
> > > 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...@googlegroups.com  
> > >  >. 
> > > To post to this group, send email to django...@googlegroups.com 
> >  
> > > . 

Re: Can't create editable foreign key field in Django admin: going to give up on django

2016-09-13 Thread Mike Dewhirst

On 13/09/2016 4:06 PM, Hanh Kieu wrote:

"So your Translation needs a FK to each of two different words. "
What would this look like?


class Translation(models.Model):
#word1 belongs to one word
word1 = models.ForeignKey(Word, on_delete=models.CASCADE, 
related_name="Translation_word1")

#word2 belongs to another word
word2 = models.ForeignKey(Word, on_delete=models.CASCADE, 
related_name="Translation_word2")

def __str__(self):
return "{0} - {1}".format(word1.language, word2.language)




On Monday, September 12, 2016 at 10:42:10 PM UTC-7, Mike Dewhirst wrote:

On 13/09/2016 3:02 PM, Hanh Kieu wrote:
> Hey guys, I'm creating a translation app that allows you to
translate
> from one object to the other. My translation model has two foreign
> keys that links to two words, and on the admin site I want the
Admin
> to be able to input two different words. The words they enter
should
> be saved as individual words, as well as a translation. However, it
> looks like this isn't possible at all in Django. I've been
trying so
> hard to read documentation but I am struggling. My Models look
like this:
>
> class Language(models.Model):
> Â  Â  Â language_text = models.CharField(max_length=200)
>
> Â  Â  Â def __str__(self):
> Â  Â  Â  Â  Â return self.language_text
>
>
> class Word(models.Model):
> Â  Â  Â language =
models.ForeignKey(Language,on_delete=models.CASCADE)
> Â  Â  Â word_text = models.CharField(max_length=200)
>
> Â  Â  Â def __str__(self):
> Â  Â  Â  Â  Â return self.word_text
>
>
> class Translation(models.Model):
> Â  Â  Â #word1 belongs to one word word1 =

models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word1")

> Â  Â  Â #word2 belongs to another word word2 =

models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word2")


Word has a FK to Language so a word exists in a language and
presumably
language_text will contain the name of the language like Ruby or
French etc.

So for that word to exist in another language, another word in that
other language must have a FK to that other language. So if you have
enough words in enough languages it would certainly be useful to
connect
them via a translation record.

But perhaps 1:1 is not what you want?

Maybe a particular word can be translated into two or three
languages?

If so, you need an intermediate table which connects any one word
with
many other words which belong in different languages. Sometimes
too, the
same word is in more than one language with the same meaning.

One translation record needs to make a single connection between
any two
word records. So your Translation needs a FK to each of two
different words.

Because you probably want to enter words for which you don't have the
translation immediately to hand, it might be worthwhile permitting
Null=True and blank=True.

Hth

> I want the admin page for Translation to be able to take in two
words
> and two languages and create a translation from them (rather than
> individually creating one word, then individually creating another
> word, then indiviudally creating a translation)
>
> I've tried using TranslationForm(models.ModelForm), however when I
> submit it gives me an error that there are NULL values for my
models
> :C. Help I am really lost and no one has been of help, I'm getting
> really frustrated with this aspect of django.
>
> If someone could take time to actually understand my problem and
help
> out that would be great please :C
>
> --
> 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...@googlegroups.com 
> .
> To post to this group, send email to django...@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/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%40googlegroups.com



>

>.

> For more options, visit https://groups.google.com/d/optout

Re: Can't create editable foreign key field in Django admin: going to give up on django

2016-09-13 Thread Hanh Kieu
"So your Translation needs a FK to each of two different words. "
What would this look like?

On Monday, September 12, 2016 at 10:42:10 PM UTC-7, Mike Dewhirst wrote:
>
> On 13/09/2016 3:02 PM, Hanh Kieu wrote: 
> > Hey guys, I'm creating a translation app that allows you to translate 
> > from one object to the other. My translation model has two foreign 
> > keys that links to two words, and on the admin site I want the Admin 
> > to be able to input two different words. The words they enter should 
> > be saved as individual words, as well as a translation. However, it 
> > looks like this isn't possible at all in Django. I've been trying so 
> > hard to read documentation but I am struggling. My Models look like 
> this: 
> > 
> > class Language(models.Model): 
> >  language_text = models.CharField(max_length=200) 
> > 
> >  def __str__(self): 
> >  return self.language_text 
> > 
> > 
> > class Word(models.Model): 
> >  language = models.ForeignKey(Language,on_delete=models.CASCADE) 
> >  word_text = models.CharField(max_length=200) 
> > 
> >  def __str__(self): 
> >  return self.word_text 
> > 
> > 
> > class Translation(models.Model): 
> >  #word1 belongs to one word word1 = 
> models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word1")
>  
>
> >  #word2 belongs to another word word2 = 
> models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word2")
>  
>
>
> Word has a FK to Language so a word exists in a language and presumably 
> language_text will contain the name of the language like Ruby or French 
> etc. 
>
> So for that word to exist in another language, another word in that 
> other language must have a FK to that other language. So if you have 
> enough words in enough languages it would certainly be useful to connect 
> them via a translation record. 
>
> But perhaps 1:1 is not what you want? 
>
> Maybe a particular word can be translated into two or three languages? 
>
> If so, you need an intermediate table which connects any one word with 
> many other words which belong in different languages. Sometimes too, the 
> same word is in more than one language with the same meaning. 
>
> One translation record needs to make a single connection between any two 
> word records. So your Translation needs a FK to each of two different 
> words. 
>
> Because you probably want to enter words for which you don't have the 
> translation immediately to hand, it might be worthwhile permitting 
> Null=True and blank=True. 
>
> Hth 
>
> > I want the admin page for Translation to be able to take in two words 
> > and two languages and create a translation from them (rather than 
> > individually creating one word, then individually creating another 
> > word, then indiviudally creating a translation) 
> > 
> > I've tried using TranslationForm(models.ModelForm), however when I 
> > submit it gives me an error that there are NULL values for my models 
> > :C. Help I am really lost and no one has been of help, I'm getting 
> > really frustrated with this aspect of django. 
> > 
> > If someone could take time to actually understand my problem and help 
> > out that would be great please :C 
> > 
> > -- 
> > 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...@googlegroups.com  
> > . 
> > To post to this group, send email to django...@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/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%40googlegroups.com
>  
> > <
> https://groups.google.com/d/msgid/django-users/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%40googlegroups.com?utm_medium=email_source=footer>.
>  
>
> > 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/53110a43-f7e7-449c-9e74-2606a2d71854%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't create editable foreign key field in Django admin: going to give up on django

2016-09-12 Thread Mike Dewhirst

On 13/09/2016 3:02 PM, Hanh Kieu wrote:
Hey guys, I'm creating a translation app that allows you to translate 
from one object to the other. My translation model has two foreign 
keys that links to two words, and on the admin site I want the Admin 
to be able to input two different words. The words they enter should 
be saved as individual words, as well as a translation. However, it 
looks like this isn't possible at all in Django. I've been trying so 
hard to read documentation but I am struggling. My Models look like this:


class Language(models.Model):
 language_text = models.CharField(max_length=200)

 def __str__(self):
 return self.language_text


class Word(models.Model):
 language = models.ForeignKey(Language,on_delete=models.CASCADE)
 word_text = models.CharField(max_length=200)

 def __str__(self):
 return self.word_text


class Translation(models.Model):
 #word1 belongs to one word word1 = 
models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word1")
 #word2 belongs to another word word2 = 
models.OneToOneField(Word,on_delete=models.CASCADE,related_name="Translation_word2")


Word has a FK to Language so a word exists in a language and presumably 
language_text will contain the name of the language like Ruby or French etc.


So for that word to exist in another language, another word in that 
other language must have a FK to that other language. So if you have 
enough words in enough languages it would certainly be useful to connect 
them via a translation record.


But perhaps 1:1 is not what you want?

Maybe a particular word can be translated into two or three languages?

If so, you need an intermediate table which connects any one word with 
many other words which belong in different languages. Sometimes too, the 
same word is in more than one language with the same meaning.


One translation record needs to make a single connection between any two 
word records. So your Translation needs a FK to each of two different words.


Because you probably want to enter words for which you don't have the 
translation immediately to hand, it might be worthwhile permitting 
Null=True and blank=True.


Hth

I want the admin page for Translation to be able to take in two words 
and two languages and create a translation from them (rather than 
individually creating one word, then individually creating another 
word, then indiviudally creating a translation)


I've tried using TranslationForm(models.ModelForm), however when I 
submit it gives me an error that there are NULL values for my models 
:C. Help I am really lost and no one has been of help, I'm getting 
really frustrated with this aspect of django.


If someone could take time to actually understand my problem and help 
out that would be great please :C


--
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/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%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/1c91bf93-9a58-2c1a-bfd6-b88e237a58af%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


Re: Can't create editable foreign key field in Django admin: going to give up on django

2016-09-12 Thread ludovic coues
Have you looked at
https://docs.djangoproject.com/en/1.10/ref/contrib/admin/#inlinemodeladmin-objects
?
It's still early morning here so I haven't to it with your specific use
case but the django tutorial use this feature to create a poll and its
response in the same form.

2016-09-13 7:29 GMT+02:00 Luis Zárate :

> See https://github.com/django-parler/django-parler
>
> 2016-09-12 23:02 GMT-06:00 Hanh Kieu :
>
>> Hey guys, I'm creating a translation app that allows you to translate
>> from one object to the other. My translation model has two foreign keys
>> that links to two words, and on the admin site I want the Admin to be able
>> to input two different words. The words they enter should be saved as
>> individual words, as well as a translation. However, it looks like this
>> isn't possible at all in Django. I've been trying so hard to read
>> documentation but I am struggling. My Models look like this:
>>
>> class Language(models.Model):
>> language_text = models.CharField(max_length=200)
>>
>> def __str__(self):
>> return self.language_text
>>
>>
>> class Word(models.Model):
>> language = models.ForeignKey(Language, on_delete=models.CASCADE)
>> word_text = models.CharField(max_length=200)
>>
>> def __str__(self):
>> return self.word_text
>>
>>
>> class Translation(models.Model):
>> #word1 belongs to one word
>> word1 = models.OneToOneField(Word, on_delete=models.CASCADE, 
>> related_name="Translation_word1")
>> #word2 belongs to another word
>> word2 = models.OneToOneField(Word, on_delete=models.CASCADE, 
>> related_name="Translation_word2")
>>
>>
>>
>>
>> I want the admin page for Translation to be able to take in two words and 
>> two languages and create a translation from them (rather than individually 
>> creating one word, then individually creating another word, then 
>> indiviudally creating a translation)
>>
>> I've tried using TranslationForm(models.ModelForm), however when I submit it 
>> gives me an error that there are NULL values for my models :C. Help I am 
>> really lost and no one has been of help, I'm getting really frustrated with 
>> this aspect of django.
>>
>> If someone could take time to actually understand my problem and help out 
>> that would be great please :C
>>
>> --
>> 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/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/CAG%2B5VyNZOT2-Hp2i2yC_MO7R73P%
> 2BBiDoP%3D%3DrX-aiy35THfxO%3Dw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTbx4vO0eNC2pWfowVOZ%2BZJmYqqLT_d9ROhejqAitr90%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Can't create editable foreign key field in Django admin: going to give up on django

2016-09-12 Thread Luis Zárate
See https://github.com/django-parler/django-parler

2016-09-12 23:02 GMT-06:00 Hanh Kieu :

> Hey guys, I'm creating a translation app that allows you to translate from
> one object to the other. My translation model has two foreign keys that
> links to two words, and on the admin site I want the Admin to be able to
> input two different words. The words they enter should be saved as
> individual words, as well as a translation. However, it looks like this
> isn't possible at all in Django. I've been trying so hard to read
> documentation but I am struggling. My Models look like this:
>
> class Language(models.Model):
> language_text = models.CharField(max_length=200)
>
> def __str__(self):
> return self.language_text
>
>
> class Word(models.Model):
> language = models.ForeignKey(Language, on_delete=models.CASCADE)
> word_text = models.CharField(max_length=200)
>
> def __str__(self):
> return self.word_text
>
>
> class Translation(models.Model):
> #word1 belongs to one word
> word1 = models.OneToOneField(Word, on_delete=models.CASCADE, 
> related_name="Translation_word1")
> #word2 belongs to another word
> word2 = models.OneToOneField(Word, on_delete=models.CASCADE, 
> related_name="Translation_word2")
>
>
>
>
> I want the admin page for Translation to be able to take in two words and two 
> languages and create a translation from them (rather than individually 
> creating one word, then individually creating another word, then indiviudally 
> creating a translation)
>
> I've tried using TranslationForm(models.ModelForm), however when I submit it 
> gives me an error that there are NULL values for my models :C. Help I am 
> really lost and no one has been of help, I'm getting really frustrated with 
> this aspect of django.
>
> If someone could take time to actually understand my problem and help out 
> that would be great please :C
>
> --
> 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/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyNZOT2-Hp2i2yC_MO7R73P%2BBiDoP%3D%3DrX-aiy35THfxO%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Can't create editable foreign key field in Django admin: going to give up on django

2016-09-12 Thread Hanh Kieu
Hey guys, I'm creating a translation app that allows you to translate from 
one object to the other. My translation model has two foreign keys that 
links to two words, and on the admin site I want the Admin to be able to 
input two different words. The words they enter should be saved as 
individual words, as well as a translation. However, it looks like this 
isn't possible at all in Django. I've been trying so hard to read 
documentation but I am struggling. My Models look like this:

class Language(models.Model):
language_text = models.CharField(max_length=200)

def __str__(self):
return self.language_text


class Word(models.Model):
language = models.ForeignKey(Language, on_delete=models.CASCADE)
word_text = models.CharField(max_length=200)

def __str__(self):
return self.word_text


class Translation(models.Model):
#word1 belongs to one word
word1 = models.OneToOneField(Word, on_delete=models.CASCADE, 
related_name="Translation_word1")
#word2 belongs to another word
word2 = models.OneToOneField(Word, on_delete=models.CASCADE, 
related_name="Translation_word2")




I want the admin page for Translation to be able to take in two words and two 
languages and create a translation from them (rather than individually creating 
one word, then individually creating another word, then indiviudally creating a 
translation)

I've tried using TranslationForm(models.ModelForm), however when I submit it 
gives me an error that there are NULL values for my models :C. Help I am really 
lost and no one has been of help, I'm getting really frustrated with this 
aspect of django.

If someone could take time to actually understand my problem and help out that 
would be great please :C

-- 
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/9ab72b11-b7b3-4c1a-bf26-3ed4befb212f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.