django difference between - one to one, many to one and many to many

2013-10-28 Thread Aamu Padi
So, this is my first time learning computer language. And I chose python and django. Now, I got many of the basic concepts of python and also django. I can create new page with the views and all other stuff. But I am still confused with the relations, i.e. one to one, many to one, and many

Re: django difference between - one to one, many to one and many to many

2013-10-29 Thread Aamu Padi
et.tutsplus.com/tutorials/databases/sql-for-beginners-part-3-database-relationships/ > > > On Monday, October 28, 2013 2:06:20 PM UTC-5, Aamu Padi wrote: >> >> So, this is my first time learning computer language. And I chose python >> and django. Now, I got many of the ba

Re: django difference between - one to one, many to one and many to many

2013-10-30 Thread Aamu Padi
Thank you! That did helped. On Tuesday, October 29, 2013 12:36:20 AM UTC+5:30, Aamu Padi wrote: > > So, this is my first time learning computer language. And I chose python > and django. Now, I got many of the basic concepts of python and also > django. I can create new page wi

django - default value name for the ForeignKey

2013-10-31 Thread Aamu Padi
I have a model for uploading photos in an album by the users. But if the user don't want to create an album, and just upload photos, I want it to be uploaded in a default album, namely 'Default album'. So that, whenever the user uploads photo without creating a new album, the 'Default album should

Re: django - default value name for the ForeignKey

2013-10-31 Thread Aamu Padi
Thank you so much for your reply. But I am just a beginer, didn't quite understood the 'Manger' thing. Will you please be kind enough to elaborate a little more. Thank you. On Thu, Oct 31, 2013 at 8:44 PM, Aamu Padi <aamup...@gmail.com> wrote: > I have a model for uploading photos in

[no subject]

2013-11-03 Thread Aamu Padi
How to make a model with a yes/no field, if yes that particular object (image) will be used as the background, and no other image will be selected. I have come with this model: class BackgroundImage(models.Model): user = models.ForeignKey(user) caption =

Model to select only 1 object from multiple objects

2013-11-03 Thread Aamu Padi
How to make a model with a yes/no field, if yes that particular object (image) will be used as the background, and no other image will be selected. I have come with this model: class BackgroundImage(models.Model): user = models.ForeignKey(user) caption =

Re:

2013-11-03 Thread Aamu Padi
Thank you for the reply Lee. But could please elaborate a little more. :) On Mon, Nov 4, 2013 at 2:48 AM, Lee Hinde <leehi...@gmail.com> wrote: > > On Nov 3, 2013, at 12:23 PM, Aamu Padi <aamup...@gmail.com> wrote: > > > How to make a model with a yes/no field, if

Re: Model to select only 1 object from multiple objects

2013-11-04 Thread Aamu Padi
To do it the way you are doing - you need to make sure that first all > User=X have set using_image=false. Then set the particular used > using_image=true. Then you can retrieve the unique photo for every user by > filtering on using_image = true This needs to be done in code rather than >

How to add objects from one class to another

2013-11-04 Thread Aamu Padi
This is my models.py: class Image(models.Model): user = models.ForeignKey(User) caption = models.CharField(max_length=300) image = models.ImageField(upload_to=get_upload_file_name) pub_date = models.DateTimeField(default=datetime.now) class Meta:

Re: How to add objects from one class to another

2013-11-04 Thread Aamu Padi
`. On Tue, Nov 5, 2013 at 4:03 AM, Aamu Padi <aamup...@gmail.com> wrote: > This is my models.py: > > class Image(models.Model): > user = models.ForeignKey(User) > caption = models.CharField(max_length=300) > image = models.ImageField(upload

Re: How to add objects from one class to another

2013-11-05 Thread Aamu Padi
in it??? On Tue, Nov 5, 2013 at 6:18 AM, Gonzalo Delgado <m...@gonzalodelgado.com.ar>wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > El 04/11/13 19:33, Aamu Padi escribió: > > This is my models.py: > > > > class Image(models.Model): us

Re: How to add objects from one class to another

2013-11-05 Thread Aamu Padi
Ok, I guess, I will try that. Thank you!!! On Tue, Nov 5, 2013 at 10:40 PM, Gonzalo Delgado <m...@gonzalodelgado.com.ar > wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA256 > > El 05/11/13 13:14, Aamu Padi escribió: > > I think abstract models is what I am after.

How to copy and object from one model to another model

2013-11-05 Thread Aamu Padi
Each user has many *albums*, and each album has its many photos. And each user has one *background image* to hold its many images. Similarly, a user has one *profile picture* to hold its many images. These are my models: class UserProfile(models.Model): user = models.OneToOneField(User)

Re:

2013-11-05 Thread Aamu Padi
Thank you all for the precious ideas! I made some changes and just about to get the result. :D Thank you again! On Mon, Nov 4, 2013 at 6:22 PM, Tom Evans <tevans...@googlemail.com> wrote: > On Sun, Nov 3, 2013 at 8:23 PM, Aamu Padi <aamup...@gmail.com> wrote: > > How to ma

Re: How to copy and object from one model to another model

2013-11-05 Thread Aamu Padi
dels.ForeignKey(Album, default=3) > > > [1] > https://docs.djangoproject.com/en/1.5/topics/db/models/#model-inheritance > [2] > https://docs.djangoproject.com/en/1.5/ref/models/fields/#django.db.models.Field.choices > > > > 2013/11/5 Aamu Padi <aamup...@gmail.com>

django - How to copy the actual image file from one model to another?

2013-11-08 Thread Aamu Padi
I want to copy images from one model to another within the project. Suppose these are my models: class BackgroundImage(models.Model): user = models.ForeignKey(User) image = models.ImageField(upload_to=get_upload_file_name) caption = models.CharField(max_length=200)

Get a set of objects from different models field names

2013-11-09 Thread Aamu Padi
Please have a look at my models. class BackgroundImage(models.Model): user = models.ForeignKey(User) image = models.ImageField(upload_to=get_upload_file_name) caption = models.CharField(max_length=200) pub_date = models.DateTimeField(default=datetime.now)

Things to know about sorl-thumbnail

2013-11-10 Thread Aamu Padi
I am using sorl-thumbnail to create thumbnails for my project. I am implementing it only in templates and not in the models or the view. And each of the thumbnail are linked with their original image, which are used by a lightbox. As a newbie, I wanted to know, some of its functionality: 1.

How to get the class name of a ContentType in django

2013-11-28 Thread Aamu Padi
How do I get the class name in string of a ContentType? I tried it this way, but it didn't worked out: class StreamItem(models.Model): user = models.ForeignKey(User) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() pub_date =

Re: Admin File CSS Not Working Properly

2013-11-28 Thread Aamu Padi
Are you running the development server? On Fri, Nov 29, 2013 at 12:30 AM, nagendra palla wrote: > Hi Developers, > >I am new to Django App Development. My part-1 training is completed > successfully. But when i go for part-2, my Admin page is not working > properly.

Re: Admin File CSS Not Working Properly

2013-11-28 Thread Aamu Padi
Ok, you are using WAMP, so Apache as the server. Right? If so, have you tried this command -- manage.py collectstatic And then run the server again. Hope this helped. Cheers! On Fri, Nov 29, 2013 at 2:22 AM, Aamu Padi <aamup...@gmail.com> wrote: > Are you running the developme

Signals not working as expected

2013-11-28 Thread Aamu Padi
I am trying to create a project for creating feeds/activity feeds of a user with the help of a blog . These are the models - class StreamItem(models.Model): > user = models.ForeignKey(User) >

django - model for a messaging app between users

2013-11-29 Thread Aamu Padi
How do I go about creating a message app, between users. What's the business logic for creating the model? All I can think of was like this: models.py > > > > > *class Message(models.Model):description = > models.TextField()date_added = >

Re: Signals not working as expected

2013-11-29 Thread Aamu Padi
app’s models.py a good place to put >> registration of signal handlers. > > > I think you have to put your connection code in models.py (your > `create_stream_item` function can still live in signals.py) in order to be > sure connections are made early enough. > > 2013/

Re: How to get the class name of a ContentType in django

2013-11-30 Thread Aamu Padi
Yes. Could you kindly please show me how? On Sat, Nov 30, 2013 at 8:44 AM, Simon Charette <charett...@gmail.com>wrote: > Do you want to retrieve the class name of the model class associated with > a content type? > > Le jeudi 28 novembre 2013 12:04:34 UTC-5, Aamu Padi a écr

Re: How to get the class name of a ContentType in django

2013-11-30 Thread Aamu Padi
th a > > content type? > > > > Le jeudi 28 novembre 2013 12:04:34 UTC-5, Aamu Padi a écrit : > >> > >> How do I get the class name in string of a ContentType? I tried it this > >> way, but it didn't worked out: > >> > >> class StreamI

How to use primary key as an attribute

2013-11-30 Thread Aamu Padi
This may be a lame question, but how do I use the primary key as a default value for an attribute? This is my models.py: *class Thread(models.Model):thread_pk = models.PositiveIntegerField(default=self.pk )* This gives me an error: *self is not defined* How do I

Re: How to use primary key as an attribute

2013-12-01 Thread Aamu Padi
Actually I need to use *Thread* class in other class as a ForeignKey. Here is the whole code: class Thread(models.Model): thread_pk = models.PositiveIntegerField(default=self.pk) class ThreadParticipant(models.Model): thread = models.ForeignKey(Thread) user = models.ForeignKey(User)

Re: How to get the class name of a ContentType in django

2013-12-01 Thread Aamu Padi
Ok, I will try it! Thank you so very much!!! On Sun, Dec 1, 2013 at 3:41 AM, Timothy W. Cook <t...@mlhim.org> wrote: > On Sat, Nov 30, 2013 at 3:37 PM, Aamu Padi <aamup...@gmail.com> wrote: > > Yes!!! Can I use it as a string in template? > > > > > I haven

Re: How to use primary key as an attribute

2013-12-01 Thread Aamu Padi
subject") > > Then when you create the message you can use thread = > selected_subject[0] (assuming unique subjects/threads) when you create > your message. OR if 'some subject' isn't found, len(selected_subject) > == 0 then create a new Thread. > > HTH, > Tim > >

auto populating the fields in the models

2013-12-01 Thread Aamu Padi
Hello, please have a look at my models.py. *models.py:* > class Thread(models.Model): > pass > > class ThreadParticipant(models.Model): > thread = models.ForeignKey(Thread) > user = models.ForeignKey(User) > > class Message(models.Model): > thread = models.ForeignKey(Thread) >

Re: auto populating the fields in the models

2013-12-01 Thread Aamu Padi
t;> if not self.id: >> #on a new message do something >> #on modify message do somenthing else >> super(Message, self).save() >> >> >> >> >> >> >> 2013/12/1 Aamu Padi <aamup...@gmail.com&g

Save the user from one model to the another model

2013-12-02 Thread Aamu Padi
What I want to do is, whenever I create a new message, I want the *sender *of the *Message* to be added to the *user *of the *Thread.* How do I do that? > class Thread(models.Model): > user = models.ManyToManyField(User) > is_hidden = models.ManyToManyField(User,

Re: Save the user from one model to the another model

2013-12-03 Thread Aamu Padi
ld in > plural, i.e. Thread.users would be better than Thread.user > > HTH > > Jirka > -- > *From: * Aamu Padi <aamup...@gmail.com> > *Sender: * django-users@googlegroups.com > *Date: *Tue, 3 Dec 2013 04:19:55 +0530 > *To: *<django-users@g

Re: Save the user from one model to the another model

2013-12-03 Thread Aamu Padi
<antialia...@gmail.com> wrote: > I believe what Aamu Padi is getting at is that he doesn't want to do this > in the view at all. He just wants it to happen *whenever* a Message is > created. That's a textbook use case for signals. > > On Tuesday, December 3, 2013 1:14:5

[no subject]

2013-12-03 Thread Aamu Padi
How do I check whether there is a *thread* containing only the *sender *(user 1) and the *recipient* (user 2), and no other users. models.py class Thread(models.Model): user = models.ManyToManyField(User) is_hidden = models.ManyToManyField(User, related_name='hidden_thread',

How to query multiple described objects exist in a many to many field

2013-12-04 Thread Aamu Padi
How do I check whether there is a thread containing only the sender (user 1) and the recipient (user 2), and no other users. models.py class Thread(models.Model): user = models.ManyToManyField(User) is_hidden = models.ManyToManyField(User, related_name='hidden_thread',

Re: How to query multiple described objects exist in a many to many field

2013-12-05 Thread Aamu Padi
the thread, in this case '*t3*'? >>> t1 = Thread.objects.get(id=1) >>> t1 [,] >>> t2 = Thread.objects.get(id=2) >>> t2 [,] >>> t3 = Thread.objects.get(id=3) >>> t3 [,,] On Wed, Dec 4, 2013 at 5:41 PM, Tom Evans <tevans...@googlemail.

Custom page design by users

2015-08-20 Thread Aamu Padi
I am planning on building a blogging site. In that, I would like to allow the users to customize there page using html tags and bootstrap. 1. How do I save the contents? - Save all the contents in the db? - Or create different html files and serve them? -

Guidance needed - Real time and django

2014-08-29 Thread Aamu Padi
Hello, I would like to build a real time web application, but have little idea of where to start to from. It will have notification and feed system like facebook or instagram. Would really appreciate if anyone who have already done this type of web application could kindly guide me through. I will

Display objects from different models at the same page according to their published date

2016-06-10 Thread Aamu Padi
I have three different models for my app. All are working as I expected. class Tender(models.Model): title = models.CharField(max_length=256) description = models.TextField() department = models.CharField(max_length=50) address = models.CharField(max_length=50)

Re: Display objects from different models at the same page according to their published date

2016-06-10 Thread Aamu Padi
iday, June 10, 2016 at 6:59:55 AM UTC-5, Aamu Padi wrote: >> >> This is just a follow up of my question. >> >> I don't want to show each of the model objects separately at the same >> page. But like feeds of facebook or any other social media. Suppose a new >>

Is using multi-table inheritance still a bad choice?

2016-06-17 Thread Aamu Padi
Hi, I want to create feeds activity using the models that I have. class Tender(models.Model): title = models.CharField(max_length=256) description = models.TextField() department = models.CharField(max_length=50) tags = models.ManyToManyField(Tag) pub_date =

django rest framework - request context key error

2016-06-21 Thread Aamu Padi
I have two models (Like and News). I am using django-rest-framework to make a web api out of it. class Like(models.Model): user = models.ForeignKey(User) content_type = models.ForeignKey(ContentType) object_id = models.PositiveIntegerField() content_object =

django-rest-framework serializer for ContentType object

2016-06-20 Thread Aamu Padi
I am building an activity model, somewhat similar to this package . It has an actor, verb and the target. class Activity(models.Model): actor_type = models.ForeignKey(ContentType, related_name='actor_type_activities') actor_id =

How to create a new user with django rest framework and custom user model

2017-03-26 Thread Aamu Padi
I have a custom user model and I am using django-rest-framework to create API models.py: class User(AbstractBaseUser, PermissionsMixin): email = models.EmailField( unique=True, max_length=254, ) first_name = models.CharField(max_length=15) last_name =

Creating multiple objects with one request in Django Rest Framework

2017-04-16 Thread Aamu Padi
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 =

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

2017-04-17 Thread Aamu Padi
es/many_to_many/ > On Apr 17, 2017 8:19 AM, Aamu Padi <aamup...@gmail.com> 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)

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

2017-04-18 Thread Aamu Padi
izers.IntegerField > > user = serializers.IntegerField > > seats = serializers.ListField(child=serializers.IntegerFields) > > > > def create(self, validated_data): > > iterate over seats and save every instance. > > > > On Monday,

How to perform grouping and ordering

2017-04-23 Thread Aamu Padi
I have a Ticket booking model class Movie(models.Model): name = models.CharField(max_length=254, unique=True) class Show(models.Model): day = models.ForeignKey(Day) time = models.TimeField(choices=CHOICE_TIME) movie = models.ForeignKey(Movie) class MovieTicket(models.Model): show

Extending a image and adding text on the extended area using python pil

2017-04-08 Thread Aamu Padi
I am creating QRcode for each ticket. The QRcode is in image format. ​I want to extend this image vertically on both the sides (i.e. Top and Bottom). And in the extended area I want to add some additional data like this: Theater Name _ || |

Group by object's field and return list of object or object's id for each group

2018-05-07 Thread Aamu Padi
class Ticket(models.Model): ... booked_at = models.DateTimeField(default=timezone.now) bought = models.BooleanField(default=False) I would like to group tickets by booked day to get list of ticket or ticket's id for each day. Something like this: [ { 'day':

Django signals created kwargs is True while updating

2018-07-24 Thread Aamu Padi
I think I am missing something here, but here it goes. I have a model, and it is a sender for a post_save signal. class Book(models.Model): ... created_at = models.DateTimeField(default=timezone.now) bought = models.BooleanField(default=False) @receiver(post_save, sender=Book) def

Django @transaction.atomic() to prevent creating objects in concurrency

2018-04-20 Thread Aamu Padi
I have a ticket model, and its ticket serialiazer. The ticket model has a *bought* and a *booked_at* field. And also a *unique_together* attribute for *show* and *seat*. class Ticket(models.Model): show = models.ForeignKey(Show, on_delete=models.CASCADE) seat = models.ForeignKey(Seat,