Points must know as a Django Developer. Else you may get Fired.
Hi Dev👏, Here are some things you must use in Django Projects if you are working with Experienced Team Members.
Application Name or Module Name Styling
Modules or Applications should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.
Example: chat, products, users, notifications.
Model Style
Field names should be all lowercase, using underscore instead of camel case.
Do this:🟢
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=40)
Don’t do this:🔴
class Person(models.Model):
FirstName = models.CharField(max_length=20)
Last_Name = models.CharField(max_length=40)
The class meta should appear after all the fields are defined with a single blank line separating the fields and the class definition.
Do this:🟢
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=40)class Meta:
verbose_name_plural = 'people'
Don’t do this:🔴
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=40)
class Meta:
verbose_name_plural = 'people'//orclass Person(models.Model):
class Meta:
verbose_name_plural = 'people'first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=40)
View Style
In Django views the first parameter in a view function should be called request.
Do this:🟢
def my_view(request, foo):
# ...
Don’t do this:🔴
def my_view(req, foo):
# ...
If you know more tips let me know in the comments i will add them in the post with Credits😁. It will save someone from getting fired.
Stay Tuned and I will see you in the next one👋🏻.
Thanks for Following and Claps👍!