Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango Updating var on file depending of a model
    primarykey
    data
    text
    <p>I have a file whose contents depends on a model. Bizarre thing : when updating the model's data, it does not directly reverberate on the variable on that file! I was forced to restart my dev server to have the new data.</p> <p>As a solution I used 'reload' to reload the module containing the variables in question! I think it's not the good way to do that (reloading after every update) to be able to see the data. </p> <p>Is there any way to update and see data directly without reloading?. </p> <p>Here is my code: <a href="http://pastebin.com/97BPqh0L" rel="nofollow">http://pastebin.com/97BPqh0L</a> I had a commentary at the reload section</p> <pre><code># parametres/conf.py from .models import ConfigApp if ConfigApp.objects.exists(): config = ConfigApp.objects.all()[0] else: config = None EMPLOYE_BY_COMPAGNY = config.user_compagnie if config else 7 ANNONCES_LIFETIMES = config.annonce_days if config else None IMAGE_SIZE = config.taille_image*1024 if config else 102400 #####################################################" # compte/admin.py from societe.models import Compagnie from .forms import EmployeAdminForm,NewEmployeAdminForm from django.contrib import admin from django.contrib.auth.models import User,Group import parametres.conf class EmployeAdmin(admin.ModelAdmin): list_display = ['user','identite','email','societe','is_active'] list_filter = ('is_active','societe') form = NewEmployeAdminForm search_fields = ("user__username",) user_obj = None def has_add_permission(self,request): reload( parametres.conf) #here reloading if request.user.is_superuser or request.user.groups.filter(name='admin').exists(): return True elif request.user.groups.filter(name='client').exists(): if Gestionnaire.objects.filter(employe__user=request.user,is_active=True).exists(): employe = request.user.employe_set.all()[0] if Employe.objects.filter(societe=employe.societe).count() &gt;= parametres.conf.EMPLOYE_BY_COMPAGNY: return False return True return False </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload