Re: CharField vs ImageField for Logo

2017-09-25 Thread tango ward
: urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) I also saw a urlpattern for STATIC_URL and STATIC_ROOT. Would you have a minute or two to help me understand these codes? I would really appreciate it. Thanks On Tue, Sep 26, 2017 at 5:23 AM, tango ward <tango

Re: CharField vs ImageField for Logo

2017-09-25 Thread tango ward
djangoproject.com/en/1.11/ref/models/fields/#django.db. > models.fields.files.FieldFile.url > > Regards, > > Andréas > > 2017-09-25 20:38 GMT+02:00 tango ward <tangowar...@gmail.com>: > >> Hi Andréas, >> >> >> Thank you for the response.

CharField vs ImageField for Logo

2017-09-25 Thread tango ward
Hi guys, I am new to django currently stuck in these two. I am writing my pet project which will display a Team name and their logo. I used these lines for my Team class in mode.spy class Team(models.Model): name = models.CharField(max_length=150) logo = models.CharField(null=True,

Access data associated to a primary key

2017-10-02 Thread tango ward
Hi guys, I just want to know how to access and load the data associated to a primary key in a template. models.py class Team_Region(models.Model): name = models.CharField(max_length=50) # String representation def __str__(self): return self.name class

Re: Access data associated to a primary key

2017-10-02 Thread tango ward
Hi Gourav, thanks for the input. Just a question, Can I iterate through the Team_Region to get the teams listed under the specific id? or shall I do it in Team_Member class? This is for the DetailView. On Mon, Oct 2, 2017 at 9:31 PM, Gourav Chawla < gauravchawla.chawla...@gmail.com> wrote: >

Re: Access data associated to a primary key

2017-10-02 Thread tango ward
Holy .. it works! I have to access the Team_Name class using the 'related_name=regions' and from that, I was able to access the logo attributes of Team_Name. Here's what I did. {% block body_block %} {% for region in regions_detail.regions.all %}

Re: Access data associated to a primary key

2017-10-03 Thread tango ward
thanks Gourav. I really appreciate your inputs. On Tue, Oct 3, 2017 at 9:16 PM, Gourav Chawla < gauravchawla.chawla...@gmail.com> wrote: > Glad, you worked it out. You can use them whenever you want. Function > based views require you to write more code but give you more clarity on > what's

Re: CharField vs ImageField for Logo

2017-09-26 Thread tango ward
n't know where to serve your files > from otherwise. There are no "reasonable" defaults for those settings. > > Hope that helps! > > Andréas > > 2017-09-26 0:40 GMT+02:00 tango ward <tangowar...@gmail.com>: > >> Hi Andreas, >> >> >> I was abl

Re: CharField vs ImageField for Logo

2017-09-25 Thread tango ward
tionality of Django for this. > Checkout : https://docs.djangoproject.com/en/1.11/topics/files/. > > If you add the settings required (MEDIA_ROOT in the settings file) and > then change you logo from a CharField to an ImageField AND upload your file > via django admin, you should be able to show your file

Filter data in related_name loop

2017-10-11 Thread tango ward
Hi guys, I've been scratching my head on this one. I want to know if it's possible to filter the data of models class with related_name in a foor loop? Basically, I want to show the members info associated to a Team. models.py class Team_Region(models.Model): name =

Control PhoneNumber Format in SQL

2018-05-15 Thread tango ward
Hi, I am currently migrating database from MySQL to PostgreSQL. I have already migrated some of the data but I can't pull the data for my phonenumber field. I have a model: class BasePerson(TimeStampedModel): phone_number = PhoneNumberField(max_length=50, verbose_name=_(u'phone number'),

Re:

2018-05-23 Thread tango ward
Check if your template name is correct in your views.py On Wed, May 23, 2018 at 5:56 PM, Umar Kambala wrote: > Plz need help > I found this problem TemplateDoesNotExit at /polls/1/ where might have I > gone wrong? > > -- > You received this message because you are

Re: Filter Json boolean data

2018-01-19 Thread tango ward
That works. Silly me. Thank you Florian. On Fri, Jan 19, 2018 at 7:32 PM, Florian Schweikert <kel...@ist-total.org> wrote: > Hi, > > On 19/01/18 11:50, tango ward wrote: > > # Check who the winner of the match > > if data['radiant_win'] == 'Fa

Filter Json boolean data

2018-01-19 Thread tango ward
Hi guys, I want to get the correct data if if key == false from a json data. My if else condition seems to be working however the data is inconsistent. Here's my code: class DotaMatches(TemplateView): template_name = 'matches/dota_matches.html' def get(self, request, *args, **kwargs):

wsgi error

2018-01-26 Thread tango ward
Hi Team, Not sure if this issue covered here but I am getting an error uploading my pet project in Heroku. ModuleNotFoundError: No module named 'animals.wsgi' 2018-01-27T02:59:26.637953+00:00 app[web.1]: [2018-01-27 02:59:26 +] [8] [INFO] Worker exiting (pid: 8)

Re: CRUD code feedback

2018-01-27 Thread tango ward
Hi, Thanks for the response Akhil, I am using the CreateView in my view.py to create ne pets class CreateDog(CreateView): model = Dog fields = ('name', 'bday') template_name = 'animals/dog_create.html' class CreateCat(CreateView): model = Cat fields = ('name', 'bday')

Re: CRUD code feedback

2018-01-27 Thread tango ward
Will try it now. Quesion about the on_delete=models.CASCADE, does this mean that if I delete the pet (dog or cat) it will delete the owner who owns them? On Sun, Jan 28, 2018 at 1:11 PM, Akhil Lawrence wrote: > Your create view do not accept owner as a input and

CRUD code feedback

2018-01-27 Thread tango ward
Hi, I am playing around with CRUD. I want a user a create an account first before he/she can add pets under his/her profile. I tried adding one pet however it's seems that it is not associated to the Owner who added the pet. models.py from django.db import models from django.contrib.auth.models

Re: CRUD code feedback

2018-01-27 Thread tango ward
bday=datetime.today(), owner=owner).save() On Sun, Jan 28, 2018 at 1:13 PM, tango ward <tangowar...@gmail.com> wrote: > Will try it now. > > Quesion about the on_delete=models.CASCADE, does this mean that if I > delete the pet (dog or cat) it will delete the owner who owns

Re: CRUD code feedback

2018-01-27 Thread tango ward
Sorry for being a drag, I tried this code: class CreateDog(CreateView): template_name = 'dogs_cats/create_dog.html' model = Dog fields = ('name', 'bday', 'owner') def get_initial(self): initial_data = super(CreateDog, self).get_initial() initial_data["owner"] =

Re: CRUD code feedback

2018-01-27 Thread tango ward
I updated my models. py from django.db import models from django.contrib.auth import get_user_model from django.contrib.auth.models import User, PermissionsMixin # Create your models here. Pet_Owner = get_user_model() class RegisteredUser(User, PermissionsMixin): def __str__(self):

Re: CRUD code feedback

2018-01-28 Thread tango ward
Thanks, I'm digesting it. I am going to use the first option. On Sun, Jan 28, 2018 at 3:20 PM, Akhil Lawrence wrote: > I doubt whether you are reading my response properly. Let me reiterate my > response for you. > > > *There are two ways to do this. * > > *1. You can

Re: CRUD code feedback

2018-01-28 Thread tango ward
ot; must be a "User" >>> instance." >>> >>> >>> >>> class CreateDog(CreateView): >>> template_name = 'dogs_cats/create_dog.html' >>> model = Dog >>> fields = ('name', 'bday') >>>

Re: CRUD code feedback

2018-01-28 Thread tango ward
= Dog >> fields = ('name', 'bday') >> >> def form_valid(self, form): >> form.instance.owner = self.request.user >> return super(CreateDog, self).form_valid(form) >> >> >> I looked at StackOverflow and saw this thread >>

Re: CRUD code feedback

2018-01-28 Thread tango ward
-must-be-an-instance. Is there a way to use the same solution in side the form_valid()? On Sun, Jan 28, 2018 at 5:32 PM, tango ward <tangowar...@gmail.com> wrote: > Thanks, I'm digesting it. I am going to use the first option. > > On Sun, Jan 28, 2018 at 3:20 PM, Akhil Lawrence

Re: CRUD code feedback

2018-01-28 Thread tango ward
;>> Instead of *form.instance.owner = self.request.user*, try >>>> *form.instance.owner >>>> = Owner(id=self.request.user.id <http://self.request.user.id>)* >>>> >>>> It should work. >>>> >>>> On Sunday, 28 January 2018

Re: wsgi error

2018-01-31 Thread tango ward
Hi, thanks for the response. I was able to solved it. Turns out that my should be in the same directory with manage.py. On Tue, Jan 30, 2018 at 2:01 PM, Matemática A3K <matematica@gmail.com> wrote: > > > On Sat, Jan 27, 2018 at 12:05 AM, tango ward <tangowar...@gmail.com

Re: CRUD code feedback

2018-01-28 Thread tango ward
;> *fields = ('name', 'bday')* >>>>> >>>>> >>>>> >>>>> *def form_valid(self, form):form.instance.owner = >>>>> self.request.user return super(CreateDog, self).form_valid(form)* >>>>>

importError: Count Not import Django inside Virtualenv

2018-02-13 Thread tango ward
Hi, I want to seek some advice about the error. All of my pet projects in my desktop are getting the same error even though virtualenv is activated. I can confirm that when I started playing around with the projects, I have installed Django inside virtualenv without using "sudo". Now, I can't run

Re: importError: Count Not import Django inside Virtualenv

2018-02-13 Thread tango ward
Hi Eric, I tried what you suggested and it works! I was just wondering why my existing pet projects have the same problem? On Wed, Feb 14, 2018 at 10:13 AM, tango ward <tangowar...@gmail.com> wrote: > Hi, > > The error message that I am getting is: > > Traceback (

Re: importError: Count Not import Django inside Virtualenv

2018-02-13 Thread tango ward
hon by installing stuff > in sudo mode. The situation could be a little more complicated then. > > > Best. > > > Eric > ------ > *From:* django-users@googlegroups.com <django-users@googlegroups.com> on > behalf of tango ward <tangowar.

Re: importError: Count Not import Django inside Virtualenv

2018-02-14 Thread tango ward
> related libs, for the same reasons. > > > Eric > -- > *From:* django-users@googlegroups.com <django-users@googlegroups.com> on > behalf of tango ward <tangowar...@gmail.com> > *Sent:* Wednesday, February 14, 2018 3:40:04 AM > *To:* dja

Re: When to use get_user_model()

2018-02-17 Thread tango ward
created in models.py or the one that is currently logged in to the website? what does "or User otherwise" mean? My apologies for asking too many questions. On Sun, Feb 18, 2018 at 6:39 AM, tango ward <tangowar...@gmail.com> wrote: > > Hi, > > I am playing around with user r

When to use get_user_model()

2018-02-17 Thread tango ward
Hi, I am playing around with user registration. I came across a code where the get_user_model() was assigned to a model in Meta class inside a form. I was just wondering, what is the benefit of using the get_user_model() as Model in a form instead of importing a class from models.py then use that

Re: When to use get_user_model()

2018-02-19 Thread tango ward
n why and when to use >>> get_user_model(). >>> https://stackoverflow.com/questions/24629705/django-using- >>> get-user-model-vs-settings-auth-user-model >>> >>> >>> On Feb 18, 2018 4:11 AM, "tango ward" <tango...@gmail.com> wrote: >

Re: When to use get_user_model()

2018-02-18 Thread tango ward
and when to use > get_user_model(). > https://stackoverflow.com/questions/24629705/django- > using-get-user-model-vs-settings-auth-user-model > > > On Feb 18, 2018 4:11 AM, "tango ward" <tangowar...@gmail.com> wrote: > > > Hi, > > I am playing

How to parse json and display it in CBV.

2017-12-26 Thread tango ward
Hi, I need suggestions on this. I want to use the OpenDOTA API for my pet project. As a beginner, I don't know where to start working on this. I have found the OpenDOTA API https://api.opendota.com/api/heroes which I am planning to use but I am confuse as to how to parse the json into my CBVs. I

Re: How to parse json and display it in CBV.

2017-12-28 Thread tango ward
Thanks James. I heard of serialization in REST but I haven't played around with it. That's why I didn't know the exact terms of what I am doing. On Thu, Dec 28, 2017 at 5:44 AM, James Schneider <jrschneide...@gmail.com> wrote: > > > On Dec 27, 2017 1:02 PM, "tango ward&quo

Re: How to parse json and display it in CBV.

2017-12-26 Thread tango ward
ing_here is the string that you want to parse - and object is > the parsed json. > > Look here for more information: http://docs.python-guide.org/en/latest/ > scenarios/json/ > > Regards, > > Andréas > > 2017-12-26 18:29 GMT+01:00 tango ward <tangowar...@gmail.co

Re: How to parse json and display it in CBV.

2017-12-26 Thread tango ward
n't be > too hard as long as you understand how to send context data to the template. > > See here : > https://docs.djangoproject.com/en/2.0/topics/class-based- > views/generic-display/#adding-extra-context > > Regards, > > Andréas > > 2017-12-26 19:07 GMT+01:0

Re: How to parse json and display it in CBV.

2017-12-27 Thread tango ward
a List of dictionaries. Now, is it possible to turn this list to a dictionary? Apologies for the confusion, I am confuse as well. Regards, Jarvis On Wed, Dec 27, 2017 at 2:41 AM, tango ward <tangowar...@gmail.com> wrote: > Thanks for the idea Andréas. You're always helping me. > &

Re: Simple Search Feature

2018-02-24 Thread tango ward
thanks for the suggestions Ken. I just want to ask too if it's safe to display the list of songs even if the textbox is empty? On Sun, Feb 25, 2018 at 10:21 AM, Ken Whitesell wrote: > One of the issues is here: > if request.method == 'GET': >

Simple Search Feature

2018-02-24 Thread tango ward
Hi, I am playing around on adding a search feature to a website. I am currently encountering a problem when the page should load a list of songs and after typing in a song title in the search box: views.py class SongListView(ListView): model = Song context_object_name = 'songs'

PostrgreSQL Inside Virtualenv

2018-01-24 Thread tango ward
Hi, Newbie question, since I installed django and pillow inside virtualenv, shall I also install PostgreSQL inside Virtualenv? At the moment I am still using SQLite in my pet project. Regards, Jarvis -- You received this message because you are subscribed to the Google Groups "Django users"

Re: PostrgreSQL Inside Virtualenv

2018-01-24 Thread tango ward
Hi Anoosha, Thanks for the response. I'm just curious if the installation of PostgreSQL should be inside Virtualenv too or should it be installed directly into the computer. On Wed, Jan 24, 2018 at 4:55 PM, 'Anoosha Masood Keen' via Django users < django-users@googlegroups.com> wrote: > > Hi

Re: PostrgreSQL Inside Virtualenv

2018-01-24 Thread tango ward
Got it. Thanks Anoosha On Wed, Jan 24, 2018 at 5:29 PM, 'Anoosha Masood Keen' via Django users < django-users@googlegroups.com> wrote: > Install it on your computer. > > On Wednesday, January 24, 2018 at 8:49:17 AM UTC, tangoward15 wrote: > >> >> Hi, >> >> >> Newbie question, since I installed

Re: PostrgreSQL Inside Virtualenv

2018-01-24 Thread tango ward
he host that you want to communicate with. It cannot be installed > "only" in the virtualenv. > > Regards, > > Andréas > > 2018-01-24 9:59 GMT+01:00 tango ward <tangowar...@gmail.com>: > >> Hi Anoosha, >> >> >> Thanks for the response.

Re: PostrgreSQL Inside Virtualenv

2018-01-24 Thread tango ward
Noted. Thanks On Wed, Jan 24, 2018 at 5:56 PM, Avraham Serour <tovm...@gmail.com> wrote: > In any case you'll need to pip install the postgres drivers for python, I > suggest doing that inside the env > > > On Wed, Jan 24, 2018 at 11:32 AM, tango ward <tangowar...@gmai

Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread tango ward
Hi there, This will be my first time to migrate a database in my first programming job. I checked the dump file today and load it in MySQL benchmark to view the ERD. The database that I need to migrate has 48 tables and has existing data already. I would like to know what are the things that I

Re: Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread tango ward
lost on this, sorry. On Thu, Apr 12, 2018 at 8:46 AM, Mike Dewhirst <mi...@dewhirst.com.au> wrote: > On 12/04/2018 9:47 AM, tango ward wrote: > >> Hi Mike, >> >> >> Thanks for the advice. >> >> May I ask as well, on Django side, since we have al

Re: Tips On Migrating DB from other website to django with Postgresql

2018-04-11 Thread tango ward
it fits in our existing system? My only experience with changing backend database in Django was when I changed one of my pet projects db from SQLite to Postgres which I did in settings.py. On Thu, Apr 12, 2018 at 8:59 AM, tango ward <tangowar...@gmail.com> wrote: > At the moment, I am

UpdateView Decimal Field Initial Value

2018-04-24 Thread tango ward
Hi, I am working on an UpdateView of a form. I am having hard time displaying the initial value of grades per subject. I can display the subjects fine in the template, however I can't display the grades using the

Reverse for '' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []

2018-04-18 Thread tango ward
Hi, I just need some suggestions with this error that I am getting. I searched some related posts in Stackoverflow but most of the posts related were problems with urls.py or name in urls. My issue is that the page loads if I just put a plain HTML text in the page but the error occurs when I try

Request Timed Out When Generating Huge Data

2018-04-01 Thread tango ward
Good day, I need suggestions on how to approach this problem. I am working on a task that needs to generate the list students per school. When the school has larger number of students, I am getting a request timed out error. I can filter the school per campus to lessen the number of students but

Re: Request Timed Out When Generating Huge Data

2018-04-02 Thread tango ward
, tango ward <tangowar...@gmail.com> wrote: > Hi, > > SLR. > > At the moment, the largest number of students we have is 2000 in one > campus. I haven't played around with the code but when I check it we're > using a get_queryset function to get the data and filter it using

Re: Request Timed Out When Generating Huge Data

2018-04-02 Thread tango ward
In other words, add more information so that it's easier to > troubleshoot > > On Mon, 2 Apr 2018, 02:27 tango ward, <tangowar...@gmail.com> wrote: > >> >> Good day, >> >> I need suggestions on how to approach this problem. >> >> I am working o