How to delete a model in LoopBack? - loopbackjs

Is there a command to delete a model in LoopBack?
The command to create a model is:
slc loopback
But I can't find how to delete a model...

Go into your loopback project folder and delete the files associated with the model from directory /common/models/ or /server/models/.
Then go into /server/ directory and delete the model's config object from the file model-config.json

Related

Django 2.1.7 Clean Way to delete a single App?

i ask myself if there is a clean way/ procedure to ask Django to delete a single app. There are Topics with the same Question but they referencing to older Versions or i missed it.
I am newbie i donĀ“t want to mess around with the django db by simply delete the Setting.py App registration. Because I saw that in the Django DB, between all the model entries, there are also data records of migrations, sessions, data entries or how i would call it, django magic.
I am using Django 2.1.7 within VirtualEnv.
So Far my procedure.
Delete the 'my_old_app' App-Registration in settings.py / INSTALLED_APPS
Change all entries in views.py, urls.py that have a connection to my_old_app
Deleting the model data of my_old_app. (simply Migrate?)
Thanks, for every Information.
You could follow these steps to delete an app in a good way.
delete unnecessary model in `models.py` and `migrate`
delete your app name from `settings.py` in INSTALLED_APPS
delete all folder `__pycache__ `
delete all import link in `views.py`, `admin.py` end etc.
delete all link's in `urls.py` that are unnecessary
delete app's folder
You could make use of --dry-run as mentioned by #Red Cricket in comments

How to migrate default user data to custom user model in Django

As I want to customize Django user model, I migrated from default user model to my own custom user model. Since my Django project has been working since a long time ago, I need to keep the existing user data.
I was thinking to move them manually, but Django default user model's passwords are hidden. How can I safely move existing user data to my custom user model?
Moving to CustomUser is no easy task in Django. If you want to keep the existing data, then as per ticket #25313, you need to do the following steps:
Create a custom user model identical to auth.User, call it User (so many-to-many tables keep the same name) and set db_table='auth_user' (so it uses the same table).
Throw away all your migrations from all the apps(except for __init__.py file inside the migrations folder).
Recreate a fresh set of migrations(using python manage.py makemigrations).
Make a backup of your database.
Delete all entries from django_migrations table from DB.
Fake-apply the new set of migrations(using python manage.py migrate --fake).
Optional: Set db_table="your_custom_table" or remove it altogether.
Make other changes to the custom model, generate migrations, apply them.
You can dump your existing model data with dumpdata command and also able to reload those data to that model or your changed custom model with loaddata command. Here is a good example how you can able to do that. link

Django: database access

I have a Django project called myproj, with an app called myapp, containing a model called Mymodel. In myproj/myapp, I want to create a Python script that accesses the database. I know how to access the database from myproj/myapp/views.py, but if I have a blank file at myproj/myapp/myscript.py, then what do I need to do to enable database interaction? Currently, if I just write the following in the script:
from models import mymodel
objs = Mymodel.objects.all()
But I get a load of errors for that. Any help?
Create a custom management command

Retrieve Data from Project Server Field into Task List

How to retrieve data from project server custom fields into cutsom list.
Like : There is Project ID fields in pwa, which contains all project ID's. Now the data of this field i want in custom list of project site.
Is there any connection can be made?
You can use the Project Server Interface if you are on 2007+.
http://msdn.microsoft.com/en-us/library/office/ms512767(office.14)

sorl-thumbnail not deleting parent file or cache when entry is deleted

I'm not sure what I am doing wrong. But the uploaded file and it's related cache don't get deleted when the entry is deleted.
I have a photos model inline of a property model, with an FK from the photos model to the property model. I am using 'from sorl.thumbnail import ImageField' to replace the default Django models.ImageField.
In Django Admin, when I delete the entry of a photo, the entry is deleted but the files for that entry are not deleted. I am using Django's runserver for the development and I am not seeing any errors. From what I have read, these files should be removed if the entry is deleted, unless there is a reference to them yet. The only reference that I am seeing yet is in the thumbnail_kvstore table.
Anyone have any thoughts on what I am missing?
The delete_file method will only be called in Django < v1.2.5. The best way to delete sorl.thumbnail.ImageField files, thumbnails and key value store references (used by sorl thumbnail) is to use sorl.thumbnail.delete function: sorl.thumbnail.delete(self.photo)
The ImageField from sorl.thumbnail should be an extension of django's FileField
From the release notes of django 1.2.5:
In earlier Django versions, when a model instance containing a FileField was deleted, FileField took it upon itself to also delete the file from the backend storage. This opened the door to several potentially serious data-loss scenarios, including rolled-back transactions and fields on different models referencing the same file. In Django 1.2.5, FileField will never delete files from the backend storage. If you need cleanup of orphaned files, you'll need to handle it yourself (for instance, with a custom management command that can be run manually or scheduled to run periodically via e.g. cron).
I had the problem with django-filebrowser, and when you replaced the image with a new one, the cached files did not update. So in my case it wasn't an issue with sorl-thumbnail but rather with django-filebrowser. sorl would only re-draw the thumbnails when the path of the file changed. To fix this I set the filebrowser FILEBROWSER_OVERWRITE_EXISTING setting to False.
FILEBROWSER_OVERWRITE_EXISTING = False
This may help someone at least debug the issue if they are not using django-filebrowser. But in the case of django-filebrowser this is the way to go. Cheers.