godjango

package module
v1.6.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 10, 2023 License: BSD-1-Clause Imports: 11 Imported by: 0

README

Go-Django

A web framework built in Go, inspired by Django. This framework is still in development, and is not ready for production use.

It might still undergo many reworks and breaking changes.

As of now, Go-Django only supports MySQL.

Information

This framework, is built from the ground up, and thus there is a lot of work to be done. It is not a port of Django, but rather a re-implementation of the core concepts of Django, in Go. The default ORM we use is GORM. This is because it is one of the most popular ORM's for Go, and it is very easy to use.

The framework works through interfaces, thus you must add your own implementation for saving models, etc.

Beware! Most of the code is not tested thoroughly, and there could be bugs present. If you find any bugs, please report them in the github issues page.

Rework:

The framework, and mainly the admin site used to have a dependency on GORM.

This has been removed, and it is now up to the Developer to implement a way to save your models.

The admin package has went through a complete rework. To see a full implementation of models in the admin site; have a look at the following files:

  • auth/user.go
  • auth/groups.go
  • auth/permissions.go

It is now also possible to create custom fields for the admin-site forms.

The auth package used to also depend on gorm. This has now also been removed for generated queries by SQLC.

Make sure you have your GOPATH set up correctly.

Installing the project-setup tool
go install github.com/Nigel2392/go-django/go-django@vX.X.X.X

This will install the go-django command-line tool, which you can use to create a new project.

Creating a new project
go-django -startproject <project-name>

This will create a new project in the current directory, with the name you specified. Following that, change into the project directory, make sure you install the latest tag. Our tags are in the format of vX.X.X.X, which might make the go tool struggle. After changing into the project directory, run the following command:

go get github.com/Nigel2392/go-django@vX.X.X.X
go mod tidy

This will install the latest version of the framework, and update the go.mod file. Now you can run the project with the following command:

go run ./src/
Adminsite

In the main file are a few developer credentials registered. These are used to log into the adminsite. You can view the adminsite by going to the <<DOMAIN>>/admin/ url (As specified in config.go).

Finished:

  • Routing
  • Signals
  • Template file system/manager module
  • Media file system/manager module (Reworked)
  • middleware: CSRF protection, Sessions, AllowedHosts
  • Authentication (Reworked)
  • Messages (To the templates)
  • Sending emails
  • Admin panel extensions (Embed your own templates!) (Removed after rework, WIP)
  • Secret keys, secure hashing with secret.Hash and secret.Compare (Repackaged into separate github repository)
  • Command-line flag package
  • Project-setup tool
  • Debug recovery page middleware (Only when running with -debug flag)

In progress:

  • Forms (Repackaged into separate github repository.)
  • Testing
  • Documentation

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Cache

func Cache() client.Cache

func Database added in v1.6.2

func Database() *sql.DB

func Filer added in v1.6.2

func Filer() fs.Filer

func Flags

func Flags() *flag.Flags

func Logger

func Logger() request.Logger

func Mailer

func Mailer() *email.Manager

func Middlewares

func Middlewares(m ...router.Middleware)

func Run

func Run() error

func Serve

func Serve() (http.Handler, error)

func ServeRedirect

func ServeRedirect() error

func TemplateFuncs

func TemplateFuncs(t template.FuncMap)

func Templates

func Templates() *templates.Manager

Types

type App

type App app.Application

func New

func New(c AppConfig) *App

Create a new application.

type AppConfig

type AppConfig app.Config

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL