Re: First models.py needs tuning

2017-04-18 Thread Rich Shepard

On Wed, 19 Apr 2017, Mike Dewhirst wrote:


You probably need a single FK plus a meta option of unique_together
https://docs.djangoproject.com/en/1.8/ref/models/options/#unique-together



Use the model's clean() method ...
https://docs.djangoproject.com/en/1.8/ref/models/instances/#django.db.models.Model.clean


Mike,

  I'll read how to use these.

Thanks,

Rich



Re: First models.py needs tuning

2017-04-18 Thread Mike Dewhirst

On 19/04/2017 8:13 AM, Rich Shepard wrote:

  Converting from the postgres schema to a Django models.py for my first
Django project. Most of the syntax (64 lines in the file) should be 
correct,

but there are two conditions that I have not found how to handle.

  First, a couple of classes have primary keys with three fields. I know
there's a models.PrimaryKey but haven't found an example of how to apply
that to a field that foreign key fields.


You probably need a single FK plus a meta option of unique_together

https://docs.djangoproject.com/en/1.8/ref/models/options/#unique-together



  Second, I have a couple of fields with postgres check constraints; that
is, valid data is restricted to a list of strings. I've not found a 
Django

model field validator teaching me how to write this.


Use the model's clean() method ...

https://docs.djangoproject.com/en/1.8/ref/models/instances/#django.db.models.Model.clean

Cheers

Mike


  If you would be willing to look at the module, show me how to write the
two conditions above, and check syntax on the all 5 classes in it I will
send you the file off the mail list.

Rich



--
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/f8c37692-2c4c-09bd-5fa3-9189f6313797%40dewhirst.com.au.
For more options, visit https://groups.google.com/d/optout.


First models.py needs tuning

2017-04-18 Thread Rich Shepard

  Converting from the postgres schema to a Django models.py for my first
Django project. Most of the syntax (64 lines in the file) should be correct,
but there are two conditions that I have not found how to handle.

  First, a couple of classes have primary keys with three fields. I know
there's a models.PrimaryKey but haven't found an example of how to apply
that to a field that foreign key fields.

  Second, I have a couple of fields with postgres check constraints; that
is, valid data is restricted to a list of strings. I've not found a Django
model field validator teaching me how to write this.

  If you would be willing to look at the module, show me how to write the
two conditions above, and check syntax on the all 5 classes in it I will
send you the file off the mail list.

Rich


send email with django

2017-04-18 Thread shahab emami
hello

i want to send email using django. i used to send email with pour python 
before but now i can't do that in django.

i have search about this and i have seen some tutorials on youtube  in last 
two days but i cant do this .

this is in my settings.py :

EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = 'my_gm...@gmail.com'
EMAIL_HOST_PASSWORD= 'my_password'
EMAIL_PORT = 587

and this is my send email:

from django.core.mail import send_mail
def click(request):
send_mail(
'shahab',
'Here is the message.',
'my_gm...@gmail.com',
['shahabem...@yahoo.com'],
fail_silently=True
)
return HttpResponseRedirect('index')

but it doesn't work.

I am running this code on localhost. but i doesn't work on heroku too.
i changed allow less secure app to on in my gmail account and 
i went to this page too and  i clicked on continue :
https://accounts.google.com/DisplayUnlockCaptcha

can anybody tell me:
what am i missing ?



-- 
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/65e0ab09-ff5a-4ed5-89d6-e5e0991b9ea0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django 1.7: ImportError: No module named .models

2017-04-18 Thread Leonard Cohen
I WENT ALMOST CRAZY thanx a lot !!! ;)

Τη Τρίτη, 12 Αυγούστου 2014 - 12:19:34 μ.μ. UTC+3, ο χρήστης ngangsia 
akumbo έγραψε:
>
> i have had this same erroe too but it happed that i include instead the 
> module class name in the settings.py file
>
> make sure u are having the name of the app in the *settings.py *file
>

-- 
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/bd70d3e0-df69-448d-85ba-ff40b7d6af21%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating multiple objects with one request in Django Rest Framework

2017-04-18 Thread Aamu Padi
@Camilo Hi, I tried this way

class ManyMovieTicketSerializer(serializers.ModelSerializer):

seats = serializers.ListField(

child=serializers.IntegerField(min_value=0, max_value=100)

)

class Meta:

model = MovieTicket

fields = '__all__'


But I am getting error:

*AttributeError at /api/movies/buy-many-tickets/*


Got AttributeError when attempting to get a value for field `seats` on
serializer `ManyMovieTicketSerializer`.
The serializer field might be named incorrectly and not match any attribute
or key on the `MovieTicket` instance.
Original exception text was: 'MovieTicket' object has no attribute 'seats'.

What am I missing?

On Tue, Apr 18, 2017 at 4:45 PM, Christian Ledermann <
christian.lederm...@gmail.com> wrote:

> maybe
> https://github.com/marcgibbons/django-rest-framework-bulk
>
> HTH
>
> On 18 April 2017 at 11:29, Camilo Torres  wrote:
> > Hi,
> >
> > May be you can create a new Serializer, including a ListField to get
> > multiple seat IDs:
> >
> > class ManyMovieTicketsSerializer(serializers.Serializer):
> > show = serializers.IntegerField
> > user = serializers.IntegerField
> > seats = serializers.ListField(child=serializers.IntegerFields)
> >
> > def create(self, validated_data):
> > iterate over seats and save every instance.
> >
> > On Monday, April 17, 2017 at 1:19:23 AM UTC-4, Aamu Padi wrote:
> >>
> >> I am using Django as the backend server and Vue.js for the front end
> Movie
> >> app.
> >>
> >> I have a Ticket model
> >>
> >> class MovieTicket(models.Model):
> >> show = models.ForeignKey(Show)
> >> seat = models.ForeignKey(Seat)
> >> user = models.ForeignKey(User)
> >> purchased_at = models.DateTimeField(default=timezone.now)
> >> qrcode = models.ImageField(upload_to='qrcode', blank=True,
> null=True)
> >> qrcode_data = models.CharField(max_length=255, unique=True,
> >> blank=True)
> >>
> >> class Meta:
> >> unique_together = ('show', 'seat')
> >>
> >> And its related Serializer
> >>
> >> class MovieTicketSerializer(serializers.ModelSerializer):
> >> class Meta:
> >> model = MovieTicket
> >> fields = '__all__'
> >>
> >> To buy a new Ticket there's a view which is mapped to this url
> >> http://dev.site.com/api/movies/buy-ticket/:
> >>
> >> @api_view(['POST'])
> >> @permission_classes([IsAuthenticated])
> >> def buy_ticket(request):
> >> serialized = MovieTicketSerializer(data=request.data)
> >> if serialized.is_valid():
> >> serialized.save()
> >> return Response(serialized.data, status=status.HTTP_201_
> CREATED)
> >> return Response(serialized._errors,
> >> status=status.HTTP_400_BAD_REQUEST)
> >>
> >> Now from the front end (Vue.js) I can create a new movie ticket like
> this:
> >>
> >> const formBody = {
> >> show: this.$store.state.showSelected.showTime.id,
> >> user: this.$store.state.user.id,
> >>
> >> // selectedSeats is an array of seats that have been selected by the
> >> user. Here I am passing the first seat object.
> >> seat: this.$store.state.selectedSeats[0].seat.id
> >> };
> >>
> >> this.$http.post("http://dev.site.com/api/movies/buy-ticket/;, formBody)
> >> .then(function (response) {
> >> console.log(response.data);
> >> })
> >> .catch(function (response) {
> >> console.log(response);
> >> });
> >> return;
> >>
> >> If the form was valid, this will create a new MovieTicket Object.
> >>
> >> Now, suppose if the user selected multiple seats, I can loop through
> each
> >> selectedSeats array and get the seat ids. But what I am confused is how
> can
> >> I pass multiple seat.id if Django rest framework is only accepting one
> seat
> >> per request?
> >
> > --
> > 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/b8c28522-
> cf21-4081-9563-97a869f4fa7f%40googlegroups.com.
> >
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> Best Regards,
>
> Christian Ledermann
>
> Newark-on-Trent - UK
> Mobile : +44 7474997517
>
> https://uk.linkedin.com/in/christianledermann
> https://github.com/cleder/
>
>
> <*)))>{
>
> If you save the living environment, the biodiversity that we have left,
> you will also automatically save the physical environment, too. But If
> you only save the physical environment, you will ultimately lose both.
>
> 1) Don’t drive species to extinction
>
> 2) Don’t destroy a habitat that species rely on.
>
> 3) Don’t change the climate in ways that will result in the above.
>
> }<(((*>
>
> --
> You 

Re: Automatic reverse migrations

2017-04-18 Thread Paul Tiplady
I think it's possible to do better than the current status quo with a bit
more metadata, and without changing the current flow for users that don't
want/need more -- essentially all I'm looking for is a way to record which
migrations were applied in a given run of `./manage.py migrate`, so that I
can revert the same set in a downgrade. This would be equally useful for
reversing manually applied migrations as for doing an automated rollback.

The API I'm thinking of is something like this (zero thought invested in
naming):

```
# ./manage.py migratewithtag 1.2.3
> running migration app1.0002
> running migration app2.0004
> writing tag before and after state to django_migrationtags table
{app1:{before: 0001, after:0002},...}
# ./manage.py rollbacktag 1.2.3
> running migration app1.0001
> running migration app2.0003
```

This is essentially just a layer of metadata above the current migrations
table.

I've yet to start playing with an implementation, but of course suggestions
welcome for potential problems with this approach.

On Mon, Apr 17, 2017 at 5:21 PM, Mike Dewhirst 
wrote:

> On 18/04/2017 9:58 AM, p...@qwil.co wrote:
>
>> Thanks Andrew, will see what I can rustle up.
>>
>> Camilo -- blue/green deploys don't really help with this problem. As each
>> application deployment still talks to the same database, once you have run
>> the migration you can't just abandon your deployment, you need to unwind
>> the db migration first.
>>
>
> I agree it is an unsolvable problem to automate it. Or rather, not worth
> the development cost of making an automatic "unwinder".
>
> For the number of times it is likely to be needed in general it would be
> less costly to do another new migration towards the previous state.
>
>
>> On Saturday, April 15, 2017 at 6:01:03 PM UTC-7, Camilo Torres wrote:
>>
>> Hi,
>> May both of you try to implement "blue-green deployments", and
>> switch only if all tests are OK.
>> You may also be interested in running a test deployment in a
>> testing environment prior to production.
>> Don't know of a solution integrated into django.
>>
>> On Friday, April 14, 2017 at 2:26:51 PM UTC-4, Andrew Godwin wrote:
>>
>> Hi Paul,
>>
>> I have tried this in the past, but it's basically an
>> unsolvable problem in the generic case. Databases do not take
>> well to snapshotting or changing schema, and some operations
>> are naturally irreversible. If you find a way that works well,
>> I suggest you write it up so others can learn from it!
>>
>> Andrew
>>
>> On Fri, Apr 14, 2017 at 10:33 AM,  wrote:
>>
>> In a modern Continuous Delivery environment, it's expected
>> that there is an automated process for deploying code, and
>> therefore performing database migrations. This is all
>> straightforward.
>>
>> I haven't been able to find any good solutions for
>> automatic rollback though. The main problem that I see is
>> that there is (AFAIK) no easy way to definitively know
>> which migrations to unapply to roll back to the previous
>> verison. If you try to rollback from the new N+1 version,
>> you have the migrations, but no recording of the previous
>> version's state. If you rollback from the previous N
>> version, you don't have the new migration files to do the
>> DB rollback.
>>
>> What I'd really like is a way of recording a 'db migration
>> checkpoint' which could be generated per-release (or
>> whenever else you care to checkpoint your migration
>> state), and would say something like `v1: {app1:0002,0003,
>> app2: 0004}, v2: {app1:0004, app2: 0005, 0006}`, thus
>> letting me roll back all of the migrations in the v2
>> deploy with a single command.
>>
>> Does anyone have suggestions or references here? I may try
>> rolling the above solution if there is no prior art, but I
>> want to avoid reinventing the wheel here, as it seems that
>> this issue must have been hit by many other users before me.
>> -- 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
>> https://groups.google.com/group/django-users
>> .
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/6cafecca-2c71
>> 

Crone Job Issue

2017-04-18 Thread reachsyedmail
Hi All ,

I am new for Django Framework  , I need your help to fix this below issue
.I am trying to run cron job (*python manage.py crontab add*) but its
showing following error .

*System check identified some issues:*

*WARNINGS:*
*metric_db.note_appnav_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_automatedreg_table.updated: (fields.W161) Fixed default
value provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_autotest_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_buffer_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_featuredev_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_hardening_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_manualtest_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_planned_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_release_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.now`*
*metric_db.note_sustanance_table.updated: (fields.W161) Fixed default value
provided.*
*HINT: It seems you set a fixed date / time / datetime value as
default for this field. This may not be what you want. If you want to have
the current date as default, use `django.utils.timezone.*


*System configuration : *
OS: Linux
Python 2.7 and  Django version 1.8.3

I have tried multiple ways but no luck , Could you please help me to 
resolve this issue .

Thanks 
Syed 

-- 
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/0860374c-cc80-4c43-9b95-c4abe02d9320%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Profiles in Django 1.11

2017-04-18 Thread Camilo Torres
Hi,

I think you can use the default authentication system and create 2 
different groups: 'students' and 'teachers', give 'students' group 
permissions to all the parts of the application for students; similarly, 
give the 'teachers' group permissions to all the parts of the teachers 
application; you can do this with the admin. When you create new users, you 
should put them in any of the 2 groups; you can do this with the admin or 
programmatically.
Then, in your application views, remember to check for permissions by using 
the already available mixins or function decorators.
Please, read this part of the documentation:

   - https://docs.djangoproject.com/en/1.11/topics/auth/
   - https://docs.djangoproject.com/en/1.11/topics/auth/default/

Hope this helps.

On Tuesday, April 18, 2017 at 9:14:39 AM UTC-4, Bujj wrote:
>
> Hi guys i am new to django and i need some help here, i have created two 
> apps inside my django project namely students and teachers, how do i create 
> an authentication system for each one of them?  where they can register and 
> login to their backend, which will have a totaly different look from one 
> another
>

-- 
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/9268f190-33f6-449b-93ae-95b3504fc7ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Meu site esta com problema com decode messagem erro AttributeError at str object has no atribute 'decode' sera alguem pode me ajudar?

2017-04-18 Thread Camilo Torres
Hi,
You have not pasted enough information for me to know the error. You can 
paste the entire stack trace (as text, no need for a screen shot), or even 
better, if you have access to the server logs (django logs), you can see 
the entire stack trace there. You can also paste the relevant code if you 
need more help.

   - http://www.wikihow.com/Ask-a-Question-Intelligently
   - 
   
https://support.microsoft.com/en-us/help/555375/suggestions-for-asking-a-question-on-help-forums

For now, I can only recommend you to watch at line 68 of file 
.../web_server_moip.py, your error is being detected there. You are using a 
'decode' attribute of some variable, but that variable contains a str 
object (string text), and do not have such 'decode' property. The problem 
is probably because you are expecting another type of object like bytes or 
bytearray.

On Tuesday, April 18, 2017 at 8:11:38 AM UTC-4, Marcio Shochi wrote:
>
>
>1. erro AttributeError at   str object has no atribute  'decode' sera 
>alguem pode me ajudar?
>
>
>
>
> 
>

-- 
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/09559516-cbfa-4a07-a0c2-68abd70ca294%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Multiple Profiles in Django 1.11

2017-04-18 Thread Bujj
Hi guys i am new to django and i need some help here, i have created two 
apps inside my django project namely students and teachers, how do i create 
an authentication system for each one of them?  where they can register and 
login to their backend, which will have a totaly different look from one 
another

-- 
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/3e9c485d-3656-4720-927d-108b20b98759%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating multiple objects with one request in Django Rest Framework

2017-04-18 Thread Christian Ledermann
maybe
https://github.com/marcgibbons/django-rest-framework-bulk

HTH

On 18 April 2017 at 11:29, Camilo Torres  wrote:
> Hi,
>
> May be you can create a new Serializer, including a ListField to get
> multiple seat IDs:
>
> class ManyMovieTicketsSerializer(serializers.Serializer):
> show = serializers.IntegerField
> user = serializers.IntegerField
> seats = serializers.ListField(child=serializers.IntegerFields)
>
> def create(self, validated_data):
> iterate over seats and save every instance.
>
> On Monday, April 17, 2017 at 1:19:23 AM UTC-4, Aamu Padi wrote:
>>
>> I am using Django as the backend server and Vue.js for the front end Movie
>> app.
>>
>> I have a Ticket model
>>
>> class MovieTicket(models.Model):
>> show = models.ForeignKey(Show)
>> seat = models.ForeignKey(Seat)
>> user = models.ForeignKey(User)
>> purchased_at = models.DateTimeField(default=timezone.now)
>> qrcode = models.ImageField(upload_to='qrcode', blank=True, null=True)
>> qrcode_data = models.CharField(max_length=255, unique=True,
>> blank=True)
>>
>> class Meta:
>> unique_together = ('show', 'seat')
>>
>> And its related Serializer
>>
>> class MovieTicketSerializer(serializers.ModelSerializer):
>> class Meta:
>> model = MovieTicket
>> fields = '__all__'
>>
>> To buy a new Ticket there's a view which is mapped to this url
>> http://dev.site.com/api/movies/buy-ticket/:
>>
>> @api_view(['POST'])
>> @permission_classes([IsAuthenticated])
>> def buy_ticket(request):
>> serialized = MovieTicketSerializer(data=request.data)
>> if serialized.is_valid():
>> serialized.save()
>> return Response(serialized.data, status=status.HTTP_201_CREATED)
>> return Response(serialized._errors,
>> status=status.HTTP_400_BAD_REQUEST)
>>
>> Now from the front end (Vue.js) I can create a new movie ticket like this:
>>
>> const formBody = {
>> show: this.$store.state.showSelected.showTime.id,
>> user: this.$store.state.user.id,
>>
>> // selectedSeats is an array of seats that have been selected by the
>> user. Here I am passing the first seat object.
>> seat: this.$store.state.selectedSeats[0].seat.id
>> };
>>
>> this.$http.post("http://dev.site.com/api/movies/buy-ticket/;, formBody)
>> .then(function (response) {
>> console.log(response.data);
>> })
>> .catch(function (response) {
>> console.log(response);
>> });
>> return;
>>
>> If the form was valid, this will create a new MovieTicket Object.
>>
>> Now, suppose if the user selected multiple seats, I can loop through each
>> selectedSeats array and get the seat ids. But what I am confused is how can
>> I pass multiple seat.id if Django rest framework is only accepting one seat
>> per request?
>
> --
> 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/b8c28522-cf21-4081-9563-97a869f4fa7f%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
Best Regards,

Christian Ledermann

Newark-on-Trent - UK
Mobile : +44 7474997517

https://uk.linkedin.com/in/christianledermann
https://github.com/cleder/


<*)))>{

If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.

1) Don’t drive species to extinction

2) Don’t destroy a habitat that species rely on.

3) Don’t change the climate in ways that will result in the above.

}<(((*>

-- 
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/CABCjzWotO%2B77TkYeJyBq%3DuKEtuPbTmnn%3DOzy%2BpmQ3AuDD462%3DA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: I am in need of a django programmer

2017-04-18 Thread Marlysson Silva
You need to..

Em segunda-feira, 17 de abril de 2017 17:41:03 UTC-3, Web Design by Sami 
Social Media by Sami escreveu:
>
> http://www.prosadata.com/slamgrams/Slamgrams1.html
>
> my email is wdb...@gmail.com 
>

-- 
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/fff81a54-e6d3-4c5a-9684-f1c41644e586%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: take select request from django from

2017-04-18 Thread Camilo Torres
Hi,

I think you can do what you need with your current model and form and using 
FormSets, but then you should change your view and template:
https://docs.djangoproject.com/en/1.11/topics/forms/formsets/

On Sunday, April 16, 2017 at 3:41:04 PM UTC-4, Xristos Xristoou wrote:
>
> hello i have create a select django form with list of images for per user.
>
> How to take that select request in my views.py ?
>
> i have success only to create correct that select list but i need take 
> that select request but i dont know how.
>
> models.py
>
> class MyModel(models.Model):
> user = models.ForeignKey(User, unique=True)
> upload = models.ImageField(upload_to='upload')
>
> views.py
>
>@login_required(login_url="login/")
> def carlist(request):
> Myform = MyModelForm(user=request.user)
> return render(request,'about.html',{'Myform':Myform})
>
> select django form :
>
> class MyModelForm(ModelForm):
> def __init__(self, *args, **kwargs):
> # extract "user" from kwrags (passed upon form init)
> if 'user' in kwargs:
> self.user = kwargs.pop('user')
> super(MyModelForm, self).__init__(*args, **kwargs)
> # generate the choices as (display, value). 
> # Display is the one that'll be shown to user, value is 
> # the one that'll be sent upon submitting 
> # (the "value" attribute of )
> choices = 
> MyModel.objects.filter(user=self.user).values_list('upload', 'id')
> self.fields['upload'].widget = Select(choices=choices)
>
> class Meta:
> model = MyModel
> fields = ('upload',)
>
> html :
>
> {% 
> csrf_token %}
>   {{ Myform}}
>
> for example Myform now have a list of user images that is correct but 
> after from that i need the select images from the form.
>
> can do it that with my code or not ?
>

-- 
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/ec7723ac-5c48-4745-9ebe-e16347598926%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Mysql/Models

2017-04-18 Thread Camilo Torres
Hi,

You can use a Meta class for your models and add a db_table property to 
control the table name related to the model, that way, you can name your 
model as you like (and differently from the DB table name).
You can also use the db_column parameter to Fields to control the name of 
the column in the table you are associating the model fields. That allows 
you to use lowercase field names as customary for Python, for example:

class Organism(models.Model):
author = models.CharField(max_length=200, db_column='Author')
...

Please, read this documentation:
https://docs.djangoproject.com/en/1.11/ref/models/options/
https://docs.djangoproject.com/en/1.11/ref/models/fields/#db-column


On Sunday, April 16, 2017 at 6:01:16 PM UTC-4, alkha...@mymail.vcu.edu 
wrote:
>
> Hello everyone,
>
> Again, I'm super new to django so please bare with me. 
>
> I have just connected my mysql database to my django project in 
> settings.py. I then manually made models for the tables in my database. I 
> originally used inspectdb to do this, but I was getting a bunch of errors. 
> I decided to just do it manually from there, although I'm not necessarily 
> sure if it is correct yet. Do my models have to perfectly match my sql 
> relations? My tables already have unique ids as a field. I now that django 
> automatically does this, that is, make unique ids? Will this be a problem. 
>
> Anyway, I then ran makemigrations and migrate (which worked wonderfully), 
> and now I am trying to simply view some data from my database in the 
> manage.py shell. I am not exactly sure how to do this, so any help would be 
> great. Further, am I missing any steps as far connecting the mysql database 
> to my django project? Lastly, a rather huge disconnect I am having with all 
> of this is simply understanding how exactly the models.py in my apps are 
> actually connected to my database?
>
> Here are a few snapshots of my files:
>
> Models.py 
>
>
> 
>  
>
> manage.py shell
>
>
>
> 
>

-- 
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/a0345dda-370e-40f8-8e68-0fbf37e4c422%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Creating multiple objects with one request in Django Rest Framework

2017-04-18 Thread Camilo Torres
Hi,

May be you can create a new Serializer, including a ListField to get 
multiple seat IDs:

class ManyMovieTicketsSerializer(serializers.Serializer):
show = serializers.IntegerField
user = serializers.IntegerField
seats = serializers.ListField(child=serializers.IntegerFields)

def create(self, validated_data):
iterate over seats and save every instance.

On Monday, April 17, 2017 at 1:19:23 AM UTC-4, Aamu Padi wrote:
>
> I am using Django as the backend server and Vue.js for the front end Movie 
> app.
>
> I have a Ticket model
>
> class MovieTicket(models.Model):
> show = models.ForeignKey(Show)
> seat = models.ForeignKey(Seat)
> user = models.ForeignKey(User)
> purchased_at = models.DateTimeField(default=timezone.now)
> qrcode = models.ImageField(upload_to='qrcode', blank=True, null=True)
> qrcode_data = models.CharField(max_length=255, unique=True, blank=True)
>
> class Meta:
> unique_together = ('show', 'seat')
>
> And its related Serializer
>
> class MovieTicketSerializer(serializers.ModelSerializer):
> class Meta:
> model = MovieTicket
> fields = '__all__'
>
> To buy a new Ticket there's a view which is mapped to this url 
> *http://dev.site.com/api/movies/buy-ticket/ 
> :*
>
> @api_view(['POST'])@permission_classes([IsAuthenticated])def 
> buy_ticket(request):
> serialized = MovieTicketSerializer(data=request.data)
> if serialized.is_valid():
> serialized.save()
> return Response(serialized.data, status=status.HTTP_201_CREATED)
> return Response(serialized._errors, status=status.HTTP_400_BAD_REQUEST)
>
> Now from the front end (Vue.js) I can create a new movie ticket like this:
>
> const formBody = {
> show: this.$store.state.showSelected.showTime.id,
> user: this.$store.state.user.id,
>
> // selectedSeats is an array of seats that have been selected by the 
> user. Here I am passing the first seat object.
> seat: this.$store.state.selectedSeats[0].seat.id};
> this.$http.post("http://dev.site.com/api/movies/buy-ticket/;, formBody)
> .then(function (response) {
> console.log(response.data);
> })
> .catch(function (response) {
> console.log(response);
> });return;
>
> If the form was valid, this will create a new MovieTicket Object.
>
> Now, suppose if the user selected multiple seats, I can loop through each 
> selectedSeats array and get the seat ids. But what I am confused is how 
> can I pass multiple seat.id if Django rest framework is only accepting 
> one seat per request?
>

-- 
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/b8c28522-cf21-4081-9563-97a869f4fa7f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django forks

2017-04-18 Thread Antonis Christofides
I'm really no expert in JS, but I have noticed that now that browsers are much
more compliant than they used to be a few years ago, there is a tendency by some
to avoid JS frameworks altogether and write vanilla JS. For example,
https://gomakethings.com/vanilla-js-guidebook/ (the author is an acquaintance),
and there are more on the same train.

I guess that writing vanilla JS might have the added benefit of being easier to
accept into core Django.

Antonis Christofides
http://djangodeployment.com


On 2017-04-17 17:57, Jamesie Pic wrote:
> Dear Andréas,
>
> During the past decade, I have fought that model fields do not have
> usable form fields out of the box.
>
> "Django doesn't want to couple a JS framework", is what I remember
> from discussions. For me, having JS enabled form fields does not mean
> **removing** support for pure-HTML form fields, so, nobody would be
> actually "coupled with a JS framework". And, supporting one JS
> framework doesn't mean Django couldn't support other framework
> neither.
>
> I'd like to try a Django fork that LOVES javascript and out of the box
> experience. Currently, the philosophy in Django is "if it can be in an
> app then it should be in an app", which opposes what "improving ootb
> experience" means for me.
>
> Also, I'd like it to make it easier for newbies to install Django
> projects, I've posted about this in a thread about
> DJANGO_SETTINGS_FILE on django-dev.
>
> And of course, I'd like a fork that's easy to contribute to, iterate
> with, so that features can mature outside of Django before being
> proposed upstream. I'm up for helping others on their features too of
> course ;)
>
> Best,
> Jamesie
> <3
>

-- 
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/ccff6499-a7c8-3523-4c13-8c3f282c2937%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: safe perfect and reliable app for verification email

2017-04-18 Thread Antonis Christofides
I haven't followed this discussion very closely, but is it possible that what
the original poster needs is django-registration-redux?

Antonis Christofides
http://djangodeployment.com


On 2017-04-17 20:51, ludovic coues wrote:
> I believe we have a code of conduct against posting an answer which is
> nothing more than a google link.
>
> I don't know any app handling email verification. If I had to do it, I
> would copy how django handle password reset. Send an email with with a
> link containing a token. When someone hit that url, check if they are
> connected and their account is associated with the token.
>
> As far as I know, there are no way to know if an email is valid
> without sending a message. There are various check we can do to mark
> an email as invalid but these need constant update. An example could
> be tld.
>
> 2017-04-16 15:07 GMT+02:00 Willian Will :
>> Hey, you can user javasript for that, thus You dont need use ajax or
>> anything for retrieve confirmation about email is correct or no , but you
>> need confirm about the email already exists in database ?
>>
>>
>> sábado, 15 de Abril de 2017 às 09:22:21 UTC-3, shahab emami escreveu:
>>> hello
>>> I want to verify user's email while user is registering  .
>>>
>>> can you introduce me a few safe perfect  and reliable app for verification
>>> email?
>>>
>>> thanks
>> --
>> 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/9e07bab1-2bdc-4056-9a6e-29a418f932d8%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/a7310d17-ffab-05e1-694e-432d7649e08b%40djangodeployment.com.
For more options, visit https://groups.google.com/d/optout.


Re: Totally Lost on "python manage.py runserver"

2017-04-18 Thread Scot Hacker
`pip install pysqlite2` ? 

./s

On Friday, April 14, 2017 at 5:07:06 AM UTC-7, Michael Durkin wrote:
>
> I am at a loss. My Google-Fu seems to be sub-par as I cannot find an 
> answer to what I'm looking for. 
>
> I am running Ubuntu, using Python 3.6.0 (pyenv handles different Python 
> versions for me), have installed SQLite and Apache and ran "pip install 
> django" to get Django on my machine. 
>
> I have run through the Django tutorial on installation (
> https://docs.djangoproject.com/en/1.11/topics/install/#installing-official-release)
>  
> and made it all the way to "python manage.py runserver". After running that 
> line I get the following message through the shell that I simply do not 
> understand:
>
> ~/Scripts/Django_Practice/mysite$ python manage.py runserver
> Unhandled exception in thread started by  check_errors..wrapper at 0x7f0e6c4ce730>
> Traceback (most recent call last):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py",
>  
> line 31, in 
> from pysqlite2 import dbapi2 as Database
> ModuleNotFoundError: No module named 'pysqlite2'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py",
>  
> line 33, in 
> from sqlite3 import dbapi2 as Database
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/sqlite3/__init__.py", 
> line 23, in 
> from sqlite3.dbapi2 import *
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/sqlite3/dbapi2.py", line 
> 27, in 
> from _sqlite3 import *
> ModuleNotFoundError: No module named '_sqlite3'
>
> During handling of the above exception, another exception occurred:
>
> Traceback (most recent call last):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/core/management/commands/runserver.py",
>  
> line 117, in inner_run
> autoreload.raise_last_exception()
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 250, in raise_last_exception
> six.reraise(*_exception)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/six.py",
>  
> line 685, in reraise
> raise value.with_traceback(tb)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/utils/autoreload.py",
>  
> line 227, in wrapper
> fn(*args, **kwargs)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/__init__.py",
>  
> line 27, in setup
> apps.populate(settings.INSTALLED_APPS)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/apps/registry.py",
>  
> line 108, in populate
> app_config.import_models()
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/apps/config.py",
>  
> line 202, in import_models
> self.models_module = import_module(models_module_name)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/importlib/__init__.py", 
> line 126, in import_module
> return _bootstrap._gcd_import(name[level:], package, level)
>   File "", line 978, in _gcd_import
>   File "", line 961, in _find_and_load
>   File "", line 950, in 
> _find_and_load_unlocked
>   File "", line 655, in _load_unlocked
>   File "", line 678, in exec_module
>   File "", line 205, in 
> _call_with_frames_removed
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/contrib/auth/models.py",
>  
> line 4, in 
> from django.contrib.auth.base_user import AbstractBaseUser, 
> BaseUserManager
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/contrib/auth/base_user.py",
>  
> line 52, in 
> class AbstractBaseUser(models.Model):
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/base.py",
>  
> line 124, in __new__
> new_class.add_to_class('_meta', Options(meta, app_label))
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/base.py",
>  
> line 330, in add_to_class
> value.contribute_to_class(cls, name)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/models/options.py",
>  
> line 214, in contribute_to_class
> self.db_table = truncate_name(self.db_table, 
> connection.ops.max_name_length())
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/__init__.py",
>  
> line 33, in __getattr__
> return getattr(connections[DEFAULT_DB_ALIAS], item)
>   File 
> "/home/durkin/.pyenv/versions/3.6.0/lib/python3.6/site-packages/django/db/utils.py",
>  
> line 211, in __getitem__
> backend =