by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Fabian
    @fabiand93
    is there a way I can have a models.py with multiple classes but make migrations of each class on different databases?
    not as a replica
    but using one class on an aws db, another one on azure... and when running migrations only using the migrate element?
    Pierre Sigwalt
    @pierresigwalt
    is there is a way to use the view cache but for Json parameters?
    matrixbot
    @matrixbot

    Routhinator > <@gitter_nitish30:matrix.org> how can we integrate react with Django ...any idea...please

    Lookup Django Rest Framework.

    Sandip Nath
    @wandysandy_twitter

    I have defined a user model inheriting AbstractUser from django.auth.models. How can I refer to each individual fields of that customized user model? Say if I want to refer to date of birth of the customised user what should I write? I need to show the user prifile, so in show_profile.html file, I wrote :

    first name = {{ settings.AUTH_USER_MODEL.first_name }}
    date 0f birth = {{ settings.AUTH_USER_MODEL.dob }}

    But it didn't work. Any idea?

    matrixbot
    @matrixbot

    Routhinator > <@gitter_wandysandy_twitter:matrix.org> I have defined a user model inheriting AbstractUser from django.auth.models. How can I refer to each individual fields of that customized user model? Say if I want to refer to date of birth of the customised user what should I write? I need to show the user prifile, so in show_profile.html file, I wrote :

    first name = {{ settings.AUTH_USER_MODEL.first_name }}
    date 0f birth = {{ settings.AUTH_USER_MODEL.dob }}

    But it didn't work. Any idea?

    Sandip Nath (Gitter): settings.AUTH_USER_MODEL is a class reference, not an object reference. You need to use a query to get the user instance for the profile you are trying to display by doing a db lookup for the id of the User Object using settings.AUTH_USER_MODEL as your class : https://docs.djangoproject.com/en/3.0/topics/db/queries/

    djangoReactGuy
    @SanskarSans
    How would you design the table if you have more than 2 types of user? For example let's say its a travel app. The user in a travel app can be superadmin, guide, traveller, editor
    Sumanth Ratna
    @sumanthratna
    I'm using path('accounts/', include('django.contrib.auth.urls')). are there any out-of-the-box templates I can use for development? I'll add styling later
    Sumanth Ratna
    @sumanthratna
    they don't even have to be official—if you have your own go-to auth templates, I'd love to see them :)
    Sumanth Ratna
    @sumanthratna
    MinHyeokBae
    @bmh8993

    hi, developers
    If I do bulk_create in ListSerialzer on DRF, the following issues occur:
    encode/django-rest-framework#1116

    how do I resolve?

    bulk_create returns
    [
        {
            "id": null,
            "start_date": "2016-08-24",
            "amount": "3295000",
            "unpaid_amount": "2295000",
            "interest_rate": "2.5",
            "loan_account": "2016-2-02-01-6861096",
            "deferment_date": "9999-12-31",
            "due_date": "9999-12-31",
            "created_at": "2020-06-17 06:30",
            "updated_at": "2020-06-17 06:30",
            "is_planned": false,
            "loaner": 1
        },
        {
            "id": null,
            "start_date": "2016-08-24",
            "amount": "3295000",
            "unpaid_amount": "2295000",
            "interest_rate": "2.5",
            "loan_account": "2016-2-02-01-6861097",
            "deferment_date": "9999-12-31",
            "due_date": "9999-12-31",
            "created_at": "2020-06-17 06:30",
            "updated_at": "2020-06-17 06:30",
            "is_planned": false,
            "loaner": 1
        }
    ]
    id is null
    I use cumstom ListSerializer
    class LoanListSerializer(serializers.ListSerializer):
        def create(self, validated_data):
            loan_list = [Loan(**data) for data in validated_data if "is_existed" not in data]
            return Loan.objects.bulk_create(loan_list)
    Ariel Torti
    @maks500
    What database are you using ?
    You can't always access the ids of the objects created with bulk_create, it's database dependent
    MinHyeokBae
    @bmh8993
    I use django 2.2 version, and mysql.
    Is it problem?
    Ariel Torti
    @maks500
    Getting the ids on bulk_create is only supported on postgres
    If you need to have the ids for further processing I would recommend using a loop instead of bulk_create
    Bear in mind it does come with some performance penalties
    MinHyeokBae
    @bmh8993
    Thank you for your kindness
    Dan Black
    @dyspop
    Hi. I’ve been working on a django project. I used django cms and I am getting to the point of figuring out how to deploy it. Well. Before that choosing a database. I see that I’m supposed to choose something other than what django sets you up with. I’m looking at doing this on divio (or does this community recommend something better?) or pythonanywhere. But I really don’t have any idea what database type I should use. I’d err on Postgres but... I’m kinda just guessing
    Sumanth Ratna
    @sumanthratna
    @dyspop I would go with postgres—after mysql, I would say it's the most widely supported DB by django
    Dan Black
    @dyspop
    That’s what I started working with. Had some roadblocks but I think I can get through them. Thanks!!
    mushiri
    @mushiri
    Hey guys, is anyone here atm??
    I am new to Django, and I am still learning. I have an idea of a website that I want to achieve, but I just don't know which approach to take
    could anyone help me please :)
    matrixbot
    @matrixbot
    azwn hello sure
    sahil-developer-88
    @sahil-developer-88

    Hi

    If i want to get timezone (like asia/kolkata) based on user location, how can i get it using python code?

    Oleksandr Dubovyk
    @struy
    Hi, Why you need to use timezone
    Oleksandr Dubovyk
    @struy
    {% get_current_timezone as TIME_ZONE %}
    Rob
    @borriej

    hi guys :wave:

    I've created a scrum agile retrospective app for your team!

    https://retros.work

    hope this can help your team during the corona. It support remote sessions with socket.

    djangoReactGuy
    @SanskarSans

    I was looking on customizing admin where i found tabularinline model which allow us to edit on the same page. But i got confused as my tables are reference in multiple places. I could not understand which model should i make tabular inline.

    Here is my model

    class ProductType(ModelWithMetadata):
        name = models.CharField(max_length=150, help_text="type of product. ex - accessories, apparel")
        slug = models.SlugField(max_length=150, unique=True)
        is_shipping_required = models.BooleanField(default=True)
    
        class Meta:
            ordering = ("slug",)
            app_label="products"
    
    class Category(MPTTModel, ModelWithMetadata):
        name = models.CharField(max_length=128)
        slug = models.SlugField(max_length=128)
        description = models.TextField(blank=True)
        parent = models.ForeignKey(
            "self", null=True, blank=True, related_name="children", on_delete=models.CASCADE
        )
    
        objects = models.Manager()
        tree = TreeManager()
    
        class Meta:
            verbose_name = "Category"
            verbose_name_plural = "Categories"
    
        def __str__(self):
            return self.name
    
    
    class Product(ModelWithMetadata, PublishableModel):
        product_type = models.ForeignKey(
            ProductType, related_name="products", on_delete=models.CASCADE
        )
        name = models.CharField(max_length=128)
        slug = models.SlugField()
        category = models.ForeignKey(
            Category,
            related_name="products",
            on_delete=models.SET_NULL,
            null=True,
            blank=True,
        )
        isAvailable = models.BooleanField(default=True)
        isDiscount = models.BooleanField(default=False)
        charge_taxes = models.BooleanField(default=False)
        updated_at = models.DateTimeField(auto_now=True, null=True)
    
        class Meta:
            verbose_name = "product"
            verbose_name_plural = "products"
            ordering = ("name",)
            constraints = [
                models.UniqueConstraint(
                    fields=["article_number", "slug"], name="unique article number and slug")
            ]
    
    class ProductVariant(ModelWithMetadata):
        sku = models.CharField(max_length=255, unique=True)
        name = models.CharField(max_length=255, blank=True)
        currency = models.CharField(
            max_length=settings.DEFAULT_CURRENCY_CODE_LENGTH,
            default=settings.DEFAULT_CURRENCY,
            blank=True,
            null=True,
        )
        price_override_amount = models.DecimalField(
            max_digits=settings.DEFAULT_MAX_DIGITS,
            decimal_places=settings.DEFAULT_DECIMAL_PLACES,
            blank=True,
            null=True,
        )
        product = models.ForeignKey(
            Product, related_name="variants", on_delete=models.CASCADE
        )
        images = models.ManyToManyField("ProductImage", through="VariantImage")
        track_inventory = models.BooleanField(default=True)
    class BaseAssignedAttribute(models.Model):
    
        assignment = None
        values = models.ManyToManyField("AttributeValue")
    
    
    class AttributeValue(models.Model):
    
        name = models.CharField(max_length=250)
        value = models.CharField(max_length=100, blank=True, default="")
        slug = models.SlugField(max_length=255)
        attribute = models.ForeignKey(
            "Attribute", related_name="values", on_delete=models.CASCADE
        )
    
    
    class AssignedProductAttribute(BaseAssignedAttribute):
        """Associate a product type attribute and selected values to a given product."""
    
        product = models.ForeignKey(
            Product, related_name="attributes", on_delete=models.CASCADE
        )
        assignment = models.ForeignKey(
            "ProductAttribute", on_delete=models.CASCADE, related_name="productassignments"
        )
    
        class Meta:
            unique_together = (("product", "assignment"),)
    
    
    class AssignedVariantAttribute(BaseAssignedAttribute):
        """Associate a product type attribute and selected values to a given variant."""
    
        variant = models.ForeignKey(
            ProductVariant, related_name="attributes", on_delete=models.CASCADE
        )
        assignment = models.ForeignKey(
            "AttributeVariant", on_delete=models.CASCADE, related_name="variantassignments"
        )
    
        class Meta:
            unique_together = (("variant", "assignment"),)
    
    
    class AttributeVariant(models.Model):
        attribute = models.ForeignKey(
            "Attribute", related_name="attributevariant", on_delete=models.CASCADE
        )
        product_type = models.ForeignKey(
            ProductType, related_name="attributevariant", on_delete=models.CASCADE
        )
        assigned_variants = models.ManyToManyField(
            ProductVariant,
            blank=True,
            through=AssignedVariantAttribute,
            through_fields=("assignment", "variant"),
            related_name="attributesrelated",
        )
    
    
    class Attribute(models.Model):
        name = models.CharField(max_length=30, unique=True)
        slug = models.SlugField(max_length=250, unique=True)
        product_types = models.ManyToManyField(
            ProductType,
            blank=True,
            related_name="product_attributes",
            through="ProductAttribute",
            through_fields=("attribute", "product_type"),
        )
        product_variant_types = models.ManyToManyField(
            ProductType,
            blank=True,
            related_name="variant_attributes",
            through=AttributeVariant,
            through_fields=("attribute", "product_type"),
        )
    
    
    class ProductAttribute(models.Model):
        attribute = models.ForeignKey(
            "Attribute", related_name="attributeproduct", on_delete=models.CASCADE
        )
        product_type = models.ForeignKey(
            ProductType, related_name="attributeproduct", on_delete=models.CASCADE
        )
        assigned_products = models.ManyToManyField(
            Product,
            blank=True,
            through=AssignedProductAttribute,
            through_fields=("assignment", "product"),
            related_name="attributesrelated",
        )

    I am confused on the tables AttributeValue, AssignedProductAttribute, AssignedVariantAttribute, AttributeVariant, Attribute and ProductAttribute. Attribute is related to ProductAttribute and is also related to AttributeVariant and AttributeValue. Similarly, in the case of variant.

    I could not figure out which table should be inline and where should i reference that inlined table. Because of various relationship, i am not sure of those things.

    Apophus
    @Apophus
    Anyone here using django-audit-log?
    How can i get rid of this error without touching the ste-packages code? TypeError: __init__() missing 1 required positional argument: 'on_delete
    It's thrown by "/home/brian/environments/sokoenv/lib/python3.8/site-packages/audit_log/models/__init__.py", line 5, in <module> class AuthStampedModel(Model):
    Parsa Akbari
    @parsaakbari80808080
    Hi everyone, I am 19 years old. I am a computer engineering student right now, and I have been learning and using python, js, HTML, CSS, bash script, java, docker, react, and many other technologies and libraries. Right now, I am trying to land my first remote, part-time job as a software developer. If anyone could help me find one, or know about some open positions or could give me some tips [you know what I am trying to say :-) ] I would appreciate contacting. I am not expecting high or medium salary, I just one to start from a point and do some real team works and develop web apps.
    If you can help me please email me I would really like to make some friends too. My email address:
    akbariparsa1209@gmail.com
    PavitKaur05
    @PavitKaur05
    Hi Everyone ! My name is Pavit and I recently started working with Django and really loved it . I want to be part of this community so that I can learn and grow more😊😊
    developerbuilds
    @developerbuilds
    @parsaakbari80808080 i am Looking For a React Developer . If You wanna work with me (a small startup ) then i will pay you for what you will do for me (if everything goes well you will be Paid enough else i will pay you for sure . ) you may learn new thing or maybe i will learn so this will be benificial for us . :) waiting for your reponse !
    Parsa Akbari
    @parsaakbari80808080
    Hi @developerbuilds , thanks I dmed you just check there.
    matrixbot
    @matrixbot
    MARIOREDFOX Can anyone say how to use pandas in django to upload CSV and store the data on DB
    Dr. Muhammad Anjum
    @anjumuaf123_twitter
    @parsaakbari80808080 hi sair
    Parsa Akbari
    @parsaakbari80808080
    hi @anjumuaf123_twitter
    joonaid
    @joonaid
    gays what the way for host my socket server online ,, i try azure server but i cant connect from client to server
    matrixbot
    @matrixbot
    vladox > gays what the way for host my socket server online ,, i try azure server but i cant connect from client to server
    Guys?