数据操作Django报销单

D:\djangoProject\shuishan_oa_v1>python manage.py shell
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:02) [MSC v.1924 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
(InteractiveConsole)
>>> from financial.models import BusinessTravels
>>> BusinessTravels.objects.all()
<QuerySet [<BusinessTravels: 2020-08-10-张三-项目演示>, <BusinessTravels: 2020-08-10-张三-oa_key>, <BusinessTravels: 2020-08-09-张三-产品演示>, <BusinessTravels: 2020-08-08-张三-水杉数
字科技>]>
>>> a=BusinessTravels.objects.first()
>>> a
<BusinessTravels: 2020-08-10-张三-项目演示>
>>> dir(a)
['DoesNotExist', 'MultipleObjectsReturned', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__'
, '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__setstate__', '__sizeo
f__', '__str__', '__subclasshook__', '__weakref__', '_check_column_name_clashes', '_check_field_name_clashes', '_check_fields', '_check_id_field', '_check_index_together', '_check_loca
l_fields', '_check_long_column_names', '_check_m2m_through_same_relationship', '_check_managers', '_check_model', '_check_model_name_db_lookup_clashes', '_check_ordering', '_check_swap
pable', '_check_unique_together', '_do_insert', '_do_update', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_get_unique_chec
ks', '_meta', '_perform_date_checks', '_perform_unique_checks', '_save_parents', '_save_table', '_set_pk_val', '_state', 'cDate', 'cTime', 'check', 'clean', 'clean_f






                                                                                                                      l_fields', '_check_long_column_names', '_check_
m2m_through_same_relationship', '_check_managers', '_check_model', '_check_model_name_db_lookup_clashes', '_check_ordering', '_check_swappable', '_check_unique_toget
her', '_do_insert', '_do_update', '_get_FIELD_display', '_get_next_or_previous_by_FIELD', '_get_next_or_previous_in_order', '_get_pk_val', '_get_unique_checks', '_me
ta', '_perform_date_checks', '_perform_unique_checks', '_save_parents', '_save_table', '_set_pk_val', '_state', 'cDate', 'cTime', 'check', 'clean', 'clean_fields', '
date_error_message', 'delete', 'employee', 'employee_id', 'fee', 'filePath', 'from_db', 'full_clean', 'get_deferred_fields', 'get_next_by_cDate', 'get_next_by_cTime'
, 'get_previous_by_cDate', 'get_previous_by_cTime', 'get_status_display', 'isDel', 'name', 'objects', 'pk', 'prepare_database_save', 'projectName', 'refresh_from_db'
, 'remark', 'save', 'save_base', 'serializable_value', 'sort', 'status', 'travelChoice', 'travelEx', 'uid', 'unique_error_message', 'validate_unique']
>>> a.travelEx
<django.db.models.fields.related_descriptors.create_reverse_many_to_one_manager.<locals>.RelatedManager object at 0x000002544FDF9D00>
>>> a.travelEx()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
TypeError: __call__() missing 1 required keyword-only argument: 'manager'
>>> a.travelEx.all()
<QuerySet [<TravelExpenses: None-日期:[2020-08-01],地点:[衡水2]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水]>]>
>>> from financial.models import TravelExpenses
>>> TRavelExpenses.objects.all()
Traceback (most recent call last):
  File "<console>", line 1, in <module>
NameError: name 'TRavelExpenses' is not defined
>>> TravelExpenses.objects.all()
<QuerySet [<TravelExpenses: None-日期:[2020-08-04],地点:[2]>, <TravelExpenses: 张三-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[杭
州]>, <TravelExpenses: None-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[石家庄]>, <TravelExpenses: None-日期:[2020-08-01],地点:[444
4]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水2]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水]>]>
>>> b=TravelExpenses.objects.all()
>>> b
<QuerySet [<TravelExpenses: None-日期:[2020-08-04],地点:[2]>, <TravelExpenses: 张三-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[杭
州]>, <TravelExpenses: None-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[石家庄]>, <TravelExpenses: None-日期:[2020-08-01],地点:[444
4]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水2]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水]>]>
>>> a
<BusinessTravels: 2020-08-10-张三-项目演示>
>>> a.travelEx.all()
<QuerySet []>
>>> a.travelEx.add(*b)
>>> a
<BusinessTravels: 2020-08-10-张三-项目演示>
>>> a.travelEx.all()
<QuerySet [<TravelExpenses: None-日期:[2020-08-04],地点:[2]>, <TravelExpenses: 张三-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[杭
州]>, <TravelExpenses: None-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[石家庄]>, <TravelExpenses: None-日期:[2020-08-01],地点:[444
4]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水2]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水]>]>
>>> a.travelEx.clear()
>>> a.travelEx.all()
<QuerySet []>
>>> a.travelEx.add(*b)
>>> a.travelEx.all()
<QuerySet [<TravelExpenses: None-日期:[2020-08-04],地点:[2]>, <TravelExpenses: 张三-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[杭
州]>, <TravelExpenses: None-日期:[2020-08-01],地点:[济南]>, <TravelExpenses: None-日期:[2020-08-01],地点:[石家庄]>, <TravelExpenses: None-日期:[2020-08-01],地点:[444
4]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水2]>, <TravelExpenses: None-日期:[2020-08-01],地点:[衡水]>]>
>>>

  

posted @ 2020-08-10 23:53  巨兽~墨菲特  阅读(249)  评论(0编辑  收藏  举报