Poppy Cooke

Poppy Cooke

1548857892

Removing duplicates due to order by fields from a related model

I have 2 different models in the same app

class Book(models.Model):
    title = models.CharField(max_length=250, unique=True)
    slug = models.SlugField(max_length=50)
    description = models.TextField(max_length=500)

class Chapter(models.Model):
book = models.ForeignKey(Book,on_delete=models.CASCADE)
num = models.PositiveIntegerField(verbose_name=“Chapter Number”)
rdate = models.DateTimeField(verbose_name=“Release Date”, default=timezone.now)

What I want to do is get all books ordered by descending of release date rdate What I tried is:

Book.objects.all().order_by(‘-chapter__rdate’).distinct()

Some duplicates were found in result, I only had 2 books added, so only 1 book was duplicated. The result was something like this: Book1, Book2, Book2

I have already seen the note from here, and im using SQLite. By using values(), I won’t be able to call get_absolute_url() and some other methods that I want to call so using values() is out of question.

Next I tried to annotate the Chapter rdate into Book query like thisBook.objects.all().annotate(bdate=ExpressionWrapper(F(‘chapter__rdate’), output_field=DateTimeField())).order_by(‘-bdate’).distinct()

Still ended in the same result. I’m totally lost, please need help. I probably won’t change to PostgreSQL now, but I might use it when I deploy the app, so I want both SQLite version and PostgreSQL version solutions for this if at all possible. SQLite solution is absolutely necessary for me since it’s easy to use in development.

#django

What is GEEK

Buddha Community

Zara Bryant

1548890757

You can try this

Chapter.objects.values('book__title').distinct()

This will return books which have at least one chapter.

I am Developer

1597489568

Dynamically Add/Remove Multiple input Fields and Submit to DB with jQuery and Laravel

In this post, i will show you how to dynamically add/remove multiple input fields and submit to database with jquery in php laravel framework. As well as, i will show you how to add/remove multiple input fields and submit to database with validation in laravel.

dynamically add remove multiple input fields and submit to database with jquery and laravel app will looks like, you can see in the following picture:

add/remove multiple input fields dynamically with jquery laravel

Laravel - Add/Remove Multiple Input Fields Using jQuery, javaScript

Follow the below given easy step to create dynamically add or remove multiple input fields and submit to database with jquery in php laravel

  • Step 1: Install Laravel App
  • Step 2: Add Database Details
  • Step 3: Create Migration & Model
  • Step 4: Add Routes
  • Step 5: Create Controller by Artisan
  • Step 6: Create Blade View
  • Step 7: Run Development Server

https://www.tutsmake.com/add-remove-multiple-input-fields-in-laravel-using-jquery/

#laravel - dynamically add or remove input fields using jquery #dynamically add / remove multiple input fields in laravel 7 using jquery ajax #add/remove multiple input fields dynamically with jquery laravel #dynamically add multiple input fields and submit to database with jquery and laravel #add remove input fields dynamically with jquery and submit to database #sql

I am Developer

1597489654

Laravel - Dynamically Add or Remove Input Fields

In this post, i will share with you how to dynamically add/remove input fields in laravel forms.

As well as, dynamically add/remove input field and save data to database laravel.

Laravel – Add/remove input field Dynamically with Jquery

Dynamically add/remove input fields using submit form with jQuery ajax with validation and store fields into database in laravel:

  1. Step 1: Install Laravel App
  2. Step 2: Add Database Details
  3. Step 3: Create Migration & Model
  4. Step 4: Add Routes
  5. Step 5: Create Controller by Artisan
  6. Step 6: Create Blade View
  7. Step 7: Run Development Server

https://www.tutsmake.com/laravel-dynamically-add-or-remove-input-fields-jquery/

#dynamically add input fields and save data to database laravel #laravel - dynamically add or remove input fields using jquery #add/remove input fields dynamically with jquery laravel #add remove input fields dynamically with jquery and submit to database in laravel

Origin Scale

Origin Scale

1616572311

Originscale Order Management System

Originscale order management software helps to manage all your orders across channels in a single place. Originscale collects orders across multiple channels in real-time - online, offline, D2C, B2B, and more. View all your orders in one single window and process them with a simple click.

#order management system #ordering management system #order management software #free order management software #purchase order management software #best order management software

Poppy Cooke

Poppy Cooke

1548857892

Removing duplicates due to order by fields from a related model

I have 2 different models in the same app

class Book(models.Model):
    title = models.CharField(max_length=250, unique=True)
    slug = models.SlugField(max_length=50)
    description = models.TextField(max_length=500)

class Chapter(models.Model):
book = models.ForeignKey(Book,on_delete=models.CASCADE)
num = models.PositiveIntegerField(verbose_name=“Chapter Number”)
rdate = models.DateTimeField(verbose_name=“Release Date”, default=timezone.now)

What I want to do is get all books ordered by descending of release date rdate What I tried is:

Book.objects.all().order_by(‘-chapter__rdate’).distinct()

Some duplicates were found in result, I only had 2 books added, so only 1 book was duplicated. The result was something like this: Book1, Book2, Book2

I have already seen the note from here, and im using SQLite. By using values(), I won’t be able to call get_absolute_url() and some other methods that I want to call so using values() is out of question.

Next I tried to annotate the Chapter rdate into Book query like thisBook.objects.all().annotate(bdate=ExpressionWrapper(F(‘chapter__rdate’), output_field=DateTimeField())).order_by(‘-bdate’).distinct()

Still ended in the same result. I’m totally lost, please need help. I probably won’t change to PostgreSQL now, but I might use it when I deploy the app, so I want both SQLite version and PostgreSQL version solutions for this if at all possible. SQLite solution is absolutely necessary for me since it’s easy to use in development.

#django

I am Developer

1596030914

Laravel Livewire Add or Remove Multiple Input Fields Example

Laravel livewire 7 dynamically add or remove multiple input fields example tutorial from scratch. Here, you will learn how to implement add or remove multiple input fields dynamically using livewire in laravel.

As well as dynamically add multiple input fields and submit to database with livewire in laravel.

Sometimes you need to add or remove multiple input fields with livewire forms in laravel apps.

So, this laravel livewire add remove multiple input fields tutorial will help you step by step on how to implement add or remove multiple input fields dynamically using livewire in laravel project. And store into the database.

Laravel Livewire Add/Remove Multiple Input Fields Example From Scratch

Follow the below steps and implement dynamically add or remove multiple input fields using livewire package in laravel app:

Step 1: Install Laravel
Step 2: Add Database Detail
Step 3: Create Model & Migration using Artisan
Step 4: Install Livewire Package
Step 5: Create Component using Artisan
Step 6: Add Route
Step 7: Create View File
Step 8: Run Development Server

Read more by clicking this https://www.tutsmake.com/laravel-livewire-7-add-or-remove-dynamically-input-fields-example/

#dynamically add remove multiple input fields and submit to database in laravel #laravel - dynamically add or remove input fields using livewire