Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango error with ForeignKey reference
    text
    copied!<p>I have a question about a ForeignKey reference problem with django.</p> <p>This is a part of my code :</p> <p>App ticketsTrader</p> <pre><code>class TicketsTrader(models.Model): seller = models.ForeignKey(User, related_name='ticketsTrader_seller') buyer = models.ForeignKey(User, related_name='ticketsTrader_buyer') inscription = models.ForeignKey(Inscription) transactionCode = models.CharField(max_length=30,blank=False,null=False) ... </code></pre> <p>App inscription</p> <pre><code>class Event(models.Model): title = models.CharField(max_length=75) description = models.TextField() ... class Inscription(models.Model): event = models.ForeignKey(Event) packs = models.ManyToManyField(PackChoise) user = models.ForeignKey(User) ... def __unicode__(self): return self.event.__unicode__() + u': ' + self.user.__unicode__() def inscriptionKey(self): return str(self.pk) + '_' + str(self.valkey) </code></pre> <p>But when I try to acces to the "Add Ticket Trader" interface in my Grapelli admin, I get an error message :</p> <blockquote> <p>User matching query does not exist.</p> <p>Python27\lib\site-packages\django\db\models\query.py in get, line 366</p> <p>In template \grappelli\templates\admin\includes\fieldset.html, error at line 19</p> </blockquote> <p>What I want to get is : in the "inscription" column of my ticketTrader table get the value of the unique id (pk) of my "Inscription" table.</p> <p>Or the value of the "inscriptionKey" but I don't think it's possible.</p> <p>Django Version:1.4 / Python Version: 2.7.3 / South last version</p> <p>Thanks for your help :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload