Skip to main content

Create UL LI html menu from django model queryset.

Project description

Erscimenu

Create UL LI html menu from django model queryset . into your views or your template.

Quick start

Add erscimenu to your INSTALLED_APPS setting like this:

INSTALLED_APPS = [
...,
'erscimenu' ,
]

2.(Optional) Register Ulmenu to admin like this:

from erscimenu.models import Ulmenu
admin.site.register(Ulmenu)

and add your menu into it.

3.Run python manage.py makemigrations and python manage.py migrate to create the Ulmenu models.

4.Use this command to add menu with your views:

from erscimenu.menu import MenuClass
from erscimenu.models import Ulmenu
cl = MenuClass()
clmenu = cl.ulmenu(Ulmenu.objects.all(),None)
return render(request,"index.html",{'model' : model })

Note : 'model' is variable to use in your template.

Model is like this:

class Ulmenu(models.Model):
	title = models.CharField(max_length=100)
	css_class = models.CharField(max_length=100,null=True,blank=True)
	link = models.CharField(max_length=1000,null=True,blank=True)
	parent = models.ForeignKey("self",models.DO_NOTHING,null=True,blank=True) 
	def __str__(self):
		return self.title

4.Run python manage.py runserver Visit http://127.0.0.1:8000 to create users and its cards.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

erscimenu-1.0.7.tar.gz (16.6 kB view details)

Uploaded Source

File details

Details for the file erscimenu-1.0.7.tar.gz.

File metadata

  • Download URL: erscimenu-1.0.7.tar.gz
  • Upload date:
  • Size: 16.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.10

File hashes

Hashes for erscimenu-1.0.7.tar.gz
Algorithm Hash digest
SHA256 25a912f5535c4df7b2626cc9898fd53cfc0b67c5984d9fd7750a24ad0a75bda5
MD5 efcfa4e320173b5f2791053f30c4218e
BLAKE2b-256 3174599cf0bf4c6cc46115a1ac183bc060cbd509474c2eb7d65ba335fa0ecd3c

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page