Regarding to trying to make Django rest Api for eCommerce project.

2019-06-06 Thread RONAK JAIN
Dear All,

*Note: trying to make Django rest Api for eCommerce project.*

I am working drf eCommerce project.

I am trying to make product rating and review Django Rest Api.

*Models.py*

class Product_review(models.Model):
user_id = models.ForeignKey(User_registrations,
on_delete=models.CASCADE)
product_id = models.ForeignKey(Techshop, on_delete=models.CASCADE)
product_rating = models.IntegerField()
product_created_rating_date = models.DateTimeField(auto_now_add=True,
null=True)
product_review  = models.ForeignKey(on_delete=models.SET_DEFAULT,
null=True, default = "NA")
product_created_review_date = models.DateTimeField(auto_now_add=True,
null=True)

Serializer.py



class Product_review(serializers.Serializer):
product_code = models.IntegerField(null=True)
product_rating = models.IntegerField()
product_review  = models.TextField(max_length=3000)
product_created_rating_date = models.DateTimeField(auto_now_add=True,
null=True)
def validate(self, data,email):
product_code = data.get("product_code")
product_rating = data.get("product_rating")
product_review  = data.get("product_review")
user_data = User_registrations.objects.get(email=email)
product_code = Techshop.objects.get(product_code, product_rating,
user_data)
if int(product_rating) <= 5 and int(product_rating) => 1:
if product_rating == 1:
print("Poor")
elif product_rating == 2:
print("Average")
elif product_rating == 3:
print("Good")
elif product_rating == 4:
print("Very Good")
elif product_rating == 5:
print("Excellent")
else:
continue
else:
continue
*views.py *

class Product_reviewView(APIView):
def post(self,request):
try:
rt = TokenAuthentication()
g = rt.authenticate(request)
if g[1]:
serializer = Product_review.validate(None,request.data,
g[0])
return Response(serializer,status=HTTP_200_OK)
else:
raise serializers.ValidationError(g)
except Exception as e:
raise serializers.ValidationError(e)

I need to find ratings for particular user and my side I am taking uniqe as
product code.


Thanks
django user

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


Re: Handling two forms at different pages.

2019-06-06 Thread Chetan Ganji
This is front end task.

You combine the two different pages into a single page. Page 1 and page 2
would become step 1 and step 2.
You can use concept of tabs to implement this.

Both the tabs would be under the same form.

When you hit the save button, data from both the steps would be saved.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 2:42 AM Ashutosh Kumar  wrote:

> Hi,
>
> Actually I have two forms at two different pages and the second page is
> the extension of first form.
>
> Basically the first page has some fields and continue button to the next
> page, and next page has some fields and save button.
>
> So once user will click to continue I don't want to save the data, instead
> I want to save all together when the user will hit save button to the next
> page.
>
> My question is how to do this in dango.
>
> Your help is much appreciated.
>
> Regards,
>
> Ashutosh
>
> --
> 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/CAAcNNfJG11_t5VLGE%3Dm62D5WM5Y8sSkzTMw_ZiGE1vZMk3Ar%2Bg%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/CAMKMUjtz-BXLkv23Cg6ivP8n%3D4QfVfxhvqMN9pJbLhid6vKjBg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Watch "Django on pythonanywhere." on YouTube

2019-06-06 Thread Alex Kimeu
https://youtu.be/3B2yALSpqFg

-- 
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/CACYP3VFRV7k4EjrrK2Zc-n-3HqcHtxMVbGT4F%2BSNmPKwj%2B6Ubg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Annotations as models fields

2019-06-06 Thread Olivier Dalang
Dear list,

I was wondering whether there's a package or pattern to define annotations
as model fields, so that they could really be used as database-side
computed fields.

Currently, I do something like this (not tested, it's a simplified case):

class SalesManager(models.Manager):
def get_queryset(self):
return super().get_queryset().annotate(
profit=F("selling_price")-F("buying_price")
)

class Sales(models.Model):
objects = SalesManager()

buying_price = models.FloatField()
selling_price = models.FloatField()
...

Ideally, I'd see something like :

class Sales(models.Model):
buying_price = models.FloatField()
selling_price = models.FloatField()
profit = models.AnnotationField(F("selling_price")-F("buying_price"))
...

An AnnotationField would behave like a read-only field, excepted that it
wouldn't have a database column.

This would have the following benefits :
- much less verbose
- all instance related stuff in one place
- it would make it possible to refer to "profit" as a model field
- you could use the field in Meta.ordering
- you could easily display in django.admin without additional methods

Of course similar result can be achieved with @property and a python
method, but I really need this to be on the database side to use
subqueries, sorting and filtering, etc.

Does anything like this exist ? Is it possible to emulate this behaviour
somehow ?

Thanks !!

Olivier

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


Re: Annotations as models fields

2019-06-06 Thread Chetan Ganji
I had a similar need in one of my clients project, I ended up using
@property and a python method.

AFAIK, AnnotationField is absent from django models. If you would like to
write one, below is the material you need to refer.
https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
wrote:

> Dear list,
>
> I was wondering whether there's a package or pattern to define annotations
> as model fields, so that they could really be used as database-side
> computed fields.
>
> Currently, I do something like this (not tested, it's a simplified case):
>
> class SalesManager(models.Manager):
> def get_queryset(self):
> return super().get_queryset().annotate(
> profit=F("selling_price")-F("buying_price")
> )
>
> class Sales(models.Model):
> objects = SalesManager()
>
> buying_price = models.FloatField()
> selling_price = models.FloatField()
> ...
>
> Ideally, I'd see something like :
>
> class Sales(models.Model):
> buying_price = models.FloatField()
> selling_price = models.FloatField()
> profit = models.AnnotationField(F("selling_price")-F("buying_price"))
> ...
>
> An AnnotationField would behave like a read-only field, excepted that it
> wouldn't have a database column.
>
> This would have the following benefits :
> - much less verbose
> - all instance related stuff in one place
> - it would make it possible to refer to "profit" as a model field
> - you could use the field in Meta.ordering
> - you could easily display in django.admin without additional methods
>
> Of course similar result can be achieved with @property and a python
> method, but I really need this to be on the database side to use
> subqueries, sorting and filtering, etc.
>
> Does anything like this exist ? Is it possible to emulate this behaviour
> somehow ?
>
> Thanks !!
>
> Olivier
>
>
> --
> 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/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%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/CAMKMUjscehKiqt4Gcu3Cnm%2BHKhH8Y98RnGhR6chVZ7NS5qc-sw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: using single view function or class for multiple types of users

2019-06-06 Thread Harsh Gundecha
thank you
this perfectly makes sense

On Tuesday, June 4, 2019 at 9:32:23 PM UTC+5:30, RyuCoder wrote:
>
> RE: "slight change in output"
> First of all define what it really means. What needs to be changed and how.
>
> RE " is it a good idea to use same URL for both and serve by checking user 
> type"
> Yes and No. 
>
> It depends on your mentality. I personally prefer to have separate 
> endpoints for different types of users, 
> so if I change something for one user, I dont have to check if its still 
> working for the other user or not.
> I would create different apps for different types of users. And each app 
> would contain the endpoints for that particular user type.
> This is the best way I know. 
>
> Other way to do this, is to update the core GET, POST, PUT, Patch, etc 
> methods of the django/rest framework and return a diff response by checking 
> the user type.
> e.g. If you are overwriting the Update View in django rest framework, you 
> could overwrite the update method and check the user type after 
> perform_update() was called.
> And return a different response by checking the user type. It will work.
>
> I hope it helps :) 
>
> Cheers!
>
>
> On Monday, June 3, 2019 at 4:04:53 PM UTC+5:30, Harsh Gundecha wrote:
>>
>> what is recommended practice for serving same object to multiple types of 
>> users with slight change in output
>> for e.g book object or issued book object to lets say staff and students, 
>> is it a good idea to use same URL for both and serve by checking user type
>> PS: its a JSON based rest API in rest framework
>>
>> Thank you
>> Regards, Harsh
>>
>

-- 
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/afc3c264-0f2d-468f-a27b-e854016374c0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Orm Query for this type of situation

2019-06-06 Thread Devender Kumar
Hi,
I am working on CRM project and stuck with REPORTING part.

I have Accounts , Lead , contact, Calls ,Concern modules
account/Lead can have multiple contacts 
contacts have multiple calls and concerns 
calls have different status like Incoming outgoing missed call etc

Question 
I need to create a reporting system
In this I have to give a functionality like so
list of accounts with counts of :
 contacts, total calls,incoming, outgoing etc

 how can list all this count for a given date ranges calls on all accounts 



-- 
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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to migrate MySQL -> PostgreSQL?

2019-06-06 Thread Devender Kumar
Simple scripts :
Dump data 
python manage.py dumpdata  # this will whole database to single json 
python manage.py loaddata filename # this will populate the database with 
that json again 

On Tuesday, June 4, 2019 at 12:50:59 AM UTC+5:30, Victor Porton wrote:
>
> How to migrate a production database MySQL -> PostgreSQL?
>
> (MySQL has several bugs, I want to try something other on my production 
> server.)
>

-- 
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/39d3c382-53bd-4b33-ae69-cb6fed0aa88e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Orm Query for this type of situation

2019-06-06 Thread Chetan Ganji
Right now its an open ended question.

If you post code for your models here, someone can help you.

On Thu, Jun 6, 2019, 4:38 PM Devender Kumar  wrote:

> Hi,
> I am working on CRM project and stuck with REPORTING part.
>
> I have Accounts , Lead , contact, Calls ,Concern modules
> account/Lead can have multiple contacts
> contacts have multiple calls and concerns
> calls have different status like Incoming outgoing missed call etc
>
> Question
> I need to create a reporting system
> In this I have to give a functionality like so
> list of accounts with counts of :
>  contacts, total calls,incoming, outgoing etc
>
>  how can list all this count for a given date ranges calls on all accounts
>
>
>
> --
> 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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%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/CAMKMUjtMaEncd6LF1J%2BmgKxA_NpL1FLFz5_UXi_JMLDD%3Du52Vw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Annotations as models fields

2019-06-06 Thread Olivier Dalang
Thanks for the answer. As said, the @property + python method wouldn't work
for my use case, as I need to be able to use the field in the queryset to
filter/order (plus my actual computed field use aggregates expressions).

Cheers,

Olivier

On Thu, 6 Jun 2019 at 12:36, Chetan Ganji  wrote:

> I had a similar need in one of my clients project, I ended up using
> @property and a python method.
>
> AFAIK, AnnotationField is absent from django models. If you would like to
> write one, below is the material you need to refer.
> https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
> wrote:
>
>> Dear list,
>>
>> I was wondering whether there's a package or pattern to define
>> annotations as model fields, so that they could really be used as
>> database-side computed fields.
>>
>> Currently, I do something like this (not tested, it's a simplified case):
>>
>> class SalesManager(models.Manager):
>> def get_queryset(self):
>> return super().get_queryset().annotate(
>> profit=F("selling_price")-F("buying_price")
>> )
>>
>> class Sales(models.Model):
>> objects = SalesManager()
>>
>> buying_price = models.FloatField()
>> selling_price = models.FloatField()
>> ...
>>
>> Ideally, I'd see something like :
>>
>> class Sales(models.Model):
>> buying_price = models.FloatField()
>> selling_price = models.FloatField()
>> profit = models.AnnotationField(F("selling_price")-F("buying_price"))
>> ...
>>
>> An AnnotationField would behave like a read-only field, excepted that it
>> wouldn't have a database column.
>>
>> This would have the following benefits :
>> - much less verbose
>> - all instance related stuff in one place
>> - it would make it possible to refer to "profit" as a model field
>> - you could use the field in Meta.ordering
>> - you could easily display in django.admin without additional methods
>>
>> Of course similar result can be achieved with @property and a python
>> method, but I really need this to be on the database side to use
>> subqueries, sorting and filtering, etc.
>>
>> Does anything like this exist ? Is it possible to emulate this behaviour
>> somehow ?
>>
>> Thanks !!
>>
>> Olivier
>>
>>
>> --
>> 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/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%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/CAMKMUjscehKiqt4Gcu3Cnm%2BHKhH8Y98RnGhR6chVZ7NS5qc-sw%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/CAExk7p1PBMC7rR4iBu_80pwTBoie4NydB9gk0jKAqOqNwCGhZQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


mod_wsgi problem

2019-06-06 Thread Davin Pore
how able to resolve this issue. I tried to install the mod_wsgi on manual 
procedure.

[image: mod_wsgi.jpg]

-- 
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/d56ff442-ac07-4328-a6b0-b4bee64095d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django unable to write to an NFS share

2019-06-06 Thread Win Thor
In case anyone else runs into this. You can fix this by using NFSv4. There 
are issues with file locking and if you don't have statd running with NFSv3 
to help manage lock status for files then you'll run into these types of 
issues. I was having this same issue and had to update my NFS server to 
ONLY use NFSv4. Once I did this, I didn't have the issue anymore.




On Friday, April 13, 2012 at 8:48:23 AM UTC-7, Bastian wrote:
>
> ok I just gave up using NFS, it's just too much hassle, making sure the 
> ports are static, configuring iptables and then permissions problems... I 
> switched to sshfs and it just worked straight away :)
> Now I don't know if it is a very good option for sharing the user-media 
> folder, any idea?
>
> On Friday, April 13, 2012 11:22:48 AM UTC+2, Bastian wrote:
>>
>> Hi,
>>
>> I have a working Django project and I am trying to add a second server. 
>> In the process I am making an NFS share on one server. The Apache instances 
>> on this server (the NFS host) can write (mostly images) to this directory 
>> but the other server (the NFS client) seems unable. Actually from this 
>> second server I changed the permissions of the share to 777 just to make 
>> sure and still root can write but www-data can only create file, it is 
>> denied the right to write them. Very strange situation that I don't 
>> understand. Searching this group and Google led me to few information. 
>> There is this lock issue thing that I'm not sure to understand if it has 
>> been fixed. Any clue is welcome. I'm using Debian Squeeze, Django 1.3 and 
>> this is the options I use in the export: 
>> rw,sync,no_root_squash,no_subtree_check,insecure
>>
>> Thanks,
>> Bastian
>>
>

-- 
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/0131d23a-8d52-4c1a-9a81-123d2a600900%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: mod_wsgi problem

2019-06-06 Thread Joel Mathew
Always read installation README and github README before installing
anything. It seems you dont even have a basic compiler installed.

For Debian based systems, install:

`sudo apt install build-essential`
Sincerely yours,

 Joel G Mathew



On Thu, 6 Jun 2019 at 17:09, Davin Pore  wrote:

> how able to resolve this issue. I tried to install the mod_wsgi on manual
> procedure.
>
> [image: mod_wsgi.jpg]
>
> --
> 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/d56ff442-ac07-4328-a6b0-b4bee64095d5%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/CAA%3Diw_9ngHcA-d1Me9uNfEiohxBcZLhWf6txj4%3Dm13QrOq8tKg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: mod_wsgi problem

2019-06-06 Thread Kasper Laudrup
On June 6, 2019 4:51:49 AM GMT+02:00, Davin Pore  wrote:
>how able to resolve this issue. I tried to install the mod_wsgi on
>manual 
>procedure.
>
>[image: mod_wsgi.jpg]
>
>-- 
>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/d56ff442-ac07-4328-a6b0-b4bee64095d5%40googlegroups.com.
>For more options, visit https://groups.google.com/d/optout.

Hi David,

First of all, I don't understand why you want to install mod_wsgi from source. 
I'm sure your Linux distro has a package for that.

But as the error message states, you need at least a functional C compiler to 
compile C code (eg. Clang or GCC). You'll most likely also need some dev 
packages etc. How to install the required packages depends on the Linux distro 
you are using.

Also, there's probably an INSTALL file with the sources which you should read 
first. That hopefully tells you the requirements and how to build and install 
the module.

Hope that helps.

Kind regards,

Kasper Laudrup

-- 
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/2755E270-9488-44B9-B6DE-754C0E76AA34%40stacktrace.dk.
For more options, visit https://groups.google.com/d/optout.


Re: Annotations as models fields

2019-06-06 Thread Chetan Ganji
I think this would solve your problem. Whatever calculations needs to be
done, you can do it manually before saving the Sales instance.
Preferably after checking if form.is_valid() in case of django and in the
function perform_create() in case of django rest framework.


class Sales(models.Model):
buying_price = models.FloatField()
selling_price = models.FloatField()
profit = models.models.FloatField()


Cheers!


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 4:50 PM Olivier Dalang 
wrote:

> Thanks for the answer. As said, the @property + python method wouldn't
> work for my use case, as I need to be able to use the field in the queryset
> to filter/order (plus my actual computed field use aggregates expressions).
>
> Cheers,
>
> Olivier
>
> On Thu, 6 Jun 2019 at 12:36, Chetan Ganji  wrote:
>
>> I had a similar need in one of my clients project, I ended up using
>> @property and a python method.
>>
>> AFAIK, AnnotationField is absent from django models. If you would like to
>> write one, below is the material you need to refer.
>> https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
>> wrote:
>>
>>> Dear list,
>>>
>>> I was wondering whether there's a package or pattern to define
>>> annotations as model fields, so that they could really be used as
>>> database-side computed fields.
>>>
>>> Currently, I do something like this (not tested, it's a simplified case):
>>>
>>> class SalesManager(models.Manager):
>>> def get_queryset(self):
>>> return super().get_queryset().annotate(
>>> profit=F("selling_price")-F("buying_price")
>>> )
>>>
>>> class Sales(models.Model):
>>> objects = SalesManager()
>>>
>>> buying_price = models.FloatField()
>>> selling_price = models.FloatField()
>>> ...
>>>
>>> Ideally, I'd see something like :
>>>
>>> class Sales(models.Model):
>>> buying_price = models.FloatField()
>>> selling_price = models.FloatField()
>>> profit = models.AnnotationField(F("selling_price")-F("buying_price"))
>>> ...
>>>
>>> An AnnotationField would behave like a read-only field, excepted that it
>>> wouldn't have a database column.
>>>
>>> This would have the following benefits :
>>> - much less verbose
>>> - all instance related stuff in one place
>>> - it would make it possible to refer to "profit" as a model field
>>> - you could use the field in Meta.ordering
>>> - you could easily display in django.admin without additional methods
>>>
>>> Of course similar result can be achieved with @property and a python
>>> method, but I really need this to be on the database side to use
>>> subqueries, sorting and filtering, etc.
>>>
>>> Does anything like this exist ? Is it possible to emulate this behaviour
>>> somehow ?
>>>
>>> Thanks !!
>>>
>>> Olivier
>>>
>>>
>>> --
>>> 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/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%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/CAMKMUjscehKiqt4Gcu3Cnm%2BHKhH8Y98RnGhR6chVZ7NS5qc-sw%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/CAExk7p1PBMC7rR4iBu_80pwTBoie4

Re: Annotations as models fields

2019-06-06 Thread Olivier Dalang
Thanks Chetan for trying to help, but please read carefully the issue, as
you didn't understand what I'm trying to do.

In the meantime, and for the record, I found this, which works for simple
cases.  https://github.com/schinckel/django-computed-field

On Thu, 6 Jun 2019 at 14:57, Chetan Ganji  wrote:

> I think this would solve your problem. Whatever calculations needs to be
> done, you can do it manually before saving the Sales instance.
> Preferably after checking if form.is_valid() in case of django and in the
> function perform_create() in case of django rest framework.
>
>
> class Sales(models.Model):
> buying_price = models.FloatField()
> selling_price = models.FloatField()
> profit = models.models.FloatField()
>
>
> Cheers!
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Thu, Jun 6, 2019 at 4:50 PM Olivier Dalang 
> wrote:
>
>> Thanks for the answer. As said, the @property + python method wouldn't
>> work for my use case, as I need to be able to use the field in the queryset
>> to filter/order (plus my actual computed field use aggregates expressions).
>>
>> Cheers,
>>
>> Olivier
>>
>> On Thu, 6 Jun 2019 at 12:36, Chetan Ganji  wrote:
>>
>>> I had a similar need in one of my clients project, I ended up using
>>> @property and a python method.
>>>
>>> AFAIK, AnnotationField is absent from django models. If you would like
>>> to write one, below is the material you need to refer.
>>> https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/
>>>
>>>
>>> Regards,
>>> Chetan Ganji
>>> +91-900-483-4183
>>> ganji.che...@gmail.com
>>> http://ryucoder.in
>>>
>>>
>>> On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
>>> wrote:
>>>
 Dear list,

 I was wondering whether there's a package or pattern to define
 annotations as model fields, so that they could really be used as
 database-side computed fields.

 Currently, I do something like this (not tested, it's a simplified
 case):

 class SalesManager(models.Manager):
 def get_queryset(self):
 return super().get_queryset().annotate(
 profit=F("selling_price")-F("buying_price")
 )

 class Sales(models.Model):
 objects = SalesManager()

 buying_price = models.FloatField()
 selling_price = models.FloatField()
 ...

 Ideally, I'd see something like :

 class Sales(models.Model):
 buying_price = models.FloatField()
 selling_price = models.FloatField()
 profit = models.AnnotationField(F("selling_price")-F("buying_price"))
 ...

 An AnnotationField would behave like a read-only field, excepted that
 it wouldn't have a database column.

 This would have the following benefits :
 - much less verbose
 - all instance related stuff in one place
 - it would make it possible to refer to "profit" as a model field
 - you could use the field in Meta.ordering
 - you could easily display in django.admin without additional
 methods

 Of course similar result can be achieved with @property and a python
 method, but I really need this to be on the database side to use
 subqueries, sorting and filtering, etc.

 Does anything like this exist ? Is it possible to emulate this
 behaviour somehow ?

 Thanks !!

 Olivier


 --
 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/CAExk7p3eXvCUCxB3LgZJHTrVXzLuD%3DNqUE79a-dqtUXzekXgJg%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/CAMKMUjscehKiqt4Gcu3Cnm%2BHKhH8Y98RnGhR6chVZ7NS5qc-sw%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> You received this message

Import circular

2019-06-06 Thread Fabio O da silva
django.core.exceptions.ImproperlyConfigured: The included URLconf 
'simplemooc.urls' does not appear to have any patterns in it. If you see 
valid patterns in the file then the issue is probably caused by a circular 
import.

-- 
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/cc298740-3e54-487b-8ec4-9a0be431a3fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Orm Query for this type of situation

2019-06-06 Thread Devender Kumar
Account /Lead Model
 account_name
 contact m2m realtion

contact Model
name
phone No

calls Model
caller no # person phone no who is calling
agent no #  person who is picking the call (CRM user)
status 
timestamp
duration

calls model is populated with some third party software and we are map its
caller no and agent no their is no direct relationship

I want to get the list of accounts in particular date range  with:
total no of contact it have ,
how many time its contact have called
how many calls where missed inbound outbound etc














On Thu, Jun 6, 2019 at 4:49 PM Chetan Ganji  wrote:

> Right now its an open ended question.
>
> If you post code for your models here, someone can help you.
>
> On Thu, Jun 6, 2019, 4:38 PM Devender Kumar  wrote:
>
>> Hi,
>> I am working on CRM project and stuck with REPORTING part.
>>
>> I have Accounts , Lead , contact, Calls ,Concern modules
>> account/Lead can have multiple contacts
>> contacts have multiple calls and concerns
>> calls have different status like Incoming outgoing missed call etc
>>
>> Question
>> I need to create a reporting system
>> In this I have to give a functionality like so
>> list of accounts with counts of :
>>  contacts, total calls,incoming, outgoing etc
>>
>>  how can list all this count for a given date ranges calls on all
>> accounts
>>
>>
>>
>> --
>> 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/1cb5c003-7cbc-4d54-ae5b-21403e543b95%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/CAMKMUjtMaEncd6LF1J%2BmgKxA_NpL1FLFz5_UXi_JMLDD%3Du52Vw%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/CALmCJr7ApqHCCsm73t%3DiuvzOYwE44Vh7pcdpH2bNkb-aH015fw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Import circular

2019-06-06 Thread Joe Reitman
Can you post your views.py, urls.py and template?

On Thursday, June 6, 2019 at 9:18:22 AM UTC-5, Fabio O da silva wrote:
>
> django.core.exceptions.ImproperlyConfigured: The included URLconf 
> 'simplemooc.urls' does not appear to have any patterns in it. If you see 
> valid patterns in the file then the issue is probably caused by a circular 
> import.
>
>

-- 
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/480664b9-d779-419d-8cbe-c4ea2aadb8a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Annotations as models fields

2019-06-06 Thread Chetan Ganji
Yes Olivier, You are right :P

If I understand the problem correctly this time, you want the field
available on django model, but does not want the python to do the
calculation.
You want the database to compute the value.

If yes, you could use a row level trigger i.e after create and after update
trigger. PostgreSQL supports it.


class Sales(models.Model):
buying_price = models.FloatField()
selling_price = models.FloatField()
profit = models.models.FloatField(null=True, blank=True)


*For your reference - *
*RE: SQL Triggers*
http://www.postgresqltutorial.com/introduction-postgresql-trigger/

*RE: database-side computed fields*
Instead of concatenation as in the below example, you would do some other
operation and/or aggregation which would be calculated by the database.
https://dba.stackexchange.com/questions/21897/set-a-columns-default-value-to-the-concatenation-of-two-other-columns-values


If it works, as it would be on database level, you have to document it in
the readme file of your project.
Otherwise, next developer on the project might not know about the trigger
and bang his head on the floor like I did earlier, lolz :P

I hope it helps this time :P


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 6:57 PM Olivier Dalang 
wrote:

> Thanks Chetan for trying to help, but please read carefully the issue, as
> you didn't understand what I'm trying to do.
>
> In the meantime, and for the record, I found this, which works for simple
> cases.  https://github.com/schinckel/django-computed-field
>
> On Thu, 6 Jun 2019 at 14:57, Chetan Ganji  wrote:
>
>> I think this would solve your problem. Whatever calculations needs to be
>> done, you can do it manually before saving the Sales instance.
>> Preferably after checking if form.is_valid() in case of django and in the
>> function perform_create() in case of django rest framework.
>>
>>
>> class Sales(models.Model):
>> buying_price = models.FloatField()
>> selling_price = models.FloatField()
>> profit = models.models.FloatField()
>>
>>
>> Cheers!
>>
>>
>> Regards,
>> Chetan Ganji
>> +91-900-483-4183
>> ganji.che...@gmail.com
>> http://ryucoder.in
>>
>>
>> On Thu, Jun 6, 2019 at 4:50 PM Olivier Dalang 
>> wrote:
>>
>>> Thanks for the answer. As said, the @property + python method wouldn't
>>> work for my use case, as I need to be able to use the field in the queryset
>>> to filter/order (plus my actual computed field use aggregates expressions).
>>>
>>> Cheers,
>>>
>>> Olivier
>>>
>>> On Thu, 6 Jun 2019 at 12:36, Chetan Ganji 
>>> wrote:
>>>
 I had a similar need in one of my clients project, I ended up using
 @property and a python method.

 AFAIK, AnnotationField is absent from django models. If you would like
 to write one, below is the material you need to refer.
 https://docs.djangoproject.com/en/2.2/howto/custom-model-fields/


 Regards,
 Chetan Ganji
 +91-900-483-4183
 ganji.che...@gmail.com
 http://ryucoder.in


 On Thu, Jun 6, 2019 at 3:36 PM Olivier Dalang 
 wrote:

> Dear list,
>
> I was wondering whether there's a package or pattern to define
> annotations as model fields, so that they could really be used as
> database-side computed fields.
>
> Currently, I do something like this (not tested, it's a simplified
> case):
>
> class SalesManager(models.Manager):
> def get_queryset(self):
> return super().get_queryset().annotate(
> profit=F("selling_price")-F("buying_price")
> )
>
> class Sales(models.Model):
> objects = SalesManager()
>
> buying_price = models.FloatField()
> selling_price = models.FloatField()
> ...
>
> Ideally, I'd see something like :
>
> class Sales(models.Model):
> buying_price = models.FloatField()
> selling_price = models.FloatField()
> profit = models.AnnotationField(F("selling_price")-F("buying_price"))
> ...
>
> An AnnotationField would behave like a read-only field, excepted that
> it wouldn't have a database column.
>
> This would have the following benefits :
> - much less verbose
> - all instance related stuff in one place
> - it would make it possible to refer to "profit" as a model field
> - you could use the field in Meta.ordering
> - you could easily display in django.admin without additional
> methods
>
> Of course similar result can be achieved with @property and a python
> method, but I really need this to be on the database side to use
> subqueries, sorting and filtering, etc.
>
> Does anything like this exist ? Is it possible to emulate this
> behaviour somehow ?
>
> Thanks !!
>
> Olivier
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To unsubscribe from this group and stop receiving emails

Django, integration of code and sigma compatibility

2019-06-06 Thread trizalvi
Hello, 

I'm new at this subject. I have html/javascript codes using sigma.js and I 
was thinking about starting to use Django. I would like to know if I can 
integrate my code easily into Django and if it is compatible with sigma.js. 

Thank you in advance!

Have a nice day ^^


-- 
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/ea8aec37-2802-44f5-b52b-14153070eb54%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Deployments

2019-06-06 Thread Soumen Khatua
Hi Folks,

I develope one project using django in my localhost. Now how I can deploy
that project into digital ocean and what are changes I need to do in my
project for moving to production server. Please help I have no idea
regarding this matter.
Thank You.

Regards,
Soumen

-- 
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/CAPUw6WbQ_zCf2xUeCH5%2BQ57b7c4%3D-FC-CAh_-AJdTE5gcoUR%3DQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Import circular

2019-06-06 Thread Fabio O da silva
urls.py



[image: Mailtrack]

Remetente
notificado por
Mailtrack

06/06/19,
02:11:53 PM

On Thu, Jun 6, 2019 at 11:47 AM Joe Reitman  wrote:

> Can you post your views.py, urls.py and template?
>
> On Thursday, June 6, 2019 at 9:18:22 AM UTC-5, Fabio O da silva wrote:
>>
>> django.core.exceptions.ImproperlyConfigured: The included URLconf
>> 'simplemooc.urls' does not appear to have any patterns in it. If you see
>> valid patterns in the file then the issue is probably caused by a circular
>> import.
>>
>> --
> 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/480664b9-d779-419d-8cbe-c4ea2aadb8a4%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/CAFZF8WdSdWVQpN7HeTVNyMXoj%3DXhPa8ryx2bsMW3HeiQB8JOHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


user Form error

2019-06-06 Thread anchal agarwal
Hello,
I am making a simple user form but my form data is not saving.It is showing
this error
'UserForm' object has no attribute 'save'
Here is my code. Please tell me where i am wrong
views.py
class UserFormView(View):
form_class=UserForm
template_name='music/registration_form.html'

#display blank form
def get(self , request):
form=self.form_class(None)
return render(request,self.template_name,{'form':form})

#process from data
def post(self, request):
form=self.form_class(request.POST)

if form.is_valid():
user=form.save(commit=False)

#cleaned (normalized) data
username=form.cleaned_data['username']
password=form.cleaned_data['password']
user.set_password(password)
user.save()

#returns User objects if credentials are correct

user=authenticate(username=username,password=password)

if user is not None:

if user.is_active:
login(request,user)
return redirect('music:index')
return render(request,self.template_name,{'form':form})

forms.py
from django import forms
from django.contrib.auth.models import User

class UserForm(forms.Form):
password=forms.CharField(wiget = forms.PasswordInput)
class Meta:
model=User
fields=['username','email','password']

-- 
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/CAMT%3DisXLE0z7ADcBzB-LhDf%2BU9_ZNVrhitBAVrSDwQCSKEfNZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: user Form error

2019-06-06 Thread terry frank
Hello,  from which repos ?

On Thu, Jun 6, 2019 at 7:50 PM anchal agarwal 
wrote:

> Hello,
> I am making a simple user form but my form data is not saving.It is
> showing this error
> 'UserForm' object has no attribute 'save'
> Here is my code. Please tell me where i am wrong
> views.py
> class UserFormView(View):
> form_class=UserForm
> template_name='music/registration_form.html'
>
> #display blank form
> def get(self , request):
> form=self.form_class(None)
> return render(request,self.template_name,{'form':form})
>
> #process from data
> def post(self, request):
> form=self.form_class(request.POST)
>
> if form.is_valid():
> user=form.save(commit=False)
>
> #cleaned (normalized) data
> username=form.cleaned_data['username']
> password=form.cleaned_data['password']
> user.set_password(password)
> user.save()
>
> #returns User objects if credentials are correct
>
> user=authenticate(username=username,password=password)
>
> if user is not None:
>
> if user.is_active:
> login(request,user)
> return redirect('music:index')
> return render(request,self.template_name,{'form':form})
>
> forms.py
> from django import forms
> from django.contrib.auth.models import User
>
> class UserForm(forms.Form):
> password=forms.CharField(wiget = forms.PasswordInput)
> class Meta:
> model=User
> fields=['username','email','password']
>
> --
> 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/CAMT%3DisXLE0z7ADcBzB-LhDf%2BU9_ZNVrhitBAVrSDwQCSKEfNZg%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/CACGjKra8_nF%2BcymQogX9Y0iQbNt0nG9mLWv6kfB_4OVJB-HC1Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: user Form error

2019-06-06 Thread Chetan Ganji
Hi Anchal

PFA
https://stackoverflow.com/questions/9061846/attributeerror-at-registration-userform-object-has-no-attribute-save


.save() method is available on forms.ModelForm; not on forms.Form

Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Fri, Jun 7, 2019 at 12:02 AM terry frank  wrote:

> Hello,  from which repos ?
>
> On Thu, Jun 6, 2019 at 7:50 PM anchal agarwal 
> wrote:
>
>> Hello,
>> I am making a simple user form but my form data is not saving.It is
>> showing this error
>> 'UserForm' object has no attribute 'save'
>> Here is my code. Please tell me where i am wrong
>> views.py
>> class UserFormView(View):
>> form_class=UserForm
>> template_name='music/registration_form.html'
>>
>> #display blank form
>> def get(self , request):
>> form=self.form_class(None)
>> return render(request,self.template_name,{'form':form})
>>
>> #process from data
>> def post(self, request):
>> form=self.form_class(request.POST)
>>
>> if form.is_valid():
>> user=form.save(commit=False)
>>
>> #cleaned (normalized) data
>> username=form.cleaned_data['username']
>> password=form.cleaned_data['password']
>> user.set_password(password)
>> user.save()
>>
>> #returns User objects if credentials are correct
>>
>> user=authenticate(username=username,password=password)
>>
>> if user is not None:
>>
>> if user.is_active:
>> login(request,user)
>> return redirect('music:index')
>> return render(request,self.template_name,{'form':form})
>>
>> forms.py
>> from django import forms
>> from django.contrib.auth.models import User
>>
>> class UserForm(forms.Form):
>> password=forms.CharField(wiget = forms.PasswordInput)
>> class Meta:
>> model=User
>> fields=['username','email','password']
>>
>> --
>> 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/CAMT%3DisXLE0z7ADcBzB-LhDf%2BU9_ZNVrhitBAVrSDwQCSKEfNZg%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/CACGjKra8_nF%2BcymQogX9Y0iQbNt0nG9mLWv6kfB_4OVJB-HC1Q%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/CAMKMUjvyOVUrjO-X-iAQE4UwhEzOvMBtwryj0iy7xZceQmxguw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Deployments

2019-06-06 Thread Chetan Ganji
https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04



Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 10:33 PM Soumen Khatua 
wrote:

> Hi Folks,
>
> I develope one project using django in my localhost. Now how I can deploy
> that project into digital ocean and what are changes I need to do in my
> project for moving to production server. Please help I have no idea
> regarding this matter.
> Thank You.
>
> Regards,
> Soumen
>
> --
> 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/CAPUw6WbQ_zCf2xUeCH5%2BQ57b7c4%3D-FC-CAh_-AJdTE5gcoUR%3DQ%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/CAMKMUjsAfH-rB1cJW%2BbKh8Ldf9%3D%3DbntfvjTOibKMzm9DSKdGFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Import circular

2019-06-06 Thread 'Alex Mesias Diaz Toro' via Django users
Hi Fabio,
Did you solve this problem?
Ty

El jue., 6 jun. 2019 a las 12:12, Fabio O da silva ()
escribió:

> urls.py
>
>
>
> [image: Mailtrack]
> 
>  Remetente
> notificado por
> Mailtrack
> 
>  06/06/19,
> 02:11:53 PM
>
> On Thu, Jun 6, 2019 at 11:47 AM Joe Reitman  wrote:
>
>> Can you post your views.py, urls.py and template?
>>
>> On Thursday, June 6, 2019 at 9:18:22 AM UTC-5, Fabio O da silva wrote:
>>>
>>> django.core.exceptions.ImproperlyConfigured: The included URLconf
>>> 'simplemooc.urls' does not appear to have any patterns in it. If you see
>>> valid patterns in the file then the issue is probably caused by a circular
>>> import.
>>>
>>> --
>> 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/480664b9-d779-419d-8cbe-c4ea2aadb8a4%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/CAFZF8WdSdWVQpN7HeTVNyMXoj%3DXhPa8ryx2bsMW3HeiQB8JOHQ%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/CAGSrrc6g2NMugAv8Q2%2B7Sk0r_6nfEN9X%3DEXqTKA%2BFaOn4b-cYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multitentant login

2019-06-06 Thread Chetan Ganji
Oh yes, this one is possible.

Do you want to know if this is possible or how to actually implement it??

I have implemented a solution to solve exactly the same problem.
Let me know if you want to know the one that I implemented.


Regards,
Chetan Ganji
+91-900-483-4183
ganji.che...@gmail.com
http://ryucoder.in


On Thu, Jun 6, 2019 at 5:38 AM Sebastian Jung 
wrote:

> Hello,
>
> i have a Login Form with 3 Fields: Mandatename, Username and Password. Now
> the user login now with a Mandatename. There are a global database where
> there are a relation between mandate name and a further database. All
> Querys now from this User goes then to this database.
>
> Example:
>
> User A login with Mandatename Mandate_A. In global Database there are a
> entry Mandate_A to Database with Name "1". Now i want that all querys from
> request from User A to Database 1 goes. Another User B Login with
> Mandate_B. In global Database there are a Entry to Database "2". All Querys
> from this User goes to Database 2.
>
> Is this possible?
>
> Regards
>
> --
> 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/b8bc6fb3-f453-4b5c-a39d-31b39dc73b9e%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/CAMKMUjt%2BZMPS%3DmOHhmTaiUTLfMXo9gejp6C1fZfZEORk152zGQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Import circular

2019-06-06 Thread Fabio O da silva
not



[image: Mailtrack]

Remetente
notificado por
Mailtrack

06/06/19,
06:28:46 PM

On Thu, Jun 6, 2019 at 5:25 PM 'Alex Mesias Diaz Toro' via Django users <
django-users@googlegroups.com> wrote:

> Hi Fabio,
> Did you solve this problem?
> Ty
>
> El jue., 6 jun. 2019 a las 12:12, Fabio O da silva (<
> fabio7silv...@gmail.com>) escribió:
>
>> urls.py
>>
>>
>>
>> [image: Mailtrack]
>> 
>>  Remetente
>> notificado por
>> Mailtrack
>> 
>>  06/06/19,
>> 02:11:53 PM
>>
>> On Thu, Jun 6, 2019 at 11:47 AM Joe Reitman  wrote:
>>
>>> Can you post your views.py, urls.py and template?
>>>
>>> On Thursday, June 6, 2019 at 9:18:22 AM UTC-5, Fabio O da silva wrote:

 django.core.exceptions.ImproperlyConfigured: The included URLconf
 'simplemooc.urls' does not appear to have any patterns in it. If you see
 valid patterns in the file then the issue is probably caused by a circular
 import.

 --
>>> 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/480664b9-d779-419d-8cbe-c4ea2aadb8a4%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/CAFZF8WdSdWVQpN7HeTVNyMXoj%3DXhPa8ryx2bsMW3HeiQB8JOHQ%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/CAGSrrc6g2NMugAv8Q2%2B7Sk0r_6nfEN9X%3DEXqTKA%2BFaOn4b-cYA%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/CAFZF8Wf_0wYvXiP-C8re9%3DADH_UW821peq8o%2ByyECR%2BF8prdKw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Is it possible to check the existence of Group in Django Channel ?

2019-06-06 Thread Arean Bbay
I would like to make a channel to be able to check if a group exists, so 
that it can join.

-- 
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/3d1b7650-35c7-46be-983c-be491f2b756f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How to fix: Django forms: {{ form }} is not working in a dynamic html page

2019-06-06 Thread Majid Rafiee
I've created a form in Django:

#forms.py
from django import forms


class ContactForm(forms.Form):
name = forms.CharField()
number = forms.FloatField()
eail_user = forms.EmailField()


and imported in in views.py

#views.pyfrom django.shortcuts import renderfrom .models import Cardsfrom 
cards.forms import ContactForm

def index(request):
cards = Cards.objects.all()
return render(request,'card.html', {'cards':cards})

def contact(request):
form = ContactForm()
return render(request,'card.html', {'form': form})

This is my base.html

#base.html
{%  load staticfiles %}









Title




OUR TEAM

{% block content %}
{% endblock %}







And here is the card.html that is extended from base.html

#card.html
{% extends 'base.html' %}

{% block content %}

{% for card in cards %}







https://sunlimetech.com/portfolio/boot4menu/assets/imgs/team/img_01.png";
alt="card image">
{{ card.name }}
{{ card.description }}







{{ card.name }}


{% csrf_token %}
{{ form }}
































{% endfor %}

{% endblock %}


As you may notice, I've called form by {{ form }} inside  tag in 
card.html but the issue is that it just shows a Submit botton and ignores 
{{ form }}. Any idea how to solve the issue?
I also bring urls.py in cards app and main urls:
#urls.py in cards
from django.urls import path
from . import views


urlpatterns = [
 path('', views.index),
 path('form/', views.contact),
]


#urls.py in main directory

from django.contrib import admin
from django.urls import path, include


urlpatterns = [
 path('admin/', admin.site.urls),
 path('calculator_one_input/', include('calculator_one_input.urls')),
 path('cards/', include('cards.urls')),
 path('cards/form/', include('cards.urls')),
]


I looked for a solution for three days and still I have no idea how to 
solve this issue. I will be so appreciated if someone give me a clear clue 
how to solve. 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/014f5076-7281-4183-9c96-54900bf796c3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix: Django forms: {{ form }} is not working in a dynamic html page

2019-06-06 Thread Joe Reitman
Interesting problem. It won't display because the form is inside a 
for-loop. Django Template language looks at variables inside a for-loop 
differently. Basically it looks for a collection. Since {{ form }} is not a 
collection, it just ignores it.

I'm not sure how you can create multiple forms like that. But I would be 
interested in knowing. 


On Thursday, June 6, 2019 at 6:14:57 PM UTC-5, Majid Rafiee wrote:
>
> I've created a form in Django:
>
> #forms.py
> from django import forms
>
>
> class ContactForm(forms.Form):
> name = forms.CharField()
> number = forms.FloatField()
> eail_user = forms.EmailField()
>
>
> and imported in in views.py
>
> #views.pyfrom django.shortcuts import renderfrom .models import Cardsfrom 
> cards.forms import ContactForm
>
> def index(request):
> cards = Cards.objects.all()
> return render(request,'card.html', {'cards':cards})
>
> def contact(request):
> form = ContactForm()
> return render(request,'card.html', {'form': form})
>
> This is my base.html
>
> #base.html
> {%  load staticfiles %}
> 
> 
> 
>  href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
> rel="stylesheet" id="bootstrap-css">
>  src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js">
>  src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
>  type="text/css">
> 
> 
> Title
> 
> 
> 
> 
> OUR TEAM
> 
> {% block content %}
> {% endblock %}
> 
> 
> 
> 
> 
>
>
> And here is the card.html that is extended from base.html
>
> #card.html
> {% extends 'base.html' %}
>
> {% block content %}
> 
> {% for card in cards %}
> 
> 
>  ontouchstart="this.classList.toggle('hover');">
> 
> 
> 
> 
>  
> src="https://sunlimetech.com/portfolio/boot4menu/assets/imgs/team/img_01.png";
> alt="card image">
> {{ card.name }}
> {{ card.description 
> }}
>  class="fa fa-plus">
> 
> 
> 
> 
> 
> 
> {{ card.name }}
> 
> 
> {% csrf_token %}
> {{ form }}
> 
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
>  target="_blank" href="#">
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> {% endfor %}
>
> {% endblock %}
>
>
> As you may notice, I've called form by {{ form }} inside  tag in 
> card.html but the issue is that it just shows a Submit botton and ignores 
> {{ form }}. Any idea how to solve the issue?
> I also bring urls.py in cards app and main urls:
> #urls.py in cards
> from django.urls import path
> from . import views
>
>
> urlpatterns = [
>  path('', views.index),
>  path('form/', views.contact),
> ]
>
>
> #urls.py in main directory
>
> from django.contrib import admin
> from django.urls import path, include
>
>
> urlpatterns = [
>  path('admin/', admin.site.urls),
>  path('calculator_one_input/', include('calculator_one_input.urls')),
>  path('cards/', include('cards.urls')),
>  path('cards/form/', include('cards.urls')),
> ]
>
>
> I looked for a solution for three days and still I have no idea how to 
> solve this issue. I will be so appreciated if someone give me a clear clue 
> how to solve. Thanks
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsu

Re: Deployments

2019-06-06 Thread Soumen Khatua
In this tutorial I think they are covering about a how we can create new
project in digital ocean but I have already one project in my local
machine. How I can upload that project into server??

Thank you for your support.

On Fri, 7 Jun 2019, 01:24 Chetan Ganji,  wrote:

>
> https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
>
>
>
> Regards,
> Chetan Ganji
> +91-900-483-4183
> ganji.che...@gmail.com
> http://ryucoder.in
>
>
> On Thu, Jun 6, 2019 at 10:33 PM Soumen Khatua 
> wrote:
>
>> Hi Folks,
>>
>> I develope one project using django in my localhost. Now how I can deploy
>> that project into digital ocean and what are changes I need to do in my
>> project for moving to production server. Please help I have no idea
>> regarding this matter.
>> Thank You.
>>
>> Regards,
>> Soumen
>>
>> --
>> 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/CAPUw6WbQ_zCf2xUeCH5%2BQ57b7c4%3D-FC-CAh_-AJdTE5gcoUR%3DQ%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/CAMKMUjsAfH-rB1cJW%2BbKh8Ldf9%3D%3DbntfvjTOibKMzm9DSKdGFg%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/CAPUw6WbidHAsiPDHY%3D3JvpLZ4fD1URiu-7t%3DEpf4PTmpavDuFg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to fix: Django forms: {{ form }} is not working in a dynamic html page

2019-06-06 Thread Joe Reitman
Update. 

You can do this by hard coding the HTML form in the template. If you want 
to gather the data a user enters, each form will have to be uniquely 
identifiable and your view will have to determine which form its getting 
post data from. You can put the card index number in the button value and 
code your view to handle it based on the button value. 


On Thursday, June 6, 2019 at 11:07:18 PM UTC-5, Joe Reitman wrote:
>
> Interesting problem. It won't display because the form is inside a 
> for-loop. Django Template language looks at variables inside a for-loop 
> differently. Basically it looks for a collection. Since {{ form }} is not a 
> collection, it just ignores it.
>
> I'm not sure how you can create multiple forms like that. But I would be 
> interested in knowing. 
>
>
> On Thursday, June 6, 2019 at 6:14:57 PM UTC-5, Majid Rafiee wrote:
>>
>> I've created a form in Django:
>>
>> #forms.py
>> from django import forms
>>
>>
>> class ContactForm(forms.Form):
>> name = forms.CharField()
>> number = forms.FloatField()
>> eail_user = forms.EmailField()
>>
>>
>> and imported in in views.py
>>
>> #views.pyfrom django.shortcuts import renderfrom .models import Cardsfrom 
>> cards.forms import ContactForm
>>
>> def index(request):
>> cards = Cards.objects.all()
>> return render(request,'card.html', {'cards':cards})
>>
>> def contact(request):
>> form = ContactForm()
>> return render(request,'card.html', {'form': form})
>>
>> This is my base.html
>>
>> #base.html
>> {%  load staticfiles %}
>> 
>> 
>> 
>> > href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" 
>> rel="stylesheet" id="bootstrap-css">
>> > src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js">
>> > src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js">
>> > type="text/css">
>> 
>> 
>> Title
>> 
>> 
>> 
>> 
>> OUR TEAM
>> 
>> {% block content %}
>> {% endblock %}
>> 
>> 
>> 
>> 
>> 
>>
>>
>> And here is the card.html that is extended from base.html
>>
>> #card.html
>> {% extends 'base.html' %}
>>
>> {% block content %}
>> 
>> {% for card in cards %}
>> 
>> 
>> > ontouchstart="this.classList.toggle('hover');">
>> 
>> 
>> 
>> 
>> > 
>> src="https://sunlimetech.com/portfolio/boot4menu/assets/imgs/team/img_01.png";
>> alt="card image">
>> {{ card.name }}
>> {{ card.description 
>> }}
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> {{ card.name }}
>> 
>> 
>> {% csrf_token %}
>> {{ form }}
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> {% endfor %}
>>
>> {% endblock %}
>>
>>
>> As you may notice, I've called form by {{ form }} inside  tag in 
>> card.html but the issue is that it just shows a Submit botton and ignores 
>> {{ form }}. Any idea how to solve the issue?
>> I also bring urls.py in cards app and main urls:
>> #urls.py in cards
>> from django.urls import path
>> from . import views
>>
>>
>> urlpatterns = [
>>  path('', views.index),
>>  path('form/', views.contact),
>> ]
>>
>>
>> #urls.py in main directory
>>
>> from django.contrib import admin
>> from django.urls import path, include
>>
>>
>> urlpatterns = [
>>  path('admin