BLOG

A LITTLE STORY ABOUT MY JOURNEY

Django get current user globally in the project

Sometimes, you will need to get the current authenticated user in models, or other parts of your app. To achieve this, you must create this middleware in your app(middleware.py) and add it to MIDDLEWARE_CLASSES in project settings: ‘myapp.middleware.GlobalUserMiddlware’

Use Example:

Refrence: http://simionbaws.ro/programming/python-programming/django-python-programming/django-get-current-user-globally-in-the-project/

Check if user belongs to a group in django templates Templatetags

So here comes a simple template filter which checks if the user belongs to a given group. It can be easily extended to take into account more groups. – See more at: http://www.abidibo.net/blog/2014/05/22/check-if-user-belongs-group-django-templates/#sthash.i1cF0nIZ.dpuf

And in your template you can use it this way:

         

Django Model Form Validation

Django model form automatically validate own form while we create form, but some time we add extra field and need validate customisation at this time need to call validation function “clean” for this type of conditions, i have try with following code, you can also try :

Django Model Admin get_list_display_links

While we need links on different column we can use “get_list_display_links” function default given by Django framework and we simply define links with condition also like:

🙂

Wocommerce wpse45436_posts_filter with multiple meta_key

Default Wocommerce provide basic function for search result when we want more thins to search we can customise wocommerce function by hook or add_action, Now I want to add filter order by product name and order_type field by customising the “restrict_manage_posts” like:

  By this customisation we can successfully visible and now need to […]

1 2 3 4 5 10