How modify Django to set URLs with decorators on the view functions like Flask? (rather than using urls.py)

2016-09-09 Thread Chris Seberino
Flask has a neat design where instead of having a urls.py file they bind 
URLs to view functions with decorators.

Possible to do something similar with Django?  What modifications would be 
needed?

Thanks,

cs

-- 
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/750daf34-3b33-40c7-85d1-1d0a90f79d59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How do you disable SECURE_SSL_REDIRECT for some views in Django?

2016-09-09 Thread Mauro Sánchez
Hello, I configured in my settings SECURE_SSL_REDIRECT=True, but now I want 
to disable it for some views.
I have seen that there is an option SECURE_REDIRECT_EXEMPT where I can 
define a list of regular expressions for it.
But for some reason I can't make it work. I've tried to use the same 
regular expressions that I use in my urls.py, for example:
r'^index/$'

But it doesn't do anything. It is still redirecting it to HTTPS. Does 
anyone has an example of how to use it?
I am using Django 1.9

Thanks a lot.
Cheers.
Mauro.

-- 
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/2fc80c86-ff63-42d3-8a14-a8c88fa11d4b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom form fields in admin site

2016-09-09 Thread Luis Zárate
Hi,

I started to make a test project, and review the django code in options,
but I see the problem and started to code in other way  the result is in

https://github.com/luisza/onetooneForm

Now is more interesting because I try to provide a way to update onetoone
fields in the same form.  I made an elegant solution rewriting __new__
function of modelform, but I have son dudes about my implementation and I
really need to test it.  (Finished coding a few minutes ago)

In the REAME are the to issues that make me ask for help those are:

   - If I use RelToParentFrom in onetooneForm/forms.py works ok, but I
   wanted something like in onetooneForm/forms_wanted.py
   - No way to sort fields
   - How can I use formfield_callback? it's necesary





2016-09-09 2:01 GMT-06:00 ludovic coues :

> It's not easy to understand what you are trying to do and in which way it
> is failing. It would require us setting up a test project.
> I am assuming you want that the Admin display a form with a field for each
> of Mymodel field plus the myextra_field attribute and what you get is
> either only the name fields and maybe the myextra_field. If that not the
> case, plus give us more information about your problem.
>
> MymodelAdmin.fields is overriding MyForm.fields. If you are curious, it's
> around line 594 of django/contrib/admin/options.py. If fields is set,
> get_fields return that. Else, it will return the form base_fields and the
> modeladmin readonly_fields.
>
>
>
> 2016-09-08 18:41 GMT+02:00 Luis Zárate :
>
>> Hi,  I am trying to do something like
>>
>>
>> class MyForm(forms.ModelForm):
>>  myextra_field = forms.IntegerField()
>>
>> class Meta:
>>   models = Mymodel
>>   fields = '__all__'
>>
>> class MymodelAdmin(admin.ModelAdmin):
>>   form = MyForm
>>   fields = ["name", 'myextra_field']
>>
>> def save(self, *args, **kwargs)
>> do something with myextra_field
>>
>>
>> I know that is possible to specify readonly_fields and fields works but
>> in readonly mode that is not what i want.
>>
>> So is there any way to have extra form fields in admin.ModelAdmin in edit
>> mode?
>>
>>
>>
>> --
>> "La utopía sirve para caminar" Fernando Birri
>>
>>
>> --
>> 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/ms
>> gid/django-users/CAG%2B5VyNVmNPzjkd-9bV_j35%2BNn5PYdjvMzi6GQ
>> v%2BhaDFZLrbug%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTZHhNTu1MXqCq_YXNxbKqX5SjCXeH3VJvV8Me_
> zmXpLXw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
"La utopía sirve para caminar" Fernando Birri

-- 
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/CAG%2B5VyOhBkVXfeOWEh0Y0mA3eHkUs%3DeEV1xaPqoDocE%2BW3uCDw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django Rest Create with a Writable Nested Serializer

2016-09-09 Thread Ronaldo Bahia


Hi everyone,


I'm trying to perform a create in Django Rest Framework using a writable 
nested serializer.

With the code bellow I can create a ScriptQuestion but I can't add a 
RecordedInterview into it. Django says OrderedDict is None.

What am I doing wrong?

Thanks in advance


Thread: 
http://stackoverflow.com/questions/39415005/django-rest-create-with-a-writable-nested-serializer


#models.py
class ScriptQuestion(models.Model):
interview = models.ManyToManyField(RecordedInterview)
...
class RecordedInterview(models.Model):
id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
...

The serializers

#serializers.py
class InterviewTitleSerializer(serializers.HyperlinkedModelSerializer):

class Meta:
model = RecordedInterview
fields = ('id', 'title')
extra_kwargs = {
'title': { 'read_only': True }
}

class QuestionDetailSerializer(serializers.HyperlinkedModelSerializer):

interview = InterviewTitleSerializer(many=True)

class Meta:
model = ScriptQuestion
fields = ('id', 'title', 'prep_time', 'answer_time', 'interview')
depth = 1

def create(self, validated_data):
interview_data = validated_data.pop('interview')
question = ScriptQuestion.objects.create(**validated_data)
for item in interview_data:
item = interview_data['id']
question.interview.add(item)
return question

Here is my view

#views.py 
class CreateQuestion(generics.CreateAPIView):
queryset = ScriptQuestion.objects.all()
serializer_class = QuestionDetailSerializer

And the json

{
"title": "Question Test Json",
"prep_time": "1",
"answer_time":"1",
"interview": [
   {
"id": "a450aeb0-8446-47b0-95bd-5accbb8b4afa"
}
 ]}

If I do manually, I can add the RecordedInterview into the ScriptQuestion:

#serializers.py 
def create(self, validated_data):
interview_data = validated_data.pop('interview')
question = ScriptQuestion.objects.create(**validated_data)
item = 'a450aeb0-8446-47b0-95bd-5accbb8b4afa'
question.interview.add(item)
return question

-- 
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/01dd7e85-2281-4fe4-99b9-30a6669b6862%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: pymssql

2016-09-09 Thread john

take a look at

http://pymssql.org/en/latest/pymssql_examples.html

Johnf


On 09/08/2016 05:48 PM, sum abiut wrote:

Hi,
i have used pymssql to connet to windows database but i want to be 
able iterate and  only print out some specific fields.


here is what i did

conn=pymssql.connect(server,username,password,database)
cus=conn.cursor()
cus.execute("SELECT * FROM glbud ")

for row in cus:
   print(row)
this works perfect, but when i try to iterate through and only print 
out specific fields i got the error NameError: name 'budget_code' is 
not defined



for row in cus:
   print(row.budget_code)


NameError: name 'budget_code' is not defined

the column name is budget_code, in mssql server 2008


any idea what i am doing wrong? please advise
--
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/CAPCf-y6FWUjFwKw0D-6-8%2BggS6BP7uTFkz_aU45452f2sCpCYg%40mail.gmail.com 
.

For more options, visit https://groups.google.com/d/optout.


--
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/dd97d1b0-e8d6-51da-7056-67d9c6832cad%40jfcomputer.com.
For more options, visit https://groups.google.com/d/optout.


Prevent Django from prepending site domain to beginning of feed links

2016-09-09 Thread Jamie
I'm creating an RSS feed that contains application links for URLs, but 
Django is prepending the domain name to any link that doesn't begin with 
*http*. So, links that should be *appname://* are being generated as 
*http://domain.comappname...*


How do I prevent Django from trying to correct links that are designed to 
be generated as-is?

-- 
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/a22f7c21-afd1-4272-ac85-08a8e2d8cf8f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Django Ticketing Application

2016-09-09 Thread Alexandra
Hi! 
It's necessary to integrate a Chat bot (as Zopim) and Ticketing system in a 
new app.
Chatting has to become a ticket. 
Can you suggest any Django Ticketing App which we can use for it?
Thank you in advance!

-- 
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/4ab74ea1-1658-4c6b-8c54-a0e5e7168606%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django group email in spam

2016-09-09 Thread Lachlan Musicman
Oh! I've seen this behaviour before, and that would explain it - do you
have a post or bug report I can read on that?

Cheers
L.

--
The most dangerous phrase in the language is, "We've always done it this
way."

- Grace Hopper

On 8 September 2016 at 23:06, Uri Even-Chen  wrote:

> Same here, and the problem is I filtered the group messages to skip my
> inbox in Gmail, and I can't filter them never to send them to spam, because
> then they will not skip my inbox (it's a bug in Gmail). So I have to enter
> my spam folder manually and mark each message as "not spam". By the way,
> also messages to Django developers mailing list are marked as spam.
>
>
> *Uri Even-Chen*
> [image: photo] Phone: +972-54-3995700
> Email: u...@speedy.net
> Website: http://www.speedysoftware.com/uri/en/
> 
> 
>   
>
> On Wed, Sep 7, 2016 at 11:05 PM, sylvain_grodes 
> wrote:
>
>> Same problem here, I have to check my spam and unset the spam flag.
>>
>>
>>
>>
>> Le vendredi 2 septembre 2016 02:12:18 UTC-4, Lachlan Musicman a écrit :
>>>
>>> Hey,
>>>
>>> I've been seeing a lot of Django group email going into my spam folder
>>> over the last 48 hours.
>>>
>>> Have there been any changes to the group that may have caused this?
>>>
>>> cheers
>>> L.
>>> --
>>> The most dangerous phrase in the language is, "We've always done it this
>>> way."
>>>
>>> - Grace Hopper
>>>
>> --
>> 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/ms
>> gid/django-users/de7b0239-ff49-4c83-acb8-53308a1178e2%40googlegroups.com
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/CAMQ2MsHCqeD8wgg_EEwfj69bwCHBSu8BSDpY09waVbs3zM
> WRGg%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAGBeqiM8mh2YiXPxyA2P785EBuG7%3DAL5TuQroycScAgwwgAAaQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Custom form fields in admin site

2016-09-09 Thread ludovic coues
It's not easy to understand what you are trying to do and in which way it
is failing. It would require us setting up a test project.
I am assuming you want that the Admin display a form with a field for each
of Mymodel field plus the myextra_field attribute and what you get is
either only the name fields and maybe the myextra_field. If that not the
case, plus give us more information about your problem.

MymodelAdmin.fields is overriding MyForm.fields. If you are curious, it's
around line 594 of django/contrib/admin/options.py. If fields is set,
get_fields return that. Else, it will return the form base_fields and the
modeladmin readonly_fields.



2016-09-08 18:41 GMT+02:00 Luis Zárate :

> Hi,  I am trying to do something like
>
>
> class MyForm(forms.ModelForm):
>  myextra_field = forms.IntegerField()
>
> class Meta:
>   models = Mymodel
>   fields = '__all__'
>
> class MymodelAdmin(admin.ModelAdmin):
>   form = MyForm
>   fields = ["name", 'myextra_field']
>
> def save(self, *args, **kwargs)
> do something with myextra_field
>
>
> I know that is possible to specify readonly_fields and fields works but in
> readonly mode that is not what i want.
>
> So is there any way to have extra form fields in admin.ModelAdmin in edit
> mode?
>
>
>
> --
> "La utopía sirve para caminar" Fernando Birri
>
>
> --
> 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/ms
> gid/django-users/CAG%2B5VyNVmNPzjkd-9bV_j35%2BNn5PYdjvMzi6GQ
> v%2BhaDFZLrbug%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTZHhNTu1MXqCq_YXNxbKqX5SjCXeH3VJvV8Me_zmXpLXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.