I have written a website where an investor and a trader can: read the latest news related to finance, share their impressions about the state of the market and see the comments of other market participants
- Investing
- Trading
- News
- Comments
- Virtual environment
- pip install virtualenv
- Activate
- venv\Scripts\activate
- Install tools
- pip install -r requirements
- Run django server
- python manage.py makemigrations
- python manage.py migrate
- python manage.py runserver
- Run Node server
cd hello/apps/frontend
npm run dev
# Блок для создания статей
class Article(models.Model):
Idea = 'ID'
Learn = 'LN'
Motivation = 'mt'
Blog = 'bl'
# Переменная по созданию определенных категорий, т.е.
# на каждой странице своя тема.
CATEGORY = [
(Idea, 'Idea'),
(Learn, 'Learn'),
(Motivation, 'Motivation'),
(Blog, 'Blog'),
]
title = models.CharField('Название статьи', max_length = 120)
text = HTMLField('Текст статьи')
genre = models.ManyToManyField(
Genre,
help_text="Select a genre for this article"
)
category = models.CharField(
max_length=2,
choices=CATEGORY,
default=Blog,
)
views = models.IntegerField('Просмотры', default=0)
image = models.ImageField(
null = True,
blank=True,
upload_to='Article',
help_text='150x150px',
verbose_name='Изображение'
)
pub_date = models.DateTimeField('Дата публикации', auto_now_add = True)
content = HTMLField(null=True)
def display_genre(self):
return ', '.join([ genre.name for genre in self.genre.all()[:3] ])
display_genre.short_description = 'Genre'
def __str__(self):
return self.title
def was_published_recently(self):
return self.pub_date >= (
timezone.now() - datetime.timedelta(days = 7)
)
class Meta:
verbose_name = 'Статья'
verbose_name_plural = 'Статьи'
ordering = ["-id", "-pub_date"]```