Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
django-angular-dynamic-forms
Advanced tools
Django Rest Framework meets Angular 5 material.io dynamic forms - rapid development of create and edit dialogs
This repo provides Django mixins and Angular library for rapid development of create/edit dialogs for django rest framework. It depends on Django 2, Angular 6 and Material UI.
Note: support for Angular 5 and Django<2 is not actively developed - use release/angular5 branch or 1.1.* versions of packages if you need that.
On django side, extend your Viewset
to use AngularFormMixin
and optionally configure the mixin by providing either layout
information or field defaults (such as css classes). See demos
for details.
.. code-block:: python
class CityViewSet(AngularFormMixin, viewsets.ModelViewSet):
"""
API for cities
"""
queryset = City.objects.all()
serializer_class = CitySerializer
On angular side, use DjangoFormDialogService
to display a dialog:
.. code-block:: typescript
constructor(private dialog: DjangoFormDialogService) {
}
createCity() {
this.dialog.open('/api/1.0/cities/').subscribe(result => {
console.log('City created, result from server is:', result);
});
}
You can also display the form inside your own component via <django-inpage-form>
tag.
.. code-block:: html
<django-inpage-form django_url="/api/1.0/cities/"
(submit)="submit($event)"
(cancel)="cancel($event)"></django-inpage-form>
See demos at http://mesemus.no-ip.org:12569
.. image:: https://raw.githubusercontent.com/mesemus/django-angular-dynamic-forms/develop/docs/demo.png
With a bit of work on your side, foreign keys and many-to-many relationships are supported as well (see the demos for details)
.. image:: https://raw.githubusercontent.com/mesemus/django-angular-dynamic-forms/develop/docs/foreign_key.png
Django side:
.. code-block:: bash
pip install django-angular-dynamic-forms
Angular side:
.. code-block:: bash
npm install --save django-angular-dynamic-forms @ng-dynamic-forms/core @ng-dynamic-forms/ui-material
To render forms, this library uses https://github.com/udos86/ng-dynamic-forms - do not forget to add it to your package.json.
and add DjangoFormModule
to imports. You will need to provide your own ErrorService for showing
communication errors back to the user. See the demo/angular/src/app/mat-error.service.ts
for
an example implementation.
.. code-block:: typescript
import {DjangoFormModule, ErrorService} from 'django-angular-dynamic-forms';
@NgModule({
declarations: [
...
],
imports: [
BrowserAnimationsModule,
DynamicFormsCoreModule.forRoot(),
DynamicFormsMaterialUIModule,
DjangoFormModule,
HttpClientModule,
...
],
providers: [
{
provide: ErrorService,
useClass: MatErrorService
},
],
bootstrap: [AppComponent]
})
export class AppModule {
}
If your angular and django server are on the same host/port (see https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/proxy.md for development tips), no configuration is necessary.
If angular and django are on different hosts/ports, set django setting ANGULAR_FORM_ABSOLUTE_URLS=True
(
thanks @sssolid for pointing this out).
FAQs
Django Rest Framework meets Angular 5 material.io dynamic forms - rapid development of create and edit dialogs
We found that django-angular-dynamic-forms demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.