Django forms validation

2016-05-05 Thread Lekan Wahab
Hello,
Please, i have a model form in forms.py which am trying to validate and
update my database with. However, for some reason the form is not being
validated. I have tried everything i could think of. It just reloads the
page.

views.py

> from django.shortcuts import render
> from information.forms import ContactForm
> from django.http import HttpResponse, HttpResponseRedirect
>
>
> def index(request):
> form_class = ContactForm
> if request.method == 'POST':
> form = form_class()
> if form.is_valid():
> ###Dummy text to check validation
> return  HttpResponse('Done')
> return render(request, 'information/index.html', {'form': form_class})
>
>
> def complete(request):
> return HttpResponse("Thank you for contacting us")
>
>
models.py


> from crispy_forms.helper import FormHelper
> from django import forms
> from django.core.exceptions import ValidationError
> from django.forms import Form
> from information.models import Contact
> from crispy_forms.helper import FormHelper
> from crispy_forms.layout import Layout,Fieldset, HTML
> from crispy_forms.bootstrap import TabHolder,Tab
>
>
> class ContactForm(forms.ModelForm):
> helper = FormHelper()
> helper.form_tag = False
> def __init__(self):
> super(ContactForm, self).__init__()
> for key in self.fields:
> self.fields[key].required= False
> self.fields[key].label = False
>
>
> class Meta:
> fields = '__all__'
> model =  Contact
>
>
Thank you.

-- 
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/CAE6v7oeD7Qb_%2BJrhiOzRTiDJ%3DqEPAY56B86nuxdZnrv2EP%2BrdQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django forms validation

2016-05-05 Thread Lekan Wahab
Hello Babatunde,
Thank you for answering my question.
I have actually done that.
But Django throws and error whenever I I instantiate form/for_class to
ContactForm(request. POST).
It says it's expected only a single argumen. but two was provided.
On 05 May 2016 10:36 PM, "Babatunde Akinyanmi"  wrote:

> Hello Lekan. I have responded inline but my answer might not be a complete
> fix.
>
> On May 5, 2016 4:56 PM, "Lekan Wahab"  wrote:
> >
> > Hello,
> > Please, i have a model form in forms.py which am trying to validate and
> update my database with. However, for some reason the form is not being
> validated. I have tried everything i could think of. It just reloads the
> page.
> >
> > views.py
> >>
> >> from django.shortcuts import render
> >> from information.forms import ContactForm
> >> from django.http import HttpResponse, HttpResponseRedirect
> >>
> >>
> >> def index(request):
> >> form_class = ContactForm
> >> if request.method == 'POST':
> >> form = form_class()
>
> The above line creates an empty form because you didn't supply anything as
> the data argument therefore the is_valid method will never return True. You
> need to instantiate it with your POST data. Try:
>  form = form_class(request.POST)
> >> if form.is_valid():
> >> ###Dummy text to check validation
> >> return  HttpResponse('Done')
> >> return render(request, 'information/index.html', {'form':
> form_class})
> >>
>
> {'form': form_class}
> form_class is not an object. Perhaps you meant {'form': form}
> >>
> >> def complete(request):
> >> return HttpResponse("Thank you for contacting us")
> >
> >
> > models.py
> >
> >>
> >> from crispy_forms.helper import FormHelper
> >> from django import forms
> >> from django.core.exceptions import ValidationError
> >> from django.forms import Form
> >> from information.models import Contact
> >> from crispy_forms.helper import FormHelper
> >> from crispy_forms.layout import Layout,Fieldset, HTML
> >> from crispy_forms.bootstrap import TabHolder,Tab
> >>
> >>
> >> class ContactForm(forms.ModelForm):
> >> helper = FormHelper()
> >> helper.form_tag = False
> >> def __init__(self):
> >> super(ContactForm, self).__init__()
> >> for key in self.fields:
> >> self.fields[key].required= False
> >> self.fields[key].label = False
> >>
> >>
> >> class Meta:
> >> fields = '__all__'
> >> model =  Contact
> >
> >
> > Thank you.
> >
> > --
> > 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/CAE6v7oeD7Qb_%2BJrhiOzRTiDJ%3DqEPAY56B86nuxdZnrv2EP%2BrdQ%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/CA%2BWjgXMLEmHKdtAWBA%2BsO7zPD9XGAggUPVXsU5beqg%3Dwb2Ax5Q%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CA%2BWjgXMLEmHKdtAWBA%2BsO7zPD9XGAggUPVXsU5beqg%3Dwb2Ax5Q%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> 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/CAE6v7ofhzu7D2wv3UzK8G4vybKH3pM%3DYWK3fZFzo5Cewk7LUeA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Running Django Project Locally

2016-08-24 Thread Lekan Wahab
Good morning,
I was recently given  a django project to manage at work.
However, i noticed the project has neither a django-admin.py or a manage.py
file.
Is that normal?
If it is, how do i run the project on my local machine for testing purposes?

The file structure is something like this:
Project Name
app1
app2
app3
app4
app5
models.py
forms.py
__init__.py
urls.py
views.py
admin.py


Each app contains the following:
models.py
forms.py
__init__.py
urls.py
views.py
admin.py

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


Re: Running Django Project Locally

2016-08-24 Thread Lekan Wahab
Thanks for getting back to me.
​So, i just figured *manage.py* would also require the *settings.py* which
is missing now.
What do i do about that?

Lekan​


On Wed, Aug 24, 2016 at 8:48 AM, Mike Dewhirst 
wrote:

> On 24/08/2016 5:23 PM, Lekan Wahab wrote:
>
>> Good morning,
>> I was recently given  a django project to manage at work.
>> However, i noticed the project has neither a django-admin.py or a
>> manage.py file.
>> Is that normal?
>>
> There is usually a manage.py file in the root of the project.
> django-admin.py is put in the Python path when Django is installed.
>
>> If it is, how do i run the project on my local machine for testing
>> purposes?
>>
>
> * Establish a virtualenv setup (optional but recommended)(separate topic)
> * install the same version of Django locally (the file structure you show
> indicates a possibly older Django)
> * install the same version of the database server locally
> * dump the database on the server and load it locally
> * mkdir ~/envs
> * cd envs
> |* ||python django-admin.py startproject projname (or use python3)
>
> At this point you have the bones of the project into which you should be
> able to see where to copy the projname directories and files. After doing
> so ...
>
> * ~/envs/projname$ python manage.py runserver
>
> This will probably generate errors indicating which 3rd party packages
> need to be installed on the local machine. In theory when they are all
> installed you should be able to launch the software.
> |
> Good luck
>
> Mike
>
>
>> The file structure is something like this:
>> Project Name
>> app1
>> app2
>> app3
>> app4
>> app5
>> models.py
>> forms.py
>> __init__.py
>> urls.py
>> views.py
>> admin.py
>>
>>
>> Each app contains the following:
>> models.py
>> forms.py
>> __init__.py
>> urls.py
>> views.py
>> admin.py
>> --
>> 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 > django-users+unsubscr...@googlegroups.com>.
>> To post to this group, send email to django-users@googlegroups.com
>> <mailto:django-users@googlegroups.com>.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAE6v7ocLOQh_HMxiu29%2Br3wLANJ2wjtesyjb79SX
>> mFXpgb8jgw%40mail.gmail.com <https://groups.google.com/d/m
>> sgid/django-users/CAE6v7ocLOQh_HMxiu29%2Br3wLANJ2wjtesyjb79S
>> XmFXpgb8jgw%40mail.gmail.com?utm_medium=email&utm_source=footer>.
>> 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/ms
> gid/django-users/f61e75cb-12f3-3fe8-e792-a5ce69f473c3%40dewhirst.com.au.
>
> 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/CAE6v7odmC97UYEV0-scQZdoafoa3%3DFkP5dKUA2nJ%2BA7oCEH7Xw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Running Django Project Locally

2016-08-24 Thread Lekan Wahab
So,
I have been handed the other part of the project which now contains
everything except the manage.py file(which i have created).
Also, the project is quiet old  and some of the dependencies are either no
longer being managed or don't exist anymore.(unobase for an example).
As such, i was handed an eggs.zip containing the packages used by the
developer.
Now, the question is, how do i install the dependencies from the eggs.py
file?
I think its more of a python question than a django issue but i would still
appreciate whatever help i can get.



Lekan.

On Wed, Aug 24, 2016 at 10:22 AM, Mike Dewhirst 
wrote:

> On 24/08/2016 6:42 PM, Lekan Wahab wrote:
>
>> Thanks for getting back to me.
>> ​So, i just figured *manage.py* would also require the *settings.py*
>> which is missing now.
>> What do i do about that?
>>
>
> That depends. Is the system currently working?
>
> If so there will be a bunch of settings somewhere and the system will work
> on your local machine.
>
> If not, it might be a big ask to do anything quickly. You'll need to do
> some research.
>
> In my own projects there are no settings.py files at all. I use a settings
> directory and in there I have base.py, local.py, mike_test.py staging.py
> and production.py. Each of these imports common settings from base.py. Here
> is my local_test.py
>
> from .base import *
> SITE_ID = 3
> DEBUG = True
> TEMPLATE_DEBUG = DEBUG
> TEST_RUNNER = 'django.test.runner.DiscoverRunner'
>
> DATABASES = {
> 'default': {
> "ENGINE": "django.db.backends.sqlite3",
> "NAME": ":memory:",
> "USER": "",
> "PASSWORD": "",
> "HOST": "",
> "PORT": "",
> }
> }
>
> You can probably find where the settings are being imported from - grep
> for ENGINE and that will give you a clue.
>
> Cheers
>
> Mike
>
>
>
>> Lekan​
>>
>>
>> On Wed, Aug 24, 2016 at 8:48 AM, Mike Dewhirst > <mailto:mi...@dewhirst.com.au>> wrote:
>>
>> On 24/08/2016 5:23 PM, Lekan Wahab wrote:
>>
>> Good morning,
>> I was recently given  a django project to manage at work.
>>
>> However, i noticed the project has neither a django-admin.py
>> or a manage.py file.
>> Is that normal?
>>
>> There is usually a manage.py file in the root of the project.
>> django-admin.py is put in the Python path when Django is installed.
>>
>> If it is, how do i run the project on my local machine for
>> testing purposes?
>>
>>
>> * Establish a virtualenv setup (optional but recommended)(separate
>> topic)
>> * install the same version of Django locally (the file structure
>> you show indicates a possibly older Django)
>> * install the same version of the database server locally
>> * dump the database on the server and load it locally
>> * mkdir ~/envs
>> * cd envs
>> |* ||python django-admin.py startproject projname (or use python3)
>>
>> At this point you have the bones of the project into which you
>> should be able to see where to copy the projname directories and
>> files. After doing so ...
>>
>> * ~/envs/projname$ python manage.py runserver
>>
>> This will probably generate errors indicating which 3rd party
>> packages need to be installed on the local machine. In theory when
>> they are all installed you should be able to launch the software.
>> |
>> Good luck
>>
>> Mike
>>
>>
>> The file structure is something like this:
>> Project Name
>> app1
>> app2
>> app3
>> app4
>> app5
>> models.py
>> forms.py
>> __init__.py
>> urls.py
>> views.py
>> admin.py
>>
>>
>> Each app contains the following:
>> models.py
>> forms.py
>> __init__.py
>> urls.py
>> views.py
>> admin.py
>> -- 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
>> <mailto:django-users%2bunsubscr...@googlegroups

Re: hey.. are you there?

2016-08-24 Thread Lekan Wahab
Hi.

On 24 Aug 2016 9:13 PM, "concussion"  wrote:

> good morning.. :)
>
> --
> 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/4046833c-a3f1-4e50-a83e-b77b1710d38a%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/CAE6v7oeoQVvnzOhuPB%3DV%3D-pOVmjuZr4T_PO6TFQqA3nXwu222A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Maintaining old django code

2016-09-06 Thread Lekan Wahab
Good morning guys.
I was handed a project at work which was written as far back as 2012.
Quiet a lot of the packages used in the project are either no longer being
maintained.
Rebuilding the project from scratch is not option.
There are way too many moving parts and way too many apps to rebuild it.
Here are my questions:

1. In the scenario i am in, what would be the best approach to update this
project or at least get it set up locally?
2.  Quite a lot of changes have been made between django 1.4 (which was
originally used) and the current version(1.10), what would be the best
version for me to update the project to.
I mostly use 1.8 anyway.
3. Is there anyone who has or who is still using *unobase* here?


Olamilekan

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


Help with FlatPages

2016-09-19 Thread Lekan Wahab
Good morning guys,

I'm trying to locally set up an existing  project on my machine.
While I've set up most of the project,  the part giving me a hard time are
the ones using flatpages.

Now,  everytime I access those,  I get a "No Flatpages matches the given
query. " error.

I've tried everything I can but with no luck.

However, there's a flatpages.json file in the project folder.

What could that be for?

Is there something I am supposed to do with that json file?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE6v7oeihYOYgqatE-HqPO0_aQS0P0JvXAwPwvs5_H-xs0d5bg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django migrate generates SQLite3 file filled with junk

2016-09-25 Thread Lekan Wahab
On 25 Sep 2016 1:17 PM, "kbman99"  wrote:

>

> Just getting started with django and having an issue with the migrate.py
script. It generates a db.SQLite3 file which is filled with a lot of
garbage characters. It's in UTF-8 encoding, but looks like this.
>
> I've deleted the file and redone the migrate a few times but it's always
like this.
>
> Any help appreciated!
> 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/2980ce12-c366-454b-844a-c625e7520977%40googlegroups.com

.
> For more options, visit https://groups.google.com/d/optout.
Hi kbman,
If you use PyCharm, you can easily read the sqlite3 file better with its
database integration.
Click on database.
Select from sources and then okay.

Lekan.

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


Re: HTML Flexbox CSS

2016-09-25 Thread Lekan Wahab
Hi,
In order to ease the work of making your changing your static files to the
right URL format in Django,  a friend of mine came up with a library called
*Staticfy* for it.

You can check it out on :
https://github.com/danidee10/Staticfy

It will really ease your work.

On 25 Sep 2016 2:55 PM, "Ed09"  wrote:

> Trying to implement:
> http://www.w3schools.com/css/tryit.asp?filename=trycss3_flexbox_website
> within Django.
> Works fine when all of the Flexbox  section is within
> the template but if I move this style section to a css the following @media
> sections stop working but the rest continues to work.
>
> 
> ..
>@media all and (min-width: 600px) {
> .aside { flex: 1 auto; }
> }
>
> @media all and (min-width: 800px) {
> .main{ flex: 3 0px; }
> .aside1 { order: 1; }
> .main{ order: 2; }
> .aside2 { order: 3; }
> .footer  { order: 4; }
> }
> 
>
> If I implement it as a standard index.html and styles.css pair without
> Django it does work.
> Any suggestions?  Thanks for your help.
>
> --
> 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/1b49e8aa-2a31-4673-ab2e-ebce9ab162c9%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/CAE6v7oeKaW9ubxUsbuptt1k-Ndp_B8V9todWahtobKuOPSHTxQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: One template for multiple views

2016-11-02 Thread Lekan Wahab
Hi,
I'm not sure I completely understand what you need but if I do,  I think
passing different contexts to the same template would help you achieve
that.

You could easily have something like :

def initial_view(request) :
   variableone = 'a'
   variabletwo = 'b'
   return response(yourtemplate, {'a':variableone, 'b' :variabletwo})

Then you can also have another view using the same template but with
different contexts.
Something like,

def final_view(request) :
   variableone = 'c'
   variabletwo = 'd'
   return response(yourtemplate, {'c':variableone, 'd' :variabletwo})

Also,  if you have a repetitive section in your template, you could just
write it once and use the {% include %} tag to use it in each of your other
templates.

I hope that helps.

Lekan.
Python is the "most powerful language you can still read".

On 2 Nov 2016 19:48, "Moreplavec"  wrote:

Greetings,

i'm creating template for simple table report. Data shown are for current
month. Than i realised i need same report for previous month. I can copy
created template and modify texts, but i don't like. Is it possible to use
same template for more views and only controll differences based on view,
which is template calling? For example, i need to show "Current month" or
"Previous month". I can put these texts into variable, but i hope there is
better way to controll directly in template.

Please, can you help me or point me to some good article? 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/a61a7a9d-06a2-4749-bf71-f6d2351396af%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/CAE6v7occppraFDC50RENzJ-tO3mBipDThG%2B8AkfTAU2PkVGGHQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


ListField, JSONField and DictField

2016-11-03 Thread Lekan Wahab
Hi guys,
This question just came to me this evening and I've really been thinking
about it.

Can someone explain to me why Django doesn't have ListField, JSONField or
DictField by default in its model Fields?

I mean,  these are obviously things that would ease a lot of work so why
aren't they available yet?

Lekan.
Python is the "most powerful language you can still read".

-- 
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/CAE6v7od4Au4friMr-bqp02JeL_R4jXVBJn3zFh6bc-eds-GtWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django URLS

2016-11-17 Thread Lekan Wahab
If i have a url like *fruits.com*, does anyone know how i can write my
subdomain urls in django to be *apple.fruits.com* instead of *
fruits.com/apple* ?

-- 
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/CAE6v7odjAUgPXgeU6c%2BTuxVbFTx%3Dgzmp%3DFUboyD1tm1kWgMo5g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: syncdb command can execute

2016-12-19 Thread Lekan Wahab
Would you provide a little more information?

What errors are you getting?

On Mon, Dec 19, 2016 at 11:56 AM, Navneel Pandey 
wrote:

> hi i am new to django as i want to create a table but unable to do so I am
> writing the command python manage.py syncdb
>
> --
> 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/ba2b0951-ab21-425c-91ed-9706830eae92%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/CAE6v7ofNJmwum6Et_6_VBcs%3DTRGnSPXR_-7w94b4hu2%2BOSApfQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Happy New Year 2017

2016-12-31 Thread Lekan Wahab
Happy New year guys.
Let's do more of this next year.

On Sat, Dec 31, 2016 at 7:49 PM, Robin Lery  wrote:

> Happy new year!
>
> On 1 Jan 2017 12:05 a.m., "pradam programmer" <
> pradam.programm...@gmail.com> wrote:
>
>> Happy New Year Guys, i hope this year fill with alot of love, happiness
>> and Joy to everyone.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/django-users/CAGGVXBOiUZcsYMyu237t2nirG%3DrzOD_
>> v68b1AqYVkijk-fDk5Q%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/CA%2B4-nGr%2BajFGPFssTO9nKr94AECOiBSJ1KTi
> atgHDTzZJdd1fg%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/CAE6v7oe%2BLdfyj3MnCTaiuY00oGC9hpaidCa9i%2Bd0FEGtcvWaBw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Multiple Users

2017-03-06 Thread Lekan Wahab
##This is one approach.
You can have a single user profile and a number of other users tied to
the user profile via ForeignKey.


class UserProfile(models.Model):
user = models.ForeignKey(User)
#define general fields
class Freelancer(models.Model):
profile = models.ForeignKey(UserProfile)
#freelancer specific  fields

class Meta:
db_table = 'freelancer'
class Customers(models.Model):
profile = models.ForeignKey(UserProfile)
#customer specific fields

   class Meta:
db_table = 'customer'


Another approach(which i don't think is the best) would be to have a single
UserProfile but with a table that identifies the type of user you have.
Something like this:

class UserProfile(models.Model):
user = models.OneToOneField(User)
description = models.CharField(max_length=100, default='')
country = models.CharField(max_length=100, default='')
website = models.URLField(default='')
phone = models.IntegerField(default=0)

##The user type would be boolean and 0 by default. 0 could be a
freelancer and 1 a Customer or the other way round.
##So, based on the type of user you're creating, you could just
set a new value for user_type.
user_type = models.BooleanField(default=0)

###This method would come in handy if both users have exactly the same features.
###But I'd rather go with the first method.







On Mon, Mar 6, 2017 at 2:37 PM, Focus Ifeanyi  wrote:

> I am new to Django and trying to create an App with two User Types
> (Freelancers and Customers). I understand how to create a User profile
> Class and it works well for me:
>
> class UserProfile(models.Model):
> user = models.OneToOneField(User)
> description = models.CharField(max_length=100, default='')
> country = models.CharField(max_length=100, default='')
> website = models.URLField(default='')
> phone = models.IntegerField(default=0)
> def create_profile(sender, **kwargs):
> if kwargs['created']:
> user_profile = UserProfile.objects.create(user=kwargs['instance'])
>
>
> post_save.connect(create_profile, sender=User)
>
> This works well for me on a one user type user. But now I am building an
> app with 2 types of users (freelancers and customers), what is the best
> approach to get this done. Both users will have different view and info.
> Should I:
>
>- Create 2 different apps, and repeat the normal registeration and
>login for each.
>- If I do the above, hope the freelancers when logged in won't access
>customers view.
>- How do I add user type to the user profile if I decide to use one
>app and model for it.  Please I need a step by step beginner approach, or a
>link to relevant source. 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/7c9f19a0-0e25-4529-9353-6e69b1d9e695%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/CAE6v7ocxKgRkfh9Ez7UaRSGOByKph2vM5GWPCo8DEbq%3DwZ6u3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django - Upload Image to the server with dimension

2015-12-29 Thread Lekan Wahab
Hello Guys.
I have a website and am trying to build a rating system for the site.
The system takes in user's rating and rewards them at the end of the month
according to their ratings.
I honestly dont know where to begin.
i have searched for some things online but i still need help


On Tue, Dec 29, 2015 at 12:35 PM, monoBOT  wrote:

> Take a look at this:
>
> http://djangothumbnails.com/
>
> 2015-12-29 7:12 GMT+00:00 ken phanith :
>
>> I simply use ImageField from PIL package for Django Image Upload but it
>> does not satisfy me at all. I have a models class which contain many fields
>> including ImageField also. I am trying to upload 10 images to the server
>> but those images have the different dimension. I want to upload those image
>> to the server but with same dimension (700*400) as the example.
>> Actually, I want to do that by using Django but I don't have any idea on
>> how to do that. Does anyone have any ideas on how to do that? Please help
>> me.
>> Thank you very much.
>>
>> --
>> 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/e12e269f-8ca6-48f6-ad6f-722b84e3ef2c%40googlegroups.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> --
> *monoBOT*
> Visite mi sitio(Visit my site): monobotsoft.es/blog/
>
> --
> 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%2BxOsGCCEBX3mYcuO25jkDQz1e2iZN5aRzoS_fxtfn27WEu9AA%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/CAE6v7ofQp7vGto3SzDHTG27Ei-dR05_Mu3y3shSPZ9ehfj2AgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.