0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Django に入門してみる。

Posted at

インストール方法、起動方法とか、全部わからない状態からスタートです。

Django というか、そもそも普段Python全く使わないので、その環境構築とかの方法も調べて(VS Codeでやる方法とか)、
そのあとで、
とりあえず、このDjango入門記事のとおりに作ってみました。

投稿リスト画面

1.PNG

編集画面

3.PNG

ここまでは記事通りにできました。

投稿の、新規作成、修正、削除できます。

気づいたこと

ここで、この Modelのコードの、

models.py
from django.db import models

# Create your models here.
class Post(models.Model):
    name = models.CharField('user name', max_length=15)
    micropost = models.CharField('tweet', max_length=140, blank=True)

    def __str__(self):
        return self.name
        

CharFieldの第1引数の user name や tweet が

models.py
    name = models.CharField('user name', max_length=15)
    micropost = models.CharField('tweet', max_length=140, blank=True)

編集画面のこの赤枠で囲った部分に相当するのではないか?と思い、

3 - コピー (2).PNG

別の文字列を入れたら、変更されました。

models.py
    name = models.CharField('名前', max_length=15)
    micropost = models.CharField('投稿', max_length=140, blank=True)

8.PNG

また、もしかすると、半角英字は自動的に先頭が大文字になるのか?と思い、
「名前」を「a名前」と入れてみた所、画面表示は「A名前」になりました。

models.py
    name = models.CharField('a名前', max_length=15)
    micropost = models.CharField('投稿', max_length=140, blank=True)

9.PNG

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?