<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Readul Hasan Chayan [Heemayl] (Posts about authentication)</title><link>https://heemayl.net/</link><description></description><atom:link href="https://heemayl.net/categories/authentication.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2024 &lt;a href="mailto:me@heemayl.net"&gt;Readul Hasan Chayan [Heemayl]&lt;/a&gt; 
&lt;a rel="license" href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank"&gt;
&lt;img alt="Creative Commons License BY-NC-SA"
style="border-width:0; margin-top: 10px; margin-bottom: 5px;"
src="https://i.creativecommons.org/l/by-nc-sa/4.0/88x31.png"&gt;&lt;/a&gt;
</copyright><lastBuildDate>Thu, 07 Mar 2024 19:03:10 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Django: Custom User model without username field (and using email in place of it)</title><link>https://heemayl.net/posts/django-custom-user-model-without-username-field-and-using-email-in-place-of-it/</link><dc:creator>Readul Hasan Chayan [Heemayl]</dc:creator><description>&lt;div&gt;&lt;p&gt;Django by default uses the &lt;code&gt;username&lt;/code&gt; field for authentication purposes of a user, but it's becoming a common trend to use &lt;code&gt;email&lt;/code&gt; field for that purpose. As &lt;code&gt;email&lt;/code&gt; identifies a user uniquely, the idea of an additional &lt;code&gt;username&lt;/code&gt; field can be somewhat dropped. Also, the &lt;code&gt;email&lt;/code&gt; can be used in the places where a &lt;code&gt;username&lt;/code&gt; can be used, so it does not break any internal identification structure as well.&lt;/p&gt;
&lt;p&gt;&lt;em&gt;In the later sections, when I mentioned the (default) &lt;code&gt;User&lt;/code&gt; model please think of the &lt;a href="https://github.com/django/django/blob/master/django/contrib/auth/models.py#L384"&gt;default Django &lt;code&gt;User&lt;/code&gt; model&lt;/a&gt; (&lt;code&gt;settings.AUTH_USER_MODEL&lt;/code&gt;).&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So to make sure we're on the same page, our eventual goal is to get rid of the &lt;code&gt;username&lt;/code&gt; field and use &lt;code&gt;email&lt;/code&gt; field in the &lt;code&gt;User&lt;/code&gt; model for authentication purposes.&lt;/p&gt;
&lt;p&gt;Now, let's check out the usual ways to modify/extend the django &lt;code&gt;User&lt;/code&gt; model:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://heemayl.net/posts/django-custom-user-model-without-username-field-and-using-email-in-place-of-it/"&gt;Read more…&lt;/a&gt; (5 min remaining to read)&lt;/p&gt;&lt;/div&gt;</description><category>authentication</category><category>django</category><category>django_model</category><category>python</category><guid>https://heemayl.net/posts/django-custom-user-model-without-username-field-and-using-email-in-place-of-it/</guid><pubDate>Sun, 23 Jun 2019 09:03:48 GMT</pubDate></item></channel></rss>