It should be very simple. In your urls.py file you need the url:
url(r'/resource/(?P<resource_name>\w+)', 'app.views.resource_func', name="priv-resource"),
Then you process this in views.py with the function:
def resource_func(request, resource_name):
Finally, you can also use this in your templates using names:
{% url priv-resource string %}
Just make sure in your models.py:
class ResourceModel(models.Model) resource_name = models.CharField(max_size=somelimit, unique=True)
I may be tempted to use a signal handler to create this field automatically after saving the object. See the documentation.
user257111
source share