Code Monkey home page Code Monkey logo

Comments (3)

gasman avatar gasman commented on August 18, 2024

Hi @sowinski,
Yes, support for unique constraints was added in the latest release - #84
(If this doesn't cover what you need, please open a new issue describing the missing functionality.)

from django-modelcluster.

sowinski avatar sowinski commented on August 18, 2024

HI @gasman,

thx for the fast response.

I've installed the latest version with pip (4.0) and it is still not working. Did I miss anything?
This is my ClusterableModel.

@register_snippet
class NavigationMenu(ClusterableModel):
    FOOTERCOL1 = 'FC1'
    FOOTERCOL2 = 'FC2'
    FOOTERCOL3 = 'FC3'
    FOOTERCOL4 = 'FC4'
    MENU_CHOICES = (
        (FOOTERCOL1, 'Footer culumn 1'),
        (FOOTERCOL2, 'Footer culumn 2'),
        (FOOTERCOL3, 'Footer culumn 3'),
        (FOOTERCOL4, 'Footer culumn 4'),
    )

    objects         = NavigationMenuManager()
    menu_location   = models.CharField(null=False, max_length=255, help_text="Template name (do not change)", choices=MENU_CHOICES)
    site            = models.ForeignKey(Site, blank=True, null=True)
    menu_name       = models.CharField(null=True, blank=True, max_length=255)

    unique_together = ("site", "menu_location")

from django-modelcluster.

gasman avatar gasman commented on August 18, 2024

@sowinski Your definition is incorrect: unique_together needs to be inside a Meta class, and should be a list of tuples.

@register_snippet
class NavigationMenu(models.Model):
    FOOTERCOL1 = 'FC1'
    # ...
    class Meta:
        unique_together = [
            ("site", "menu_location"),
        ]

from django-modelcluster.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.