from django import template
from django.conf import settings

from generic_scaffold import get_url_names

register = template.Library()

@register.simple_tag
def get_url_for_action(prefix, action):
    url = get_url_names(prefix)[action]
    return url

@register.assignment_tag
def set_url_for_action(prefix, action):
    url = get_url_names(prefix)[action]
    return url

from django import template
from django.conf import settings

from generic_scaffold import get_url_names

register = template.Library()

@register.assignment_tag
def set_urls_for_scaffold(app=None, model=None, prefix=None):
    url_name = get_url_names(app, model, prefix)
    return url_name

Improve templatetag to use either prefix or ...
Improve templatetag to use either prefix or ...

app/model

  from django import template
  from django.conf import settings
  
  from generic_scaffold import get_url_names
  
  register = template.Library()
  
- @register.simple_tag
+ @register.assignment_tag
- def get_url_for_action(prefix, action):
-     url = get_url_names(prefix)[action]
+ def set_urls_for_scaffold(app=None, model=None, prefix=None):
+     url_name = get_url_names(app, model, prefix)
-     return url
+     return url_name
  
- @register.assignment_tag
- def set_url_for_action(prefix, action):
-     url = get_url_names(prefix)[action]
-     return url
- 
Improve templatetag to use either prefix or ...
## Code Before:
from django import template
from django.conf import settings

from generic_scaffold import get_url_names

register = template.Library()

@register.simple_tag
def get_url_for_action(prefix, action):
    url = get_url_names(prefix)[action]
    return url

@register.assignment_tag
def set_url_for_action(prefix, action):
    url = get_url_names(prefix)[action]
    return url

## Instruction:
Improve templatetag to use either prefix or ...
## Code After:
from django import template
from django.conf import settings

from generic_scaffold import get_url_names

register = template.Library()

@register.assignment_tag
def set_urls_for_scaffold(app=None, model=None, prefix=None):
    url_name = get_url_names(app, model, prefix)
    return url_name
