Question: I am trying to alter sequence of id field in my table using psycopg. This is works fine on my local server, but not working on production. I am not getting exceptions, the sequence is just not restarting.

```
def alter_sequence(last_id):
    try:
        dbname = settings.DATABASES['default']['NAME']
        user = settings.DATABASES['default']['USER']
        host = settings.DATABASES['default']['HOST']
        password = settings.DATABASES['default']['PASSWORD']
        port = settings.DATABASES['default']['PORT']
        connection = psycopg2.connect(
            dbname=dbname,
            user=user,
            password=password,
            host=host,
            port=port,
        )
        cursor = connection.cursor()
        cursor.execute('ALTER SEQUENCE "gs_requests_id_seq" RESTART WITH {}'.format(last_id))
        connection.close()
    except Exception as e:
        print(e)
    pass

```

I double-checked the database settings - its correct. Other database operations, performed by django ORM with this settings is works fine. 

I think, this is not enough information about my project settings but dont know what information I need to specify. I have postgres 9.6 on my local computer and 10.1 on production.

Answer: 
The problem is the `<form>` is handling the `keydown` event before the `<input>` does, so you should use `keydown.enter` on your `<input>` instead. In addition, you should use `event.preventDefault()` to stop the event from reaching the `<form>` (and triggering the `submit`-event).

**app.component.html**

```
<form (ngSubmit)="onSubmit">
  ...
  <input (keydown.enter)="handleKeyEnter($event)">
</form>

```

**app.component.ts**

```
handleKeyEnter(event) {
  event.preventDefault();
  ...
}

```

[demo](https://stackblitz.com/edit/angular-28odue?file=app/app.component.html)
You can try **[this](https://stackblitz.com/edit/angular-chqsfu)**

app.component.html

```
<form [formGroup]="form" (ngSubmit)="onSubmit($event)" (keydown)="handleKeyupEnter($event)">
  <input type="text" [formControl]="form.controls['name']" placeholder="Name">
<br><br>
  <input type="text" placeholder="data" #entry >

  <br><br>
  <button type="submit">Submit</button>
</form>

```

app.component.ts

```
import { Component, ViewChild, ElementRef } from '@angular/core';
import { FormBuilder, FormGroup, FormControl } from '@angular/forms';

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  form: FormGroup;

  constructor(private fb: FormBuilder) { }

  @ViewChild('entry') entry: ElementRef;

  ngOnInit() {
    this.form = this.fb.group({
      name: ''
    })
  }

  onSubmit(e) {
    alert('Form Submitted');
    console.log(e);
  }

  handleKeyupEnter(event, value) {
    console.log(event)
    if(event.code=="Enter")
    event.preventDefault();

  }
}

```

if you need to exclude specific children from this behaviour (like your data input) , then do a check for `event.target` & `event.srcElement`