title: Django. how to get a host name for db
body: <p>I'm trying to connect to database:
  in localhost I can do something like this:</p>
  
  <pre><code>db = MySQLdb.connect(host='127.0.0.1', user="root", passwd="", db="schooldb")
  </code></pre>
  
  <p>but in the server I want <code>'127.0.0.1'</code> to be a variable,
  unfortunately </p>
  
  <pre><code>   h = request.get_host()
     return HttpResponse(h)
  </code></pre>
  
  <p>gives me <code>127.0.0.1:8000</code> 
  So my question is how to truncate port and leave only <code>127.0.0.1</code>. Or may be you can suggest something better.</p>
  
  <p>Thank you</p>