質問編集履歴

1

指摘点の追記をいたしました。現在のディレクトリとやりたいこと、ディレクトリ構造についてです。

2020/06/17 10:45

投稿

tonytony
tonytony

スコア11

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- python manage.py makemigtations しようとしたところ、
1
+ python manage.py makemigrations しようとしたところ、
2
2
 
3
3
 
4
4
 
@@ -14,6 +14,10 @@
14
14
 
15
15
  どなたかわかる方いたら教えてください。
16
16
 
17
+ やりたいことはusersディレクトリにあるmodels.pyのProfileモデルをインポートしたいです。(pairnite.users.models.pyに記載されているProfile)
18
+
19
+ 呼び出し元のディレクトリはpairnite.chat.models.pyです。
20
+
17
21
  以下、modelsと、インポート元と、settingsです。
18
22
 
19
23
 
@@ -84,158 +88,6 @@
84
88
 
85
89
 
86
90
 
87
- class CustomUserManager(UserManager):
88
-
89
- """ユーザーマネージャー"""
90
-
91
- use_in_migrations = True
92
-
93
-
94
-
95
- def _create_user(self, email, password, **extra_fields):
96
-
97
- if not email:
98
-
99
- raise ValueError('The given email must be set')
100
-
101
- email = self.normalize_email(email)
102
-
103
- user = self.model(email=email, **extra_fields)
104
-
105
- user.set_password(password)
106
-
107
- user.save(using=self._db)
108
-
109
- return user
110
-
111
-
112
-
113
- def create_user(self, email, password=None, **extra_fields):
114
-
115
- extra_fields.setdefault('is_staff', False)
116
-
117
- extra_fields.setdefault('is_superuser', False)
118
-
119
- return self._create_user(email, password, **extra_fields)
120
-
121
-
122
-
123
- def create_superuser(self, email, password, **extra_fields):
124
-
125
- extra_fields.setdefault('is_staff', True)
126
-
127
- extra_fields.setdefault('is_superuser', True)
128
-
129
- if extra_fields.get('is_staff') is not True:
130
-
131
- raise ValueError('Superuser must have is_staff=True.')
132
-
133
- if extra_fields.get('is_superuser') is not True:
134
-
135
- raise ValueError('Superuser must have is_superuser=True.')
136
-
137
- return self._create_user(email, password, **extra_fields)
138
-
139
-
140
-
141
-
142
-
143
- class User(AbstractBaseUser, PermissionsMixin):
144
-
145
- """カスタムユーザーモデル."""
146
-
147
-
148
-
149
- email = models.EmailField(_('email address'), unique=True)
150
-
151
-
152
-
153
- is_staff = models.BooleanField(
154
-
155
- _('staff status'),
156
-
157
- default=False,
158
-
159
- help_text=_(
160
-
161
- 'Designates whether the user can log into this admin site.'),
162
-
163
- )
164
-
165
- is_active = models.BooleanField(
166
-
167
- _('active'),
168
-
169
- default=True,
170
-
171
- help_text=_(
172
-
173
- 'Designates whether this user should be treated as active. '
174
-
175
- 'Unselect this instead of deleting accounts.'
176
-
177
- ),
178
-
179
- )
180
-
181
- date_joined = models.DateTimeField(_('date joined'), default=timezone.now)
182
-
183
-
184
-
185
- objects = CustomUserManager()
186
-
187
-
188
-
189
- EMAIL_FIELD = 'email'
190
-
191
- USERNAME_FIELD = 'email'
192
-
193
- REQUIRED_FIELDS = []
194
-
195
-
196
-
197
- class Meta:
198
-
199
- verbose_name = _('user')
200
-
201
- verbose_name_plural = _('users')
202
-
203
-
204
-
205
- def get_short_name(self):
206
-
207
- """Return the short name for the user."""
208
-
209
- return self.email
210
-
211
-
212
-
213
- def email_user(self, subject, message, from_email=None, **kwargs):
214
-
215
- """Send an email to this user."""
216
-
217
- send_mail(subject, message, from_email, [self.email], **kwargs)
218
-
219
-
220
-
221
- @property
222
-
223
- def username(self):
224
-
225
- """username属性のゲッター
226
-
227
-
228
-
229
- 他アプリケーションが、username属性にアクセスした場合に備えて定義
230
-
231
- メールアドレスを返す
232
-
233
- """
234
-
235
- return self.email
236
-
237
-
238
-
239
91
 
240
92
 
241
93
  # OneToOneで、ユーザーモデルに紐付ける
@@ -308,27 +160,7 @@
308
160
 
309
161
  ```settings.py
310
162
 
311
- """
163
+
312
-
313
- Django settings for config project.
314
-
315
-
316
-
317
- Generated by 'django-admin startproject' using Django 3.0.6.
318
-
319
-
320
-
321
- For more information on this file, see
322
-
323
- https://docs.djangoproject.com/en/3.0/topics/settings/
324
-
325
-
326
-
327
- For the full list of settings and their values, see
328
-
329
- https://docs.djangoproject.com/en/3.0/ref/settings/
330
-
331
- """
332
164
 
333
165
 
334
166
 
@@ -492,124 +324,252 @@
492
324
 
493
325
 
494
326
 
495
- # Password validation
496
-
497
- # https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
498
-
499
-
500
-
501
- AUTH_PASSWORD_VALIDATORS = [
502
-
503
- {
504
-
505
- 'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
506
-
507
- },
508
-
509
- {
510
-
511
- 'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
512
-
513
- },
514
-
515
- {
516
-
517
- 'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
518
-
519
- },
520
-
521
- {
522
-
523
- 'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
524
-
525
- },
526
-
527
- ]
528
-
529
-
530
-
531
-
532
-
533
- # Internationalization
534
-
535
- # https://docs.djangoproject.com/en/3.0/topics/i18n/
536
-
537
-
538
-
539
- LANGUAGE_CODE = 'ja'
540
-
541
-
542
-
543
- TIME_ZONE = 'Asia/Tokyo'
544
-
545
-
546
-
547
- USE_I18N = True
548
-
549
-
550
-
551
- USE_L10N = True
552
-
553
-
554
-
555
- USE_TZ = True
556
-
557
-
558
-
559
-
560
-
561
- # Static files (CSS, JavaScript, Images)
562
-
563
- # https://docs.djangoproject.com/en/3.0/howto/static-files/
564
-
565
-
566
-
567
- STATIC_URL = '/static/'
568
-
569
-
570
-
571
- # アイコン画像の保存先設定
572
-
573
- MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
574
-
575
- MEDIA_URL = '/media/'
576
-
577
-
578
-
579
- # ログイン後のリダイレクト先
580
-
581
- LOGIN_REDIRECT_URL = "users:home"
582
-
583
- # ログアウト後のリダイレクト先
584
-
585
- LOGOUT_REDIRECT_URL = "users:index"
586
-
587
- # Channelsを有効化。channelsは非同期処理をサポートする。
588
-
589
- # https://qiita.com/massa142/items/cbd508efe0c45b618b34#:~:text=Django%20Channels%E3%81%A8%E3%81%AF&text=Channels%E3%81%AF%E3%80%81Django%E3%81%8CWebSocket,%E3%81%AB%E3%81%99%E3%82%8B%E3%83%97%E3%83%AD%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88%E3%81%A7%E3%81%82%E3%82%8B%E3%80%82
590
-
591
- ASGI_APPLICATION = 'config.routing.application'
592
-
593
- # channel layerの有効化。channel layerは複数ユーザーの間でメッセージを共有できる仕組み。docker環境に写したとき、hostsの第一引数をredisに変えた方がいいかも。
594
-
595
- # http://www.denzow.me/entry/2018/04/03/002351
596
-
597
- CHANNEL_LAYERS = {
598
-
599
- 'default': {
600
-
601
- 'BACKEND': 'channels_redis.core.RedisChannelLayer',
602
-
603
- 'CONFIG': {
604
-
605
- "hosts": [("127.0.0.1", 6379)],
606
-
607
- },
608
-
609
- },
610
-
611
- }
612
-
613
-
614
-
615
327
  ```
328
+
329
+
330
+
331
+ ディレクトリ構造
332
+
333
+ ```ここに言語を入力
334
+
335
+
336
+
337
+ ├── Pipfile
338
+
339
+ ├── Pipfile.lock
340
+
341
+ ├── chat
342
+
343
+ │   ├── __init__.py
344
+
345
+ │   ├── __pycache__
346
+
347
+ │   │   ├── __init__.cpython-37.pyc
348
+
349
+ │   │   ├── admin.cpython-37.pyc
350
+
351
+ │   │   ├── apps.cpython-37.pyc
352
+
353
+ │   │   ├── chat_controller.cpython-37.pyc
354
+
355
+ │   │   ├── models.cpython-37.pyc
356
+
357
+ │   │   ├── urls.cpython-37.pyc
358
+
359
+ │   │   └── views.cpython-37.pyc
360
+
361
+ │   ├── admin.py
362
+
363
+ │   ├── apps.py
364
+
365
+ │   ├── chat_controller.py
366
+
367
+ │   ├── consumers.py
368
+
369
+ │   ├── forms.py
370
+
371
+ │   ├── migrations
372
+
373
+ │   │   ├── __init__.py
374
+
375
+ │   │   └── __pycache__
376
+
377
+ │   │   └── __init__.cpython-37.pyc
378
+
379
+ │   ├── models.py
380
+
381
+ │   ├── routing.py
382
+
383
+ │   ├── tests.py
384
+
385
+ │   ├── urls.py
386
+
387
+ │   └── views.py
388
+
389
+ ├── config
390
+
391
+ │   ├── __init__.py
392
+
393
+ │   ├── __pycache__
394
+
395
+ │   │   ├── __init__.cpython-37.pyc
396
+
397
+ │   │   ├── routing.cpython-37.pyc
398
+
399
+ │   │   ├── settings.cpython-37.pyc
400
+
401
+ │   │   ├── urls.cpython-37.pyc
402
+
403
+ │   │   └── wsgi.cpython-37.pyc
404
+
405
+ │   ├── routing.py
406
+
407
+ │   ├── settings.py
408
+
409
+ │   ├── urls.py
410
+
411
+ │   └── wsgi.py
412
+
413
+ ├── db.sqlite3
414
+
415
+ ├── manage.py
416
+
417
+ ├── media
418
+
419
+ │   └── icon
420
+
421
+ │   ├── 1487784.jpg
422
+
423
+ │   ├── Hi_�\202��\203��\203\210�\203\233�\203��\203\210_1.png
424
+
425
+ │   ├── default.jpg
426
+
427
+ │   ├── �\202��\202��\203��\203��\203��\202��\203��\203\203�\203\210_2020-06-06_13.34.42.png
428
+
429
+ │   ├── �\203��\202��\226\207�\227ZZOO_w.jpg
430
+
431
+ │   └── �\214�\221�\226��\202��\202場�\217模.jpg
432
+
433
+ ├── relations
434
+
435
+ │   ├── __init__.py
436
+
437
+ │   ├── __pycache__
438
+
439
+ │   │   ├── __init__.cpython-37.pyc
440
+
441
+ │   │   ├── admin.cpython-37.pyc
442
+
443
+ │   │   ├── apps.cpython-37.pyc
444
+
445
+ │   │   ├── forms.cpython-37.pyc
446
+
447
+ │   │   ├── models.cpython-37.pyc
448
+
449
+ │   │   ├── urls.cpython-37.pyc
450
+
451
+ │   │   └── views.cpython-37.pyc
452
+
453
+ │   ├── admin.py
454
+
455
+ │   ├── apps.py
456
+
457
+ │   ├── forms.py
458
+
459
+ │   ├── migrations
460
+
461
+ │   │   ├── 0001_initial.py
462
+
463
+ │   │   ├── __init__.py
464
+
465
+ │   │   └── __pycache__
466
+
467
+ │   │   ├── 0001_initial.cpython-37.pyc
468
+
469
+ │   │   └── __init__.cpython-37.pyc
470
+
471
+ │   ├── models.py
472
+
473
+ │   ├── tests.py
474
+
475
+ │   ├── urls.py
476
+
477
+ │   └── views.py
478
+
479
+ ├── templates
480
+
481
+ │   ├── base.html
482
+
483
+ │   ├── chat
484
+
485
+ │   │   └── chat.html
486
+
487
+ │   ├── home.html
488
+
489
+ │   ├── index.html
490
+
491
+ │   ├── registration
492
+
493
+ │   │   └── login.html
494
+
495
+ │   ├── relations
496
+
497
+ │   │   ├── dislike.html
498
+
499
+ │   │   └── like.html
500
+
501
+ │   └── users
502
+
503
+ │   ├── delete.html
504
+
505
+ │   ├── detail.html
506
+
507
+ │   ├── mail_change.html
508
+
509
+ │   ├── password_change.html
510
+
511
+ │   ├── password_change_done.html
512
+
513
+ │   ├── signup.html
514
+
515
+ │   └── update.html
516
+
517
+ └── users
518
+
519
+ ├── __init__.py
520
+
521
+ ├── __pycache__
522
+
523
+ │   ├── __init__.cpython-37.pyc
524
+
525
+ │   ├── admin.cpython-37.pyc
526
+
527
+ │   ├── apps.cpython-37.pyc
528
+
529
+ │   ├── forms.cpython-37.pyc
530
+
531
+ │   ├── mixins.cpython-37.pyc
532
+
533
+ │   ├── models.cpython-37.pyc
534
+
535
+ │   ├── urls.cpython-37.pyc
536
+
537
+ │   └── views.cpython-37.pyc
538
+
539
+ ├── admin.py
540
+
541
+ ├── apps.py
542
+
543
+ ├── forms.py
544
+
545
+ ├── migrations
546
+
547
+ │   ├── 0001_initial.py
548
+
549
+ │   ├── __init__.py
550
+
551
+ │   └── __pycache__
552
+
553
+ │   ├── 0001_initial.cpython-37.pyc
554
+
555
+ │   ├── 0002_auto_20200606_1415.cpython-37.pyc
556
+
557
+ │   ├── 0003_auto_20200607_1537.cpython-37.pyc
558
+
559
+ │   ├── 0004_auto_20200608_0835.cpython-37.pyc
560
+
561
+ │   └── __init__.cpython-37.pyc
562
+
563
+ ├── mixins.py
564
+
565
+ ├── models.py
566
+
567
+ ├── tests.py
568
+
569
+ ├── urls.py
570
+
571
+ └── views.py
572
+
573
+
574
+
575
+ ```