#django

/

      • HowardwLo
        ah ya, i did a search for long_url, it showed up under @permalink
      • @models.permalink
      • atula has quit
      • dman777_alter has quit
      • Nirgal1
        django has so many great features, using the orm will simplify my life for all the other components like forms and so on.
      • HowardwLo
        no sure where that came from ..
      • sweet it works now
      • munichlinux joined the channel
      • bkuberek joined the channel
      • Nirgal1
        back to the source then, thank you anyways.
      • mattmcc
        Nirgal1: Except it's not simplifying your life, is it? :) The ORM isn't about building SQL, which is why you're having trouble making it be that way. Joins are created automatically based on the relationships between models and the filters you use.
      • There is a concept of model inheritance, but it probably doesn't use the same DB schema to accomplish it as SQLAlchemy.
      • bkuberek has quit
      • HowardwLo
        hmm…so the site maps show example.com/product/coconuts, but i don't see example.com declared anywhere in my settings. do they use example.com if its localhost or something?
      • mattmcc
        It's the initial sites.Site instance that gets created.
      • Nirgal1
        I have a table describing "extra fields" and a another table with the values. So I have dynamic relationships. I'd like to fetch everything in a single query. If someone has ideas about how to do that the django way ....
      • hoot joined the channel
      • mattmcc
        If it was one table of key, value, it'd sound like an EAV setup.
      • Mind pasting what the tables look like?
      • codeitloadit joined the channel
      • dfunckt has quit
      • bkeating_ has quit
      • glosoli joined the channel
      • Nirgal1
      • HowardwLo
        mattmcc: It's the initial sites.Site instance that gets created. was that to me?
      • mattmcc
        HowardwLo: Yeah. See /admin/sites/site/
      • HowardwLo
        mattmcc: thanks
      • codeitloadit has quit
      • iqualfragile has quit
      • jangoh joined the channel
      • robbyoconnor has quit
      • robbyoconnor joined the channel
      • arphen joined the channel
      • Nirgal1
        regarding inheritance, it's only on the python side: ContactField is now dynamically converted in ContactFieldChoice ContactFieldDate and so on. Theses "fields" knows how to validate data, how to generate a forms.field, what comparaison operators are available and so on ...
      • arphen
        Hi, how do I into sendmails? http://pastebin.com/y781wCPJ
      • i have added
      • mattmcc
        Nirgal1: So, as it stands with the ORM, you could get a single query if you started from contact_field_value. E.g, ContactFieldValue.objects.select_related('contact', 'contact_field')
      • Starting from Contact, you could do it in two queries with prefetch_related.
      • arphen
        i have added EMAIL_BACKEND etc to settings
      • mattmcc
        (Since Contact is on the 'one' side of the FK with ContactFieldValue)
      • zhost has quit
      • hairy joined the channel
      • If changing the DB schema is an option, you might find django-eav interesting. http://mvpdev.github.io/django-eav/
      • Though I'm not sure it has a way to substitute your own attribute models to add, e.g, contact_group or sort_weight.
      • rafaqueque has quit
      • breno joined the channel
      • Ariel_Calzada joined the channel
      • foofoobar has quit
      • valgrind has quit
      • sedeki has quit
      • Nirgal1
        The user can customize its contact list view. I have like 30 fields and many contacts. The user might want a list of contact (optionally in a contactgroup) with the name, the phone, the email and the favorite drink, lets say field_id in [1,4,29]. I did the job with left joins in raw queries, but then I can't have the order_by that is added later ... And I need slicing for pagination. So I'm still planing to analyse the query class now, with all the nice join,
      • gazumps joined the channel
      • jangoh has quit
      • dfunckt joined the channel
      • bkeating_ joined the channel
      • breno has quit
      • pinatay joined the channel
      • chrisramon joined the channel
      • Auv has quit
      • Auv joined the channel
      • I need a kind of Contact.objects.select_related('contact_field_value' as field_1 where field_id=1).select_related('contact_field_value' as field_42 where field_id=42)
      • munichlinux has quit
      • moneydouble joined the channel
      • LucSaffre joined the channel
      • HowardwLo
        would you run into any problems if your url is domain.com/<wildcard>; ?
      • dfunckt has quit
      • wildcard might be a product SKU or something
      • you just gotta put it at the end of urls right?
      • redShadow joined the channel
      • mattmcc
        If it was the last pattern in your list, it would be likely fine. But I'd recommend some sort of prefix anyway, even if it's just '/p/'
      • FunkyBob
        doesn't have to be at the end...
      • moneydouble
        FunkyBob: wazup man. Live chat!
      • lol
      • FunkyBob
        ?
      • mattmcc
        Nirgal1: Because it's a many-to-one, select_related can't inner join to contact_field_value (And the ORM doesn't generate left joins that aren't left outer joins, afaik). That's where prefetch_related comes in.
      • pinatay has quit
      • bkuberek joined the channel
      • bkuberek has quit
      • ehmatthes joined the channel
      • the_rat_ joined the channel
      • ghostlines has quit
      • cardboard has quit
      • the_rat has quit
      • alexsnake joined the channel
      • coolnewb has quit
      • cfoch joined the channel
      • natea has quit
      • HowardwLo
        i want to do some funny messages in my url, like website.com/has/neat/<productname>;. and i was wondering if i can write it in a way where i could change that message every now and then, so website.com/doesnt/want/<productname>;, but I don't want to break the previous urls. is this possible?
      • z0ran has quit
      • cewing has quit
      • bahamas has quit
      • I'm thinking has/neat would be a RedirectView to whichever url message is current :)
      • FunkyBob
        HowardwLo: you could have anything in there, and ignore it, if you like
      • HowardwLo
        FunkyBob: how you mean?
      • FunkyBob
        r'^(:.+)/(?P<slug>[-\w]+)/$'
      • optixx has quit
      • optixx joined the channel
      • Nirgal1
        HowardLo: I have followed your discussion, but url.py is treated sequentially (very usefull if static_url is '/') so you can have a catch all at the end of that file maybe ?
      • johnkevinmbasco joined the channel
      • marlinc joined the channel
      • dfunckt joined the channel
      • chrisramon has quit
      • snurfery joined the channel
      • trbs has quit
      • HowardwLo
        FunkyBob: oh
      • Nirgal1: what do you mean by catch all at the end?
      • notleigh joined the channel
      • munichlinux joined the channel
      • the_rat_ has quit
      • pydonny joined the channel
      • FunkyBob: are there any cons to using this method?
      • also, i changed it to (.+) instead of (:.+), is that what you meant? :)
      • cfoch
        is it possible to have two or more forms in the same view?
      • pydonny has quit
      • and manage them with an only one same submit in the tempalte?
      • santiissopasse joined the channel
      • Andy80 has quit
      • Andy80 joined the channel
      • munichlinux has quit
      • santiissopasse has quit
      • jcool joined the channel
      • ehmatthes has quit
      • moneydouble
        FunkyBob: the live chat thing, you told me to keep telling you about it. :P
      • Andy80 has quit
      • hairy has quit
      • mattmcc
        HowardwLo: Yes, it creates an arbitrary number of URLs which point to the same thing. Aside from being bad architecture, search engines don't like it. Although you can compensate for the search engine issue with rel=canonical
      • cfoch: Yes.
      • HowardwLo
        what makes it bad architecture?
      • or….what does bad architecture mean
      • hairy joined the channel
      • zeograd has quit
      • cfoch
        mattmcc:
      • so...
      • formA = MyFormA(request.POST)
      • formB = MyFormB(request.POST)
      • and... Django knows what to set in A and what to set in B
      • mattmcc
        Web architecture. A resource should have one authoritative location. http://www.w3.org/Provider/Style/URI.html
      • cfoch: It will set whatever matches. This does mean that field names might collide, which is why forms have a prefix argument. E.g, MyFormA(data=request.POST, prefix='form_a')
      • santiissopasse joined the channel
      • bkuberek joined the channel
      • somniac joined the channel
      • ticketbot has quit
      • ticketbot joined the channel
      • FunkyBob
        moneydouble: oh, right... of course :)
      • cfoch
        mattmcc: thanks
      • ;)
      • jaddison joined the channel
      • FunkyBob
        moneydouble: weren't you going to do something about the UI?
      • HowardwLo
        mattmcc: what would you suggest if i wanted to include prefixes that I would like to change from time to time?
      • mattmcc
        I would suggest not changing URLs for fun.