question about userprofile

2014-10-07 Thread Lorenzo Bernardi

Hello,

I'd like to emphasize that it is probably a newbie question but I
don't know what are the keyword I should use for googling. So any
information would be helpful.

I'm trying to add a userprofile to my django app. The idea is to use
a sign-in system so that the user depending on who is can have access to
certain pages.

I think I understand the login part that is I define a user for my app
and make onetoone correspondance with the user table of django. I didn't
implement that yet but I think it should be easy and well documented.
But after that I don't understand how I can use the information in the
user table (like the pages that the user is allowed to enter) in django
and how to set it somewhere. And also since I should change the menu to
reflect that the user can go or not to one page how can I send this info
to the template.

As I said any help is welcome.

sincerely


L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/543444AE.2050602%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Model to create forms

2015-01-05 Thread Lorenzo Bernardi

Hello All,

  I'm rather new to django and also web and database stuff and so I 
might not use the correct term.


  i need to write an application which is a log book for experiments. 
The purpose is to store information about various experiments on 
different experiment to keep a trace and compute some statistics on the 
experiments.


I have started writing one  app and creating a model for each 
experiments but it is rather a lengthy process and I was wondering if it 
would be possible to


1) offer a form generator for the experiments and store the contents in 
a table defined by a model. It can also be created programmatically (in 
starting python manage.py shell for exemple)
I was thinking using formset to define this form (using 
*django-dynamic-formset 
*)and it will be 
like a recipe thing ( I only need a few items textinput, textarea, date 
and predefined lists)


2) use this form to fill a database of data. (the key idea here is that 
the model for the data will just contain an uid (which will be created 
when the form is submitted) and a datatype and a value)) the many 
information of the forms will be stored as many rows in the database 
table and will be connected by the uid created when the form is 
submitted. It might not be clear but I got this idea from the 
bureaucracy plugin in dokuwiki.


Since this looks rather advanced for my skill I was wondering if
1) there is no other approach (like creating a model on the fly, that is 
not writing in models.py. But it looks against the way django works) and 
any idea is welcomed.
2) Also keeping all the experiments data in only one table and getting 
all the information for one experiment by finding all the row with the 
same uid looks a little bit a time consuming process but for now we used 
the bureaucracy plugin for the last six month and it doesn't look like 
it is slowing down too much the response of the wiki so it might not be 
so inefficient after all. Maybe it will scale badly. Here again any 
advice is welcomed.
3) The data to create the form is stored in a table (as a say, like a 
recipe) and so will it be better to create the form in the views.py or 
in the template (in that case in the view I gather the field definitions 
and then in templates loops through the table and create the widget at 
that time).


Thank for reading up to this point and if you have any suggestion or 
pointers related to this I'll be glad to get them (I mean even if you 
don't answer directly my questions I'm interested of new ideas).


sincerely

L.



--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54A9C2B1.802%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Re: Model to create forms

2015-01-08 Thread Lorenzo Bernardi

Hello,

1) there is no other approach (like creating a model on the fly, that 
is not writing in models.py. But it looks against the way django 
works) and any idea is welcomed.


Generally I've found that creating a real model to store the data is 
easiest in the long run and usually involves less programming.
It definitely looks easier for me to code a model per experiment. But 
I'm writing this app for seomeone else and I foind it will be easier to 
give to this person the opportunity to create by himself the definition 
of the experiment. Of course it means my app should be rather simple to 
make it handle this (adding or substracting field of the form or 
changing things ) without loosing the data and this is where I don't 
know if I can really program this. I'll try with a simpler version and 
look again at our advice after some tests.


2) Also keeping all the experiments data in only one table and getting 
all the information for one experiment by finding all the row with the 
same uid looks a little bit a time consuming process but for now we 
used the bureaucracy plugin for the last six month and it doesn't look 
like it is slowing down too much the response of the wiki so it might 
not be so inefficient after all. Maybe it will scale badly. Here again 
any advice is welcomed.


Databases are usually good at this sort of thing. It shouldn't be a 
problem, but might require some database tuning.



OK.
3) The data to create the form is stored in a table (as a say, like a 
recipe) and so will it be better to create the form in the views.py or 
in the template (in that case in the view I gather the field 
definitions and then in templates loops through the table and create 
the widget at that time).


Again, it's possible to do this, but it's hard. Are all of the fields 
just plain text fields, or are some choice fields?


there are some choice field, and date field but may be I can gather some 
common field in the definition of the experiment.


thanks for the information

sincerely

L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54AEEB58.5080508%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Re: Model to create forms

2015-01-08 Thread Lorenzo Bernardi


Hello,

this is what _relational_ databases are built for.  if you have two
tables, one for the description of the experiment (one record per
experiment), and another for the statistics (one record per data
sample, with a foreign key to the experiment record); then fetching
the description of the experiment, plus all the related data will be
much faster, simpler, more compact and all-around more efficient than
having one table per experiment.
it looks to me that the resulting code should be more compact but more 
difficult to write and maybe too clever for me. I'm writing this code 
for someone who is not completely sure of what he really wants (I mean 
the data that should be stored in the table) and  so the code should be 
able to accept some change in the definition of the experiments without 
breaking the old data.

databases aren't flat files, use them as designed and they'll perform very well.


I agree with that. My main worry is that I'm not so familiar with 
databases and I hope I can estimate if the code will perform well in 
real condition when I'll do some limited tests.


thanks  for the information and I'll give it a try

sincerely

L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54AEEE0B.3020408%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Re: Model to create forms

2015-01-09 Thread Lorenzo Bernardi


On 01/09/2015 10:39 AM, Timothy W. Cook wrote:
I think you are looking for a way to provide an abstraction like this 
http://django-forms-builder.readthedocs.org/en/latest/
yes it looks like I'll have to do something like that. Or see if the 
data collected from the form can be put in a model. Thanks for the pointer.


sincerely

L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/54AFF622.4090802%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


template or javascript

2016-10-10 Thread Lorenzo Bernardi

Hello,

  I'm making a website with bootstrap and I use some menu items (in 
fact nav bars) and I was wondering what is the best practice to make a 
menu item highlighted when I am on the page connected with this menu 
item. I mean in bootstrap the nav bar has a  to 
highlight the fact that I'm on this page. I was wondering if I should 
use django context to give the information and set in the template {% if 
currentpage="home"  %} class="active" {% endif %} or if I should use 
some javascript code to look in which page I am and set the 
class="active". Sorry if this is not the correct mailing list to send 
this question but I don't know where to start looking so any information 
is welcome (for exemple if there is standard practice for this kind of 
things can someone give me some input?)



sincerely


L

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d3b54695-ecfd-afc6-26fc-0cb5adb5f31d%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


interaction between two django app

2017-01-24 Thread Lorenzo Bernardi

Hello,

  I don't know what is the best approach for the communication between 
two django applications.


  We have a website using django and django-cms. We have another 
application, the "seminar" app for managing some informations like 
seminars, news,  people profiles They have both their databases and 
are on different server. Now we would like to take some information from 
the "seminar" appli and show them on the website. My question is how to 
retrieve the data from the seminar app. We are developping both 
applications so we can do whatever we want but for now we would like to 
keep them separated. To display the information on the website I was 
thinking of using template tags to gather the information and send them 
to the page and I see 3 different ways to do access the information.


   1) consider the distant database as a simple database and perform 
queries in SQL.


   2) use the models.py file of the seminar app (or use inspectdb) and 
use database router to gather the information from the distant database 
mode.


   3) make a REST api of the seminar application ( I have no idea how 
to do that and perhaps it is not the correct approach)


My main concern is that I'm in charge of the website part but not the 
seminar part and this one may evolve without me knowing it and so I'd 
like to be resilient to a change in the seminar app that doesn't modify 
the fields I'm using. I mean the seminar app may have other models but 
normally the seminar part should not change.


May be my question is not clear but I would like to know if other people 
have this kind of setup one django app feeding another one and how did 
they solve this problem.


sincerely.

L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/46339c58-d15d-6db0-4c36-39045e6f1d74%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Questions about session

2016-01-26 Thread Lorenzo Bernardi

Hello,

  I'm writing an app which needs authentication and I was wondering if 
the information about the user should be put in request.session. My app 
deals with the access to certain equipments and every user has a 
different set of equipment it can sees. Should I put the list of 
equipment in the session or should I compute each time I access a view 
or a form in creating a method in the my_app_user class which compute 
the rights by quering the database. Session might not be the best option 
because it keeps data so that a user can still have access even if it 
has been deleted.


My problem is in fact with the templates because once a user is logged 
the interface should show the equipment the user can access as a menu 
and so I should have the information available in the template 
(typically the base template). In that case the request.session can be a 
good option since I can check if the user has the right to access the 
equipment or not.  If I'm not using request.session it looks like I have 
to send the data for each views. Or is ther any other options?


Sorry if the questions is too silly but I haven't found any information 
for that kind of problems which looks rather common and so if you can 
send me any pointer I'm really interested. It might be more general than 
django perhaps. I mean session are used everywhere.


Sincerely

L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56A7EDCC.1060407%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Re: Questions about session

2016-01-27 Thread Lorenzo Bernardi

Hello,



I answered a very similar question to this a few days ago: 
https://groups.google.com/forum/#!msg/django-users/L3pUwDYs6jw/bSYVs81tEwAJ 



thanks for the link. I agree with you for the fact that updating session 
might be a problem because it should be done for each views explicitely. 
It seems that in fact django does it by itself on each request (and I 
didn't know that). My problem is that I have to use a custom user models 
because of extra information and permissions. You seem to imply that in 
the case of a custom auth backend I might have to use the 
request.session variable. I do a custom authentication because the way 
the password is computed in the external application I'm taking the info 
is not the same as django'one but it looks like the way to go is to 
extend the login() function of django.contrib.auth to add the 
information I need in the template.


TL;DR; You can keep everything in the session if you want, but its a 
ton more work and probably error prone. Django's approach is a fresh 
batch of data calls every time.
Better stick to this philosophy then and understand how to add 
information to request.user.


thanks,

L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56A8B032.2080405%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.


Re: Questions about session

2016-01-27 Thread Lorenzo Bernardi

Hello,


If you wish to keep some data always visible specially i the base 
template, then why not make the base template a single page app and 
then through ajax lode other pages?


I thought of using ajax but I'm not very familiar with it. But I didn't 
think of making the base page a single app. I'll look for that.



You can also use angular.js for such work.


Here again I'll have a look at it.


happy hacking.


thanks,

L.

--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/56A8B0DA.60808%40lpn.cnrs.fr.
For more options, visit https://groups.google.com/d/optout.