每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg


今日推荐开源项目:《Django——强大的python web框架

推荐理由:Django是一个基于Python的开源web应用框架,采用了MT’V的框架模式,他源自一个在线新闻web站点,以比利时的一个柬埔寨吉他手的名字命名(他的曲子真的很不错)。Django不算很年轻,但是对于一个web开发者,深入学习Django,永远都不会过时。

2018年3月28日:开源日报第20期

 

安装(Windows下):

在安装Django框架之前你的PC需要有一个Python环境,Python环境并不难搭建,就不在此过多赘述。

搭建好Python环境后,直接在官网的下载栏下载即可(点击此处下载)(目前Django1.6.x以上版本已经完全兼容Python3.x)。下载好安装包后,加压并和Python安装目录放在同一个根目录,进入Django目录。

在此目录下打开终端,并执行python setup.py install,然后开始安装,Django将要被安装到Python的Lib下site-packages。

最后是配置环境变量,将目录添加到系统环境变量当中即可。完成后就可以使用Django的django-admin.py命令新建工程了。

开始你的Django之旅:

创建django项目:

使用 django-admin.py 来创建一个名为mysite的项目:

创建完成后,通过manage.py启动django自带的服务器:

默认在127.0.0.1:8000启动服务,访问该地址显示以下页面表示创建成功:

2018年3月28日:开源日报第20期

创建新的app:

创建完项目后,在mysite目录下创建一个名为HelloDjango的app:

创建完成后目录结构如下:

HelloDjango/

__init__.py

admin.py

migrations/

__init__.py

models.py

tests.py

views.py

创建完成后在setting.py中找到INSTALLED_APPS,输入‘HelloDjango’

设计你的模型:

Django一个比较方便的地方是它附带了一个可以用Python代码描述数据库布局的对象关系映射器,数据模型语法提供了许多丰富的方法来展现你的模型。

创建一个包含title,content,pub time的模型:

models.py:

创建完成后同步数据库:

并在admin.py中注册:

Admin 管理工具

Django 最强大的部分之一是自动生成的Admin 界面。它读取模型中的元数据来提供一个强大的、生产环境就绪的界面,使内容提供者能立即用它向站点中添加内容。你可以通过 python manage.py createsuperuser创建管理员账号,通过127.0.0.1:8000/admin访问Admin界面。

2018年3月28日:开源日报第20期

你可在settings.py中将Admin界面的语言和时间设置为中国

LANGUAGE_CODE = ‘zh-hans’

TIME_ZONE = ‘Asia/Shanghai’

在Admin界面中你可访问并管理之前注册的Article模型,如添加一篇新的内容:

2018年3月28日:开源日报第20期

前端页面

Django的前端页面保存在Templates文件夹中,在HelloDjango中新建Templates文件夹并编写自己的前端代码。图片等资源则需要保存在static文件夹中

配置url与views

我们可以为每个app单独配置url,

  • 首先配置mysite中的urls.py

  • 在HelloDjango中新建urls.py

  • 在views.py中

此时访问http://127.0.0.1:8000/HelloDjango则会显示自己编写的index.html的内容

如:

2018年3月28日:开源日报第20期

在网页中加载数据库中的内容:

  • 在views.py中加载:

  • 在urls.py中添加:

  • 在article.html中通过{{article.title}},{{article.content}},{{article.pup_time}}可以分别加载出文章的标题,内容,时间(对应自己创建的模型)

完成后通过‘127.0.0.1:8000/HelloDjango/article/’ + 文章的id 就可以访问指定的文章

如127.0.0.1:8000/HelloDjango/article/1 访问新建的第一篇文章:

2018年3月28日:开源日报第20期

了解更多,欢迎访问(别着急,后面有彩蛋)

GitHub:https://github.com/django/django

官网: https://www.djangoproject.com/

 

彩蛋:

关于吉他手Django Reinhardt

法国著名吉他手,爵士乐史上的伟大琴师。1910年出生于比利时,

因18岁时一次意外导致只能以三个健全手指进行演奏,但仍然创造了传世的音乐作品

和令人赞叹的成就。1953年在法国去世。

2018年3月28日:开源日报第20期

今日推荐英文原文:《Becoming a 10x Developer》作者:Kate Heddleston

原文链接:https://kateheddleston.com/blog/becoming-a-10x-developer

推荐理由:这篇文章的副标题其实叫做 10 Ways to be a Better Teammate;成为一个好搭档的10种方法。一个好的球星不仅自己是一个很棒的球员,同时也一定是一个很好的助攻,以团队协作来看,好的搭档可谓难得,现在的软件工程以及开源协作都对互相配合提出了很高的要求,好的互助事半功倍、互相拆台则事倍功半,不仅学会自己成为一个好程序员,同时学会成人之美,成为一个好的搭档,也各位重要。

Becoming a 10x Developer

2018年3月28日:开源日报第20期

When I was first learning to play water polo, a coach told me something I’ve never forgotten. He said, “Great players make everyone around them look like great players.” A great player can catch any pass, anticipating imperfect throws and getting into position. When they make a return pass, they throw the ball so that the other person can make the catch easily.

Software engineering today is a team sport; like water polo, you can’t build incredible software systems alone. So when I first heard the concept of the 10x engineer, I was confused. How could someone be so talented that it overshadows the power of teamwork? In my experience, individual excellence is necessary, but not sufficient, for greatness. Focusing purely on individual achievement misses the larger picture that teams are required to build great software. So I decided to change the definition of a 10x engineer to this:

A 10x engineer isn’t someone who is 10x better than those around them, but someone who makes those around them 10x better.

Over the years I’ve combined my personal experience with research about building and growing effective teams and turned that into a list of 10 ways to be a better teammate, regardless of position or experience level. While many things on this list are general pieces of advice for how to be a good teammate, there is an emphasis on how to be a good teammate to people from diverse backgrounds.

10 Ways to be a Better Teammate

  1. Create an environment of psychological safety
  2. Encourage everyone to participate equally
  3. Assign credit accurately and generously
  4. Amplify unheard voices in meetings
  5. Give constructive, actionable feedback and avoid personal criticism
  6. Hold yourself and others accountable
  7. Cultivate excellence in an area that is valuable to the team
  8. Educate yourself about diversity, inclusivity, and equality in the workplace
  9. Maintain a growth mindset
  10. Advocate for company policies that increase workplace equality

1. Create an environment of psychological safety

In 2012, Google launched Project Aristotle to study hundreds of Google teams and figure out why some teams performed better than others [1]. The study found that there were only two key differences between more productive teams and less productive teams. One of those two the key components was something researchers call Psychological Safety. Harvard Business School professor Amy Edmondson described it as a “shared belief held by members of a team that the team is safe for interpersonal risk-taking” and “a sense of confidence that the team will not embarrass, reject or punish someone for speaking up.” [1] Creating an environment of psychological safety creates a space where team members can trust one another and share their opinions and ideas about work freely. Here are some ways to foster an environment of psychological safety within your own workplace.

  1. Acknowledge people’s ideas and feelings in a non-judgemental way. Acknowledgment is a separate step from judging or assessing.
  2. Respond to ideas with a “yes and” attitude to build off what your teammates say (like in improvisational comedy!) [2].
  3. Give people the benefit of the doubt. Believe them until proven otherwise, as opposed to making them prove themselves until you believe them.

2. Encourage everyone to participate equally

Project Aristotle, the research study on effective teams at Google [1], found one other important component for productive teams. It’s a phenomenon that the academic world has named ‘‘equality in distribution of conversational turn-taking.’’ Basically, this just means that people on effective teams participate equally. This doesn’t mean that people have to speak equally in every meeting, but that, over time, everyone on a team will contribute equally. So how can you foster a team culture in which everyone participates equally?

  1. Ask people their opinions in meetings.
  2. Invite discussion with your language by using words like “I think” and “maybe”. (I call this conversational style: “Maybe you should talk more like a woman?”)
  3. Communicate frequently and informally [3].
  4. Notice when someone else might be dominating a conversation and make room for others to speak.

3. Assign credit accurately and generously

Giving credit to people accurately for their work is an important part of establishing trust in a team and organization [4]. Many of us have had a personal experience where we felt like we didn’t receive credit for our work, or credit was given to the wrong person.

One of the great things about giving other people credit is that it doesn’t just make the other person look good, it also makes you look good. People who acknowledge others are seen as both smarter and more likable by other people. Basically, it’s a win-win and there’s no reason to hold back in your praise of others.

What can you do to help foster a culture where people assign credit to others for their work?

  1. Make sure you take time at the end of each project to thank the people who helped you.
  2. Especially try to notice people who are quiet and don’t do much self-promotion, or people who are new and lack confidence.
  3. Be honest, specific, and genuine when assigning credit and praising others’ work.

4. Amplify unheard voices in meetings by repeating what they say

None

In 2009, a group of President Obama’s female staff banded together and devised a strategy they called “amplification” [5]. They were experiencing a lot of the things women face in male-dominated workplaces—they were having trouble getting into important meetings and, when there, were often overlooked or unheard. So they would amplify each other’s voices. When a female staffer made a key point, the other women would repeat it and give credit to the author, which forced everyone to notice where the idea came from. President Obama himself noticed this and made a point to call on more female staffers more. By his second term, there was an even gender split and half the departments were headed by women.

This is such a simple, concrete thing that any person on any team can do for their teammates. Notice when people are overlooked or unheard and amplify what they say. While it’s common for women to be spoken over [6], it can also happen to people who are soft-spoken, shy, or introverted.

5. Give constructive, actionable feedback and avoid personal criticism

People pretty universally dislike being criticized and, when not given thoughtfully or constructively, criticism can actually damage people’s performance [8]. I’ve talked about this before, but making sure that your feedback is thoughtful and constructive is a really important way you can be a great teammate. Additionally, the way we give feedback can be biased, so spending time learning to give feedback well is important for diverse teams.

For example, there’s a common perception that women receive criticism that men don’t. Women report being called “bossy”, “pushy”, and “aggressive” more than their male peers. In 2014, Kieran Snyder, founder and CEO of Textio, decided to test that idea [7]. She collected 248 reviews from 180 people, 105 men and 75 women, and analyzed the contents of those reviews. What she found was surprising, even if you know it’s there. Of the women’s reviews, 87.9% percent contained criticism or negative feedback as opposed to 58.9% of men. Furthermore, the criticism given to men and women wasn’t the same. Of the criticism women received, 76% of it was personal in nature as opposed to 2% of criticism given to men.

Here are some ways you can give better feedback.

  1. Ask people if they’re open to feedback before giving feedback.
  2. Focus your feedback on the person’s work as much as possible.
  3. Tell people how they can make things better. Clearly identify the issue as you see it and explain how you think the person can make things better.
  4. Avoid personal criticism. If you feel that you need to give someone feedback on their person, work with a manager or HR to make sure that you have your thoughts organized.

6. Hold yourself and others accountable

Recently I met with a friend of mine, James, who was a football player in college. He’s now the COO of a startup, and he mentioned that he was spending a lot of his time teaching what he considered basic teamwork to employees, especially around accountability. As I thought about it more, I realized that James has spent thousands and thousands of hours practicing being a good teammate. Things that are obvious to him about working well as a team might not be obvious to others, especially when it comes to accountability. Football has a strong culture of accountability, and some of the ways football players hold each other accountable are through being on time to practice, having a positive attitude, encouraging teammates, and holding each other to a standard of excellence. Here are some ways you can hold yourself and others accountable.

  1. Get your work done as on-time as you can (I know as engineers estimates are one of our biggest challenges, but smaller projects with more accurate estimates help foster accountability).
  2. Jeff Lawson once told a group of founders that the most important thing is “doing what you say you’ll do”.
  3. Help others, and ask for help when you need it.
  4. For big projects or issues, stay present until your team’s work is finished [9] (whether that presence is in-person or through remote tools like Slack).

7. Cultivate excellence in an area that is valuable to the team

When we talk about being a 10x engineer, this is usually what people are referring to—individual excellence. Individual excellence is a necessary part of being a good teammate. After all, you need to do something for your team. What you choose to become excellent at is really about what motivates you; it should be something that gives you energy and fits your skills and interests. Excellence takes a lot of time and energy to cultivate, especially as our individual knowledge base is becoming more and more specialized [10], so pick something you enjoy doing because you’ll probably be at this a while. I feel that individual excellence is harped on a lot in our society, so I’ll let you read the slew of self-help books and blog posts out there on how to be more excellent at your craft.

8. Educate yourself about diversity, inclusivity, and equality in the workplace

None

Diversity and Inclusion is a team sport—we need everyone at every level to participate. One of the number one things you can do to be a good teammate is to educate yourself about how gender and race discrimination take form in the workplace. In the same way that you need to stay educated on programming languages and tooling, it’s important to stay up to date on all the amazing writing and research about how to create more egalitarian work environments.

There is a joke that “behind every woke man is an exhausted feminist”, and probably behind every woke white person is an exhausted person of color. Let’s change that. Anyone can read and do research.

  1. Read everything
  2. Ask people for reading suggestions or join mailing lists
  3. Listen as much as you can
  4. Your opinion is as valuable as your education, so if you have not educated yourself, your opinion is not valuable.

9. Maintain a growth mindset

Thirty years ago, psychologist Carol Dweck was interested in the concept of failure and resilience [11]. She and her research team noticed that some students rebounded from failure while others were demoralized even by small setbacks. She wanted to know why. After studying thousands of children, she coined the term Growth Mindset, which refers to the belief that abilities and intelligence can be developed. Students who believe that they can increase their abilities and intelligence rebound from failure, while students who believe intelligence is fixed are more likely to be demoralized by setbacks.

  1. Remember you can learn anything given time, effort, and the internet.
  2. Be prepared for feedback on how you can improve.
  3. There is no finish line; being a great engineer and a great teammate is a lifelong, daily practice.

10. Advocate for companies policies that increase workplace equality

None

Finally, speak up about ways you think your company can create a more egalitarian, inclusive workplace for every member of your team. No matter what your level within the organization, you can advocate for policies that will improve your work environment. Reading and doing research per recommendation #8 will make this step a lot easier. Some examples of organizational changes that have proven effects are:

  1. The Rooney Rule: for any key position, you have to interview at least one person of color for the role [12]
  2. Evaluate candidates in groups for promotions [13]
  3. Making meetings, salaries, key initiatives, and internal processes more transparent.

 


每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,欢迎关注开源日报。交流QQ群:202790710;电报群 https://t.me/OpeningSourceOrg