how would i want to try and store a users last search requests from a page, say they do some filtering on a listing page, click for details, then go back to the list page - I want the most recent filtering to be applied
zhalla_ has quit
jdo_dk
session ?
fission6: ^
fission6
and how would i store that kind of info in the session framework
knbk
you can store anything that's json serializable
jdo_dk
You can store anything in sessions.
fission6
i am asking how would i want to store the last search info, what would be your approach
knbk
fission6: how are the search parameter passed to the page? GET parameters?
fission6
yes
jdo_dk
then in your view, you do something like: request.session['search_param_1'] = request.GET.get('search_param_1')
knbk
I'd do something like request.session['my_session_key'] = request.GET.dict()
andrkavr
knbk: you're right, sorry, missed those two lines.
fission6
ya, and then wouldn't i want the reverse to actually use the settings
(settings = search params)
or maybe some kind of redirect
rajalokan has quit
rajalokan joined the channel
andrkavr has quit
mtellez joined the channel
jdo_dk
fission6: Then you do "reverse" when page is loaded "second" time, if request.GET.get('search_param_1') is empty, you will see if you have a value in session etc...
fission6
ok will review
could i also just do a redirect to a new url with the querystring and clear the session setting
govg joined the channel
Ryanar joined the channel
knbk
fission6: if you're doing a redirect you could save the original query string, request.META.get('QUERY_STRING', '')
fission6
in the session right?
knbk
yeah, in the session
fission6
i was thinking that and if its a session variable the clear that key and redirect to the value
would be pretty simple to acheive the idea of, show the last filtering
Troy1 joined the channel
kristian__ has quit
roomcayz joined the channel
Biwaa joined the channel
fury__ is now known as fury_
lukebigg joined the channel
morenoh149 joined the channel
morenoh149
morning
Biwaa has quit
lorddaedra has quit
OskrGrme joined the channel
zivester joined the channel
giarc joined the channel
lucasxu has quit
epopt joined the channel
Biwaa joined the channel
giarc has quit
eperzhand joined the channel
xliiv joined the channel
jdo_dk
Moin
Biwaa has quit
gugah joined the channel
giarc joined the channel
felixx has quit
jdo_dk has quit
VaticanCameos joined the channel
lamduh joined the channel
frankspank joined the channel
frankspank has quit
frankspank joined the channel
plfiorini joined the channel
frankspank has quit
cuci joined the channel
pathrocle has quit
Biwaa joined the channel
milardovich joined the channel
happylappy joined the channel
Biwaa has quit
emihir0 joined the channel
milardovich has quit
scunion joined the channel
rpkilby joined the channel
jhfisc joined the channel
emihir0
hi folks, I have a really strange problem... https://dpaste.de/m9MS it literally says that it has tried the path, yet apparently it was not found (matched)
I’m really confused about Django ORM foreign key and relational database schema design. If i take this example http://www.1keydata.com/sql/sql-foreign-key.html and do python manage.py inspectdb it will create an Orders model class with an field customer_SID for our foreign key.
jhfisc joined the channel
However in Django it seems like that foreign key should be in the Customer class? For example http://www.yilmazhuseyin.com/blog/dev/django-or... shows that Employee has a field department that’s a foreign key to access department related objects.
from the second example it just seems like the foreign key field should be in the Customer class not the Orders class?
the way it's done in SQL and django ORM seems reversed which confuses me
jhfisc has quit
milardovich has quit
if you were going to design a relationship between the two and write the models, would you write the foreign key field in the Customer or the Orders class?
or i guess it depends on what you're trying to access first?
knbk
Frenchiie: An Order can have a single Customer, so the foreign key would go in the Order class. This creates a field in the order table that can hold a reference to a single customer row
so that's just like the customer_SID field
Just like an Employee belongs to a single Department, so the ForeignKey would go in the Employee class
mitaka has quit
techno_x64 joined the channel
DrYockel joined the channel
Frenchiie
knbk: yeah i guess that makes sense
OskrGrme has quit
lamduh joined the channel
i'm just curious if an Employee were to belong to multiple department what would be the cost of doing a reverse lookup
knbk
if an Employee belongs to multiple Departments, the relation is wrong to begin with
the employee table has a single column that refers to a department, so an employee can only relate to one department at a time
milardovich joined the channel
lucasxu joined the channel
religious has quit
Frenchiie
knbk: not sure i follow. The department field in Employee doesn't have OneToOneField
knbk: why can't an Employee belong to multiple Departments?
knbk
Frenchiie: That means a department can have multiple employees, but an employee cannot belong to multiple departments