Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with inlines in admin #150

Closed
VicDate opened this issue Oct 17, 2016 · 18 comments
Closed

Problem with inlines in admin #150

VicDate opened this issue Oct 17, 2016 · 18 comments

Comments

@VicDate
Copy link

VicDate commented Oct 17, 2016

Good day i have bug with "admin.StackedInline", don't work with add new line, use Django 1.10

@millin
Copy link
Contributor

millin commented Oct 17, 2016

Did you use latest version of django-smart-selects from PyPI?

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

django-smart-selects-1.2.3

@blag
Copy link
Collaborator

blag commented Oct 17, 2016

Please post the exact error from Django, the complete traceback, the problematic admin.py file, and anything else that could help us help you troubleshoot this issue.

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

No errors, does not js do it when i try add new StackedInline

@blag
Copy link
Collaborator

blag commented Oct 17, 2016

Does anything appear in your web browser's development console?

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

Nothing happens Ajax request does not work,when add new StackedInline or TabularInline

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

Yes,empty console

@blag
Copy link
Collaborator

blag commented Oct 17, 2016

Please post the relveant excerpts of the problematic admin.py and the corresponding models.py. It's impossible to troubleshoot without knowing exactly what you're trying to do.

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

models

class ProviderGames(models.Model):
    class Meta():
        db_table = 'providers'
        verbose_name = 'Provider'
        verbose_name_plural = 'Provider'

    def __unicode__(self):
        return format('%s' % self.title)

    title = models.CharField(max_length=255,verbose_name='Name Provider)

class Games(models.Model):
    class Meta():
        db_table = 'games'
        verbose_name = 'Games'
        verbose_name_plural = 'Games'

    def __unicode__(self):
        return format('%s' % self.title)


    title = models.CharField(max_length=255,verbose_name='Название Игры')
    photo = models.ImageField(upload_to='games_logo', verbose_name='Лого Игры')
    count_lines = models.CharField(max_length=255,verbose_name='Количество Линий')
    count_barabans = models.CharField(max_length=255,verbose_name='Количество Барабанов')
    rtp = models.CharField(max_length=255,verbose_name='RTP')
    provider = models.ForeignKey(ProviderGames,verbose_name='Провайдер')



class Casino(models.Model):
    class Meta():
        db_table = 'casino'
        verbose_name = 'Казино'
        verbose_name_plural = 'Казино'

    def __unicode__(self):
        return format('%s' % self.title)

    title = models.CharField(max_length=255,verbose_name='Название Казино')
    alias = models.SlugField(max_length=255)
    logo = models.ImageField(upload_to='casino_logo',verbose_name='Лого казино')
    background = models.ImageField(upload_to='casino_back',verbose_name='Подложка казино')
    e_wallet = models.CharField(max_length=255,verbose_name='E-wallet')
    e_partomone = models.CharField(max_length=255,verbose_name='Чеки')
    credit_cards = models.CharField(max_length=255,verbose_name='Credit/Debit карты')
    bank_send = models.CharField(max_length=255,verbose_name='Банковский перевод')
    pending_period = models.CharField(max_length=255,verbose_name='Период выплаты')
    raiting_total = models.IntegerField(verbose_name='Общий рейтинг')
    raiting_admin = models.DecimalField(max_length=2,max_digits=2, decimal_places=1, verbose_name='Рейтинг Администратора')
    external_href = models.CharField(max_length=255,verbose_name='Адрес казино')
    description = models.CharField(max_length=1000,verbose_name='Описание казино')
    description_bonus = models.CharField(max_length=1000, verbose_name='Описание бонусов')
    support = models.CharField(max_length=1,choices=SUPPORT,verbose_name='Поддержка')
    payment = models.ManyToManyField(CasinoPayment, verbose_name='Платежные системы')
    valuta = models.ManyToManyField(CasinoValuta, verbose_name='Валюта')
    langs = models.ManyToManyField(CasinoLang,verbose_name='Языки')




    def save(self, *args,**kwargs):
        tr = dict([(ord(a), ord(b)) for (a, b) in zip(*SYMBOLS)])
        title = self.title
        title_exists = Casino.objects.filter(alias=title.translate(tr)).exclude(pk=self.pk).count()
        if title_exists > 0:
            title = '%s_%s' % (self.title, title_exists)
        self.alias = slugify(title.translate(tr))
        super(Casino, self).save(*args, **kwargs)

class ProvidersAndGames(models.Model):
    class Meta():
        db_table = 'providers_and_games'
        verbose_name = 'P&G'
        verbose_name_plural = 'P&G'

    def __unicode__(self):
        return format('%s' % self.casino)

    providers = models.ForeignKey(ProviderGames)
    games = ChainedManyToManyField(Games,chained_field="providers",
            chained_model_field="provider")
    casino = models.ForeignKey(Casino)

admin

class AdminPandG(admin.StackedInline):
    model = ProvidersAndGames
    extra = 1


class AdminCasino(admin.ModelAdmin):
    inlines = [AdminPandG]

admin.site.register(Casino,AdminCasino)

Edit (by blag): Added syntax highlighting to code blocks

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

2016-10-17-134916_3840x1080_scrot

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

This is problem

@blag
Copy link
Collaborator

blag commented Oct 17, 2016

@millin: You mind taking a look into this?

@VicDate
Copy link
Author

VicDate commented Oct 17, 2016

I sent the problem clearly, when i try add new Line chained js not working, help me PLEASE

@blag
Copy link
Collaborator

blag commented Oct 17, 2016

@VicDate: It would be helpful if you could debug a big and test the results, but I'm curious if @millin can reproduce the issue. He's the author of PR #148 - the one that fixed admin inlines - so he would have the easiest time reproducing this, fixing it, and adding a test case for it.

I also don't have a lot of time today to delve into this, but I should later in the week. @VicDate: Bump this thread in a few days if we don't get back to you.

@millin
Copy link
Contributor

millin commented Oct 17, 2016

@VicDate I reproduced the issue.
My PR #148 solved issue only for ChainedForeignKey, not for ChainedManyToManyField.
I never used ChainedManyToManyField in my projects. So I need a time to understand how it works...
The issue is confirmed ☝️
Let's try to find solution together

@blag blag closed this as completed in f82d5b2 Oct 17, 2016
blag added a commit that referenced this issue Oct 17, 2016
Fix issue with Inlines M2M. Close #150
@blag
Copy link
Collaborator

blag commented Oct 17, 2016

Pushed update to PyPI. This should be fixed in version 1.2.4.

@VicDate Thank you for reporting this.

@millin Thanks for fixing this so quickly! ⭐️

@SalahAdDin
Copy link
Contributor

@blag When going you to release the new version?

@blag
Copy link
Collaborator

blag commented Mar 10, 2017

@SalahAdDin I'm a little confused by your question, I released version 1.2.4 five months ago in October as per my last comment.

Since then I've released a few more versions - we're up to version 1.3.4 now!

I did remove versions < 1.3.3 (including 1.2.4) from PyPI and GitHub because they contained an XSS flaw. Please upgrade to a secure and supported version as soon as possible. If you absolutely need to use the (insecure) code as it was in version 1.2.4 you can dig through the commit history and tell pip to use that commit. I absolutely am intentionally making it difficult for people to use the old, insecure releases.

If you would like to help out, perhaps by becoming a release manager for this project, feel free to email @digi604 and ask for PyPI access.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants