Don't worry. It is easy to use. You must follow these steps:
-
Required Packages: Before starting, you need to install Python and pip. Then you have to install Django. Don't forget to use a virtual enviroment!
-
Download the source project: Download or clone the project to your computer.
-
Open the project (Optional): Once you have downloaded the project, extract it! You should open the project in your code editor so that you can see or understand the structure of the project.
-
Before execute the project:
- makemigrations: Open new terminal and inside the root directory type:
python manage.py makemigrationsto create the migrations (generate the SQL commands). - migrate: Then run
python manage.py migrateto run the migrations (execute the SQL commands). - Dump data: Make sure your DB is completely empty and then run
python manage.py loaddata subasafe_data.json
Not necessary
- Create a superuser: To get logged into the application you have to create a superuser. Use
python manage.py createsuperuserthen complete the requested data.
- makemigrations: Open new terminal and inside the root directory type:
-
Execute the project: Now you have completed the previous steps, run
python manage.py runserveron the root directory. If everything went well, you should be able to observe a line with the following:Starting development server at http://127.0.0.1:8000/. All you have to do is copy that address and paste it into your search bar. Also, you can type the addresslocalhost:8000.
3.7.9
subasafe-e683d
-
In order to activate the Virtual Enviroment on Windows OS use
.\envs\subaSafe\Scripts\activate -
SuperUser:
- Username:
admin, - Email:
admin@subasafe.com, - Password:
admin
- Username:
-
All users:
- username:
<my_username> - email:
<my_username>@subasafe.com - password:
<my_username>
- username:
-
How to know my installed packages
pip freeze --local
-
Registrar un usuario vía Firebase (Google):
- Ingresar a la URL
http://localhost:8000/login/aplastar sobre registrar y registrar la cuenta de google - Desde la consola del navegador, copiar el token otorgado por Firebase y copiarlo en la dirección
http://localhost:8000/api/google-login/ - Ahora se ha guardado un token dentro de la base de datos.
- Ingresar a la URL
-
Registrar un usuario dentro de la app interna:
-
Ingresar a la URL
http://127.0.0.1:8000/api/auth/register/y proveer los datos. -
Ingresar al correo. Se observará algo así:
Hi AlexSubaSafe Use the link below to verify your email http://127.0.0.1:8000/verificar-email/? token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9. eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjUyNjQ5NTMwLCJpYXQiOjE2NDIyODE1MzAsImp0a SI6IjNkZGJhMThkMzBhMDQ4N2ZiYzM0NGQzYTYxMTg4OTI4IiwidXNlcl9pZCI6NH0. XktbXFfCutND9AlmJKasaLoXmn4vxEEwo53ls1Uk-hY.Debería copiar:
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9. eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNjUyNjQ5NTMwLCJpYXQiOjE2NDIyODE1MzAsImp0a SI6IjNkZGJhMThkMzBhMDQ4N2ZiYzM0NGQzYTYxMTg4OTI4IiwidXNlcl9pZCI6NH0. XktbXFfCutND9AlmJKasaLoXmn4vxEEwo53ls1Uk-hY. -
Copie el token en la dirección
http://127.0.0.1:8000/verificar-email/. Si tiene un mensaje de{"STATUS": "El usuario ha sido activado"}entonces puede continuar.
-
-
Autenticación de Sesión con Firebase Google:
-
Para poder hacer las operaciones CRUD, se debe enviar los datos por cabecera.
Key: Authorization Value: Token 'token en la BD'
-
-
Autenticación de Sesión con un usuario interno:
-
Ingrese en la dirección
http://127.0.0.1:8000/api/auth/login/y loguee el correo y contraseña. -
Para poder hacer las operaciones CRUD, se debe enviar los datos por cabecera.
Key: Authorization Value: Bearer 'token de acceso del paso anterior'
-
-
ERROR: django is not recognized as a command:
SOLUTION: python and python3: Use python only when you are going to use manage.py file.
-
ERROR: AssertionError at /api/users/ 'UserApiViewSet' should either include a
querysetattribute, or override theget_queryset()method. -
ERROR: partial_update method is not working
SOLUTION: Make sure that the last field doesn't end in a comma.
-
ERROR: 'Manager' object has no attribute 'get_by_natural_key'
SOLUTION: Define an object which contains the manager for that model. https://www.google.com/search?q=which&oq=wich&aqs=edge.1.69i57j0i10i512j0i512l2j0i10j0i10i512j0i10j0i10i512j0i10.1448j0j1&sourceid=chrome&ie=UTF-8
-
ERROR: TemplateDoesNotExist: users/login.html
SOLUTION: Install Unipath package, then change the BASE_DIR to
BASE_DIR = Path(__file__).resolve().ancestor(3). Once made that, change _DIRS* in TEMPLATES to'DIRS': [BASE_DIR.child('templates')],. In settings/local.py change DATABASE/default/NAME to'NAME': BASE_DIR.child('db.sqlite3') -
ERROR: The serializer field might be named incorrectly and not match any attribute or key on the
QuerySetinstance. Original exception text was: 'QuerySet' object has no attribute 'username'.SOLUTION: Add many=True to the serialized_users https://stackoverflow.com/questions/61162245/original-exception-text-was-queryset-object-has-no-attribute-name-using-dja
-
ERROR: Add null field to a serializer
SOLUTION: Add allow_null=True in serializer field. https://stackoverflow.com/questions/42158692/django-nested-serializer-allow-null-true
-
ERROR: Turn single fields in an object field
SOLUTION: Make a new SerializerMethodField Where the desired fields are included. Then create a serializer to those fields.
By: Alex Cuenca