question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using wrong model?

See original GitHub issue

Hi, please tell me what I’m doing wrong as I’m trying to use this awesome library in one of my project and have issue. I’m running on Django 1.10 with django-rest-framework 3.5 (Python 3.5), and I have something like this:

class Company(models.Model):
    name = models.CharField(max_length=255)

class Category(models.Model):
    company = models.ForeignKey(Company)

class Project(models.Model):
    company = models.ForeignKey(Company)
    category = ChainedForeignKey(
        to=Category,
        chained_field="company",
        chained_model_field="company"
    )

This is something I want to use on Admin Form, in Project view.

The problem is, that Category shows all Projects, instead of Categories filtered by Companies. As I’ve took a look, there is because widget get model name from meta which is Project.

Is there any possiblity to control this? Or did I just misused this somehow?

Thanks in advance!

The admin part is:

@register(Project)
class ProjectAdmin(ModelAdmin):
    fieldsets = (
        (None, {
            'fields': (
                ('company',),
                ('category',),
            )
        }),

    )

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
scream4ikcommented, Oct 27, 2016

Same problem with latest version (1.2.5 from pypi). With 1.2.4 all fine

0reactions
adam-tokarskicommented, Oct 28, 2016

Seems to be working now! Thanks! I’ve used the newest version from PyPI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Consequence of Selecting wrong model? - Cross Validated
What is the consequence of using an ordinary linear regression model while a linear mixed effect model is appropriate? Will the estimates and ......
Read more >
How to Choose the Wrong Model - Biostatistics
What are the 10 best ways to choose the wrong model? ... Statistical inference: use data and the statistical model to make statements...
Read more >
Passing wrong model into partial - razor - Stack Overflow
I am building my first web app with .net core razor pages. I am trying to move my menu to be partial, so...
Read more >
Fitting the wrong model - Jorge Cimentada
Fitting the wrong model: suppose you have 100 data points that arose from the following model: y = 3 + 0.1×1 + 0.5×2...
Read more >
Using the Wrong Model Can Lead to Unsupported ...
Granted that interferences are difficult to model, but a survey has shown that they are a significant source of clinician complaints about ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found