Monday, July 1, 2013

Re: Missing peice before best practises



On Monday, July 1, 2013, Tom Evans wrote:
On Wed, Jun 26, 2013 at 10:03 PM, Sayth Renshaw <flebber.crue@gmail.com> wrote:
> This is oddly the only value difference between rails and django is that
> there is far more online courses and tutorials to say "come join rails".

Yep, they say "come join rails", and not "come join Ruby". This
encourages people to look for "rails best practices" and not "ruby
best practices". Conversely with python/django.

Cheers

Tom


Is that good though? 

Barring 2 scoops there is no new material to recognise and guide users to the new features of Django and to get beginner Django developers on board quicker.

It leads to bits of info for each python framework but nothing comprehensive.

Sayth  

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Missing peice before best practises

On Wed, Jun 26, 2013 at 10:03 PM, Sayth Renshaw <flebber.crue@gmail.com> wrote:
> This is oddly the only value difference between rails and django is that
> there is far more online courses and tutorials to say "come join rails".

Yep, they say "come join rails", and not "come join Ruby". This
encourages people to look for "rails best practices" and not "ruby
best practices". Conversely with python/django.

Cheers

Tom

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.

Templatetag variable resolution choices (Python literals)

OK, so I've got a template tag and a corresponding Node class. In order to check the value of two template variables in the Node.render method, I'm using the template.Variable class as specified in the docs. However, I'm wondering if there is any point to this, given the extra lines of code that are required to instantiate the class in the Node.__init__ method, then resolve each of the two variables within separate try-except blocks in case of a template.VariableDoesNotExist error. Given that both the variables are Python literals (boolean and list) and context.get('name', default) works as expected without the extra boilerplate, I'm wondering why it's not a documented way of doing this.

In summary, the following types of variable lookup give identical results when dealing with Python literals -- except that using the context directly removes the need for the try-except block and also eliminates the Django template.Variable checking code, which is redundant in this case:


    class ExampleNode(template.Node):
        def __init__(self):
            self.a1 = template.Variable('a_variable')

        def render(self, context):
            try:
                a1 = self.a1.resolve(context)
            except template.VariableDoesNotExist:
                a1 = False

            a2 = context.get('a_variable', False)


I'll add once again that these variables are simply set in a view context as Python literals.

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: django search query




2013/7/1 Harjot Mann <harjotmann1992@gmail.com>
On Sun, Jun 30, 2013 at 11:18 PM, Amirouche Boubekki
<amirouche.boubekki@gmail.com> wrote:
> You can do this by creating an extra field in the model with the name
> without vowels in it and doing a simple filter on it ? Is that what you need
> ?

I have a search function which is already working in views.py but I
want to refine it.

Is this search function a query like MyModel.objects.filter(usernamename=username, ...) or something more specific ?
 
How can I make a model without vowels??

the most performant solution would be to use re sub but str.replace will work too.
 
And what is django-haystack application?

Haystack is a full text search application, it build an index specific for full text search which means it's not suited for the search you are looking to do (also it takes a lot of memory).
 
Can I use it in my project for refining search or is it a normal searching application?

It depends... can you write a query in the form of MyModel.objects.filter(foo=bar, spam=egg) where you document each fields so that we can know better what your are trying to achieve ? Real data is not significant, but full scope of the problem you are trying to solve is.


 
Amirouche

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Render dynamic form based on meta data

Hi
I am OK with the javascript side (see the attachment) - I am able to take meta data and render a form.
My challange is how to use it inside django app.
Thanks

On Sunday, June 30, 2013 5:10:12 PM UTC+3, François Schiettecatte wrote:
Avishay

Take a look at http://jquery.com/ , lots of stuff there.

The other discussions that have been going on about REST would also be useful to you.

Cheers

François

On Jun 30, 2013, at 4:54 AM, Avishay Balderman <bald...@gmail.com> wrote:

> Hi  François
> Since I am a django "newbe", can you please elaborate or even point me to refrences in the web that shows the concept of what I am looking for?
> Thanks
>
> Avishay
>
> On Saturday, June 29, 2013 3:58:32 PM UTC+3, François Schiettecatte wrote:
> Django can handle some of that for you but not all, you will need to use javascript to handle the dynamics on the page itself., I use jquery, and use django to take the ajax calls and return data.
>
> If you don't have that much data you could just add it to the HTML page in javascript structures, would be easier to deal with than making ajax calls.
>
> Cheers
>
> François
>
> On Jun 29, 2013, at 5:28 AM, Avishay Balderman <bald...@gmail.com> wrote:
>
> > Hi
> > I need to implement a django app that has the following capabilities:
> > 1) When the main page loads it needs to dynamically (Ajax) populate a combo (<select>) with a list of "form types"
> > 2) When the user select an item from the "form types" combo, the app should issue Ajax call and fetch meta data. This meta data will bu used in order to render a form.
> >
> > Can you please advice?
> >
> > Thanks
> >
> > Avishay
> >
> >
> > --
> > 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...@googlegroups.com.
> > To post to this group, send email to django...@googlegroups.com.
> > Visit this group at http://groups.google.com/group/django-users.
> > For more options, visit https://groups.google.com/groups/opt_out.
> >  
> >  
>
>
> --
> 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...@googlegroups.com.
> To post to this group, send email to django...@googlegroups.com.
> Visit this group at http://groups.google.com/group/django-users.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Django 1.6 doesn't install via pip

On Sun, Jun 30, 2013 at 8:00 PM, Lachlan Musicman <datakid@gmail.com> wrote:
Hola,

I read the release notes, and tried to install 1.6. I encountered this error:

$ pip install Django==1.6b1
Downloading/unpacking Django==1.6b1
  Could not find a version that satisfies the requirement
Django==1.6b1 (from versions: 1.2.6, 1.3.6, 1.2.7, 1.2.3, 1.2.4,
1.4.4, 1.3.3, 1.2.1, 1.3.4, 1.2.2, 1.5, 1.3, 1.4.5, 1.3.1, 1.1.3,
1.3.5, 1.2.5, 1.1.4, 1.2, 1.3.2, 1.3.7, 1.4.3, 1.4.1, 1.5.1, 1.4.2,
1.4)
No distributions matching the version for Django==1.6b1


Hey L :),
 
fwiw, this should work if you want to install via pip currently:

The docs [0] do say that pip install django==1.6b1 should work though, so I'm guessing someone is going to push to pypi soon :-)

Cheers,
Sanjay

 

I presume that the 1.6 alpha/beta hasn't been pushed to pypi yet?

cheers
L.

--
We are like a drunk blundering through a crowd of pickpockets. That we
are not poor and naked already is a testament to either the goodness
of humanity or the ineptitude of the criminal class.

http://techcrunch.com/2013/06/08/we-asked-for-this/

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.



--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Re: Get Form from string?

Hey MacVictor,

So when I needed to do something similar, I landed up hard-coding a dict with form-name -> form-class in my model definition. Honestly, there is probably a better way to do it, but that worked fine for my use-case, though it did feel slightly "not right". Any-how, fwiw, I did something like:

from forms import FormA, FormB, FormC
class Foo(models.Model):
  ...
  forms = {
    'SomeFormA': FormA,
    'SomeFormB': FormB,
    'SomeFormC': FormC
  }

And then in your view, something like:
form = model.forms[<form_name>] .. etc..

I'm guessing from your email that what you need is something similar, and perhaps someone from the list has a better idea than the above to do it ..

Hope that helps, though ..

All the best,
Sanjay


On Sun, Jun 30, 2013 at 1:59 AM, MacVictor <witold.gren@gmail.com> wrote:
I try in view get the form by name.
Example:
this is my url: 

/some-url/MyForm/

url(r'^/some-url/(?P<form_name>[a-zA-Z0-9]+)/', 'my_view', name='my-wiev'),


and my view:

def my_view(request, form_name):
    form = how_get_form_name(form_name)
    response = {}
    response['my_form'] = form
    return render_to_response('request/window.html', response)


I have create uniwersal view, get my form and send to template. Why form? Because my model has more Forms and I want to select which forms.



W dniu piątek, 28 czerwca 2013 23:06:15 UTC+2 użytkownik yeswanth nadella napisał:
I am afraid, I did not understand your question. Are you trying to generate a form based on your model/ models? 

On Friday, June 28, 2013 3:23:00 PM UTC-5, MacVictor wrote:
and how to get only Form (not ModelForm) use string name?

W dniu piątek, 28 czerwca 2013 22:09:41 UTC+2 użytkownik MacVictor napisał:
get the model by string i use:

from django.db.models.loading import get_model
def get_model(self, app_label, model_name, seed_cache=True):

how to get ModelForm by string?

i try used:

modelforms = forms.ModelForm.__subclasses__()

def get_form(form):
    try:
        for model_form in modelforms:
            try:
                if model_form.Meta.form == form:
                    return model_form
            except AttributeError:
                continue
    except IndexError:
        print "Does not exist Model Forms for the object"

but I must import the form in which I will seek appropriate by name!

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
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+unsubscribe@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.
For more options, visit https://groups.google.com/groups/opt_out.