{"id":17018182,"url":"https://github.com/loitd/djangostarter","last_synced_at":"2026-04-13T16:04:20.082Z","repository":{"id":72977617,"uuid":"155493682","full_name":"loitd/djangostarter","owner":"loitd","description":"djangostarter","archived":false,"fork":false,"pushed_at":"2018-10-31T17:46:56.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-22T16:11:14.264Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/loitd.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-10-31T03:33:16.000Z","updated_at":"2018-10-31T17:46:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"95553a74-93d6-4cd9-9be1-2c9ba7b21da9","html_url":"https://github.com/loitd/djangostarter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/loitd/djangostarter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loitd%2Fdjangostarter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loitd%2Fdjangostarter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loitd%2Fdjangostarter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loitd%2Fdjangostarter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/loitd","download_url":"https://codeload.github.com/loitd/djangostarter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/loitd%2Fdjangostarter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31759576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T15:25:13.801Z","status":"ssl_error","status_checked_at":"2026-04-13T15:25:09.162Z","response_time":93,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T06:44:48.436Z","updated_at":"2026-04-13T16:04:20.065Z","avatar_url":"https://github.com/loitd.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# djangostarter\n`djangostarter` is a template and guide of Django Web Framework using `Django version 2.1` and `Python version 3.6` with `Virtual Environment Wrapper` by Tran Duc Loi at `loitranduc@gmail.com` for his own purposes.\n## Create new project\n```\ndjango-admin startproject mysite\ncd mysite\npython manage.py startapp polls\npython manage.py runserver\npython manage.py runserver 8080\n```\n\n## Git prepare\n```\ncd mysite\ngit remote add origin https://github.com/user/repo.git\ngit remote -v\n```\n## Migrate database\nBy default, `INSTALLED_APPS` contains the following apps, all of which come with Django. These applications are included by default as a convenience for the common case. Some of these applications make use of at least one database table, though, so we need to create the tables in the database before we can use them. To do that, run the following command:\\\n\tpython manage.py migrate\n## Create new models\\\nNew models in `polls/models.py`. Like this:\\\n```python\nfrom django.db import models\nclass Question(models.Model):\n    question_text = models.CharField(max_length=200)\n    pub_date = models.DateTimeField('date published')\n```\n## Activate models\\\nAdd application configures:\\\n```python\nINSTALLED_APPS = [\n\t'polls.apps.PollsConfig',\n```\n## Make the migration\n```python\npython manage.py makemigrations polls\n```\n## Apply the migration\n```python\npython manage.py migrate\n```\n## Create admin\n```python\npython manage.py createsuperuser\n```\nNow, open a Web browser and go to `“/admin/”` on your local domain\n## Make the poll app modifiable in the admin\nTo do this, open the `polls/admin.py` file, and edit it to look like this:\\\n```python\nfrom django.contrib import admin\nfrom .models import Question\nadmin.site.register(Question)\n```\n## Writting more views\nNow let’s add a few more views to `polls/views.py`:\n```py\ndef detail(request, question_id):\n\treturn HttpResponse(\"You're looking at question %s.\" % question_id)\n```\n## Wire these new views into the polls.urls module\nby adding the following path() calls:\n```py\nfrom django.urls import path\nfrom . import views\nurlpatterns = [\n\t# ex: /polls/\n\tpath('', views.index, name='index'),\n\t# ex: /polls/5/\n\tpath('\u003cint:question_id\u003e/', views.detail, name='detail'),\n]\n```\n## Using template to get data\nPut the following code in that template `polls/templates/polls/index.html`:\n```py\n{% if latest_question_list %}\n    \u003cul\u003e\n    {% for question in latest_question_list %}\n        \u003cli\u003e\u003ca href=\"/polls/{{ question.id }}/\"\u003e{{ question.question_text }}\u003c/a\u003e\u003c/li\u003e\n    {% endfor %}\n    \u003c/ul\u003e\n{% else %}\n    \u003cp\u003eNo polls are available.\u003c/p\u003e\n{% endif %}\n```\nNow let’s update our index view in `polls/views.py` to use the template:\\\n```py\nfrom django.http import HttpResponse\nfrom django.template import loader\nfrom .models import Question\ndef index(request):\n    latest_question_list = Question.objects.order_by('-pub_date')[:5]\n    template = loader.get_template('polls/index.html')\n    context = {\n        'latest_question_list': latest_question_list,\n    }\n    return HttpResponse(template.render(context, request))\n```\nin short:\n```py\nfrom django.shortcuts import render\nfrom .models import Question\ndef index(request):\n    latest_question_list = Question.objects.order_by('-pub_date')[:5]\n    context = {'latest_question_list': latest_question_list}\n    return render(request, 'polls/index.html', context)\n```\nRaising 404 error if need:\n```py\ntry:\n        question = Question.objects.get(pk=question_id)\n    except Question.DoesNotExist:\n        raise Http404(\"Question does not exist\")\n    return render(request, 'polls/detail.html', {'question': question})\n```\nin short\n```py\nquestion = get_object_or_404(Question, pk=question_id)\n    return render(request, 'polls/detail.html', {'question': question})\n```\n## Removing hardcoded URLs in templates\n```py\n\u003cli\u003e\u003ca href=\"{% url 'detail' question.id %}\"\u003e{{ question.question_text }}\u003c/a\u003e\u003c/li\u003e\n```\nwith `detail` defined in:\n```py\n# the 'name' value as called by the {% url %} template tag\npath('\u003cint:question_id\u003e/', views.detail, name='detail'),\n```\n## Write a simple form\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floitd%2Fdjangostarter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Floitd%2Fdjangostarter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Floitd%2Fdjangostarter/lists"}