How to Modify the default Django user table and the custom user table should consist of the 'first name','last name', 'gender', 'Email(Primary Key)', 'phone number' fields. How to do this? forms.py  class UserForm(ModelForm):     class Meta():         model= User         fields = 'First_name','Last_name','Gender', 'email','Phone_number'
106660
What's the best way to extend the User model (bundled with Django's authentication app) with custom fields? I would also possibly like to use the email as the username (for authentication purposes).  I've already seen a   to do it, but can't decide on which one is the best.
77735
I've added a few custom user fields which users complete when registering.  What is the simplest approach to show these fields when viewing content that user has created?  For example, when viewing a blog entry I can see the 'submitted by..' and their name. I would like to use my custom user fields to expand that summary.  I've got no problem using views, or creating/modifying the theme etc, but I'd like some guidance on the easiest approach before I start out. (It's too easy to hack away on one approach in Drupal when there's a much easier solution!)
79469
I have a custom entity that fieldable. I need to add a field to it, and I want to do it through the UI. The entity was created in a custom module, which I can modify. How can I make the entity fieldable? /**  * Defines the Quiz entity.  *  * @ingroup qwizard  *  * @ContentEntityType(  *   id = &quot;qwiz&quot;,  *   label = @Translation(&quot;Quiz&quot;),  *   bundle_label = @Translation(&quot;Quiz type&quot;),  *   handlers = {  *     &quot;storage&quot; = &quot;Drupal\qwizard\QwizStorage&quot;,  *     &quot;view_builder&quot; = &quot;Drupal\Core\Entity\EntityViewBuilder&quot;,  *     &quot;list_builder&quot; = &quot;Drupal\qwizard\QwizListBuilder&quot;,  *     &quot;views_data&quot; = &quot;Drupal\qwizard\Entity\QwizViewsData&quot;,  *  *     &quot;form&quot; = {  *       &quot;default&quot; = &quot;Drupal\qwizard\Form\QwizForm&quot;,  *       &quot;add&quot; = &quot;Drupal\qwizard\Form\QwizForm&quot;,  *       &quot;edit&quot; = &quot;Drupal\qwizard\Form\QwizForm&quot;,  *       &quot;delete&quot; = &quot;Drupal\qwizard\Form\QwizDeleteForm&quot;,  *     },  *     &quot;access&quot; = &quot;Drupal\qwizard\QwizAccessControlHandler&quot;,  *     &quot;route_provider&quot; = {  *       &quot;html&quot; = &quot;Drupal\qwizard\QwizHtmlRouteProvider&quot;,  *     },  *   },  *   base_table = &quot;qwiz&quot;,  *   revision_table = &quot;qwiz_revision&quot;,  *   revision_data_table = &quot;qwiz_field_revision&quot;,  *   admin_permission = &quot;administer quiz entities&quot;,  *   entity_keys = {  *     &quot;id&quot; = &quot;id&quot;,  *     &quot;revision&quot; = &quot;vid&quot;,  *     &quot;bundle&quot; = &quot;type&quot;,  *     &quot;label&quot; = &quot;name&quot;,  *     &quot;uuid&quot; = &quot;uuid&quot;,  *     &quot;uid&quot; = &quot;user_id&quot;,  *     &quot;langcode&quot; = &quot;langcode&quot;,  *     &quot;status&quot; = &quot;status&quot;,  *   },  *   links = {  *     &quot;canonical&quot; = &quot;/admin/structure/qwizard/qwiz/{qwiz}&quot;,  *     &quot;add-page&quot; = &quot;/admin/structure/qwizard/qwiz/add&quot;,  *     &quot;add-form&quot; = &quot;/admin/structure/qwizard/qwiz/add/{qwiz_type}&quot;,  *     &quot;edit-form&quot; = &quot;/admin/structure/qwizard/qwiz/{qwiz}/edit&quot;,  *     &quot;delete-form&quot; = &quot;/admin/structure/qwizard/qwiz/{qwiz}/delete&quot;,  *     &quot;version-history&quot; = &quot;/admin/structure/qwizard/qwiz/{qwiz}/revisions&quot;,  *     &quot;revision&quot; = &quot;/admin/structure/qwizard/qwiz/{qwiz}/revisions/{qwiz_revision}/view&quot;,  *     &quot;revision_revert&quot; = &quot;/admin/structure/qwizard/qwiz/{qwiz}/revisions/{qwiz_revision}/revert&quot;,  *     &quot;revision_delete&quot; = &quot;/admin/structure/qwizard/qwiz/{qwiz}/revisions/{qwiz_revision}/delete&quot;,  *     &quot;collection&quot; = &quot;/admin/structure/qwizard/qwiz&quot;,  *   },  *   bundle_entity_type = &quot;qwiz_type&quot;,  *   field_ui_base_route = &quot;entity.qwiz_type.edit_form&quot;  * )  */
68690
We have about 8000 users who doesn't have any roles. we need to change them to "contributor". How can I change them to "contributor"? Should I do on database? if so, which fields I need to update?  Thanks,
105471
I know this has been asked  and , but I have the same idea with a different possible implementation and I need some help.  Initially I had my blogstories table with this structure:  | Column    | Type        | Description                                    | |-----------|-------------|------------------------------------------------| | uid       | varchar(15) | 15 characters unique generated id              | | title     | varchar(60) | story title                                    | | content   | longtext    | story content                                  | | author    | varchar(10) | id of the user that originally wrote the story | | timestamp | int         | integer generated with microtime()             |   After I decided I wanted to implement some versioning system for every story on the blog, the first thing that came to my mind was creating a different table to hold edits; after that, I thought I could modify the existing table to hold versions instead of edits. This is the structure that came to my mind:  | Column        | Type          | Description                                       | |------------   |-------------  |------------------------------------------------   | | story_id      | varchar(15)   | 15 characters unique generated id                 | | version_id    | varchar(5)    | 5 characters unique generated id                  | | editor_id     | varchar(10)   | id of the user that commited                      | | author_id     | varchar(10)   | id of the user that originally wrote the story    | | timestamp     | int           | integer generated with microtime()                | | title         | varchar(60)   | current story title                               | | content       | longtext      | current story text                                | | coverimg      | varchar(20)   | cover image name                                  |   The reasons why I came here:   The uid field of the initial table was UNIQUE in the table. Now, the story_id is not unique anymore. How should I deal with that? (I thought I could address story_id = x and then find the latest version, but that seems very resource consuming, so please give your advice) author_id field value is repeating in each every row of the table. Where and how should I keep it?     Edit  The unique codes generation process is in the CreateUniqueCode function:  trait UIDFactory {   public function CryptoRand(int $min, int $max): int {     $range = $max - $min;     if ($range &lt; 1) return $min;     $log = ceil(log($range, 2));     $bytes = (int) ($log / 8) + 1;     $bits = (int) $log + 1;     $filter = (int) (1 &lt;&lt; $bits) - 1;     do {         $rnd = hexdec(bin2hex(openssl_random_pseudo_bytes($bytes)));         $rnd = $rnd &amp; $filter;     } while ($rnd &gt;= $range);     return $min + $rnd;   }   public function CreateUID(int $length): string {     $token = "";     $codeAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";     $codeAlphabet.= "abcdefghijklmnopqrstuvwxyz";     $codeAlphabet.= "0123456789";     $max = strlen($codeAlphabet) - 1;     for ($i=0; $i &lt; $length; $i++) {         $token .= $codeAlphabet[$this-&gt;CryptoRand(0, $max)];     }     return $token;   } }   The code is written in , and was originally written in PHP by  in his .  The fields author_id and editor_id can be different, because there are users with enough permissions to edit anyone's stories.
10305
I tried creating a field, but my server crapped out halfway with an Internal Server Error due to some spambot attack...  Now, when I try to add the field again, I am getting:     The machine-readable name is already in use. It must be unique.   I guess some tables were populated in the db. How can I remove these easily?
37251
I am designing a registration form for a site with multiple sets of information required from the user. I have categorized the data fields into relevant groups. Now should I present the form sections in one go or follow a wizard-like approach? What things should I keep in mind while deciding on this?
62166
I need to have a select widget but with custom allowed values per user. Since in D7 I cannot use php code, I was wondering if there is some kind of hook I could use to achieve that functionality.  Thanks
88953
Is there a good tool that checks the schema to determine custom fields and their use in triggers, page layouts, classes, etc? We have a couple objects that are getting close to the 500 max and it would be nice if there were a better way than having someone get a list of custom fields for an object manually and then searching every page layout, class, and trigger for use of each field.
60929
Anybody knows how to create custom text fields on salesforce.com objects using apex?
121398
Suppose I have a table containing job roles:  CREATE TABLE roles (   "role" character varying(80) NOT NULL,   CONSTRAINT "role" PRIMARY KEY (role) );   Suppose I further have a table, users, and each row (a specific user) can have an arbitrary number of job roles:  CREATE TABLE users (   username character varying(12) NOT NULL,   roles character varying(80)[] NOT NULL,   CONSTRAINT username PRIMARY KEY (username) );   I should probably make sure that each member of users.roles[] exists in roles.role.  It seems to me that what I want is a foreign key constraint on each member of users.roles[] such that if references roles.role.  This doesn't seem possible with postgres.  Am I looking at this the wrong way?  What is the suggested "right" way to handle this?
97745
I have a database setup with the following schema:   CREATE TABLE siteInfo (     siteID             SERIAL  NOT NULL,     siteName           TEXT    NOT NULL,     siteHost           TEXT    NOT NULL,     notes              TEXT    NOT NULL,     allowableCountries TEXT    NOT NULL,     displayChance      INT     NOT NULL,     imagePath          TEXT    NOT NULL,     PRIMARY KEY (siteID) );  CREATE TABLE siteLinks (     siteID             SERIAL  NOT NULL,     URL                TEXT    NOT NULL,     FOREIGN KEY (siteID) REFERENCES siteInfo(siteID) ON DELETE CASCADE );  CREATE TABLE siteDemographicLinks (     siteID             SERIAL  NOT NULL,     URL                TEXT    NOT NULL,     country            TEXT    NOT NULL,     chance             INT     NOT NULL,     FOREIGN KEY (siteID) REFERENCES siteInfo(siteID) ON DELETE CASCADE );  CREATE TABLE linkVisits (     siteID             SERIAL  NOT NULL,     rawVisit           BIGINT  NOT NULL,     redirects          BIGINT  NOT NULL,     FOREIGN KEY (siteID) REFERENCES siteInfo(siteID) ON DELETE CASCADE );   Data from my form is in the following format:  array(7) { ["siteName"]=&gt;string(9) "Site Name" ["siteHost"]=&gt;string(9) "SIte Host" ["notes"]=&gt;string(5) "Notes" ["links"]=&gt;array(2) {[0]=&gt;string(6) "Link 1" [1]=&gt;string(6) "Link 2"} ["countries"]=&gt;string(4) "None" ["displayChance"]=&gt;string(2) "15" ["extraLink"]=&gt;array(2) {    [0]=&gt;array(3) {       ["url"]=&gt;string(7) "dSite 1"       ["countries"]=&gt;string(4) "NONE"       ["chance"]=&gt;string(2) "11"       }    [1]=&gt;array(3) {       ["url"]=&gt;string(6) "dSite2"       ["countries"]=&gt;string(4) "None"       ["chance"]=&gt;string(2) "13"       }    } }   How would I go abound inserting data into the many type tables so they reference tuples inserted into the one type table?  I have this query constructed:  INSERT INTO siteInfo (siteName, siteHost, notes, allowableCountries, displayChance, imagePath) VALUES ('Sample', 'sample.com', 'note', 'NONE', '50', '../var');   I would then need to insert data into the siteLinks table, which is related to the entry already in the siteInfo table.  INSERT INTO siteLinks (siteID, URL) VALUES ((SELECT siteid FROM siteinfo WHERE sitename='Sample'), 'test');   Is there a better way of doing this?
66531
I'm looking at the docs for add_user_meta() vs update_user_meta().    If the current meta_key does not exist for a user, will update_user_meta() automatically add the meta_key for that user or do you have to define the meta_key with add_user_meta() first?
38464
In D6, I use a contrib module, but I would like to override a small bit of its behavior. I have a custom module for that, but my implementation of the relevant hook is called before the implementation in the contrib module, and so the contrib module's version "wins".   Is there any way to change it, and force my own hook to be called last?   Here are the specific details:  I would like to remove the default "Anonymous" user name for unregistered users in the comment form.  I created a small custom module, tweak_comment_form, that implements form_alter hook and removes the default value from the name field ().  However I also use a contrib module called , which also implements form_alter. RealName does what I want for registered users (replaces user name with "real name"), but re-assigns default value to the name field.
85665
Okay, how would I do this?  class Example(models.Model):   parent_example = models.ForeignKey(Example)   I want to have a model have a foreign key reference to itself.  When I try to create this I get a django validation error that Example is not yet defined.
82249
I have a blog with comments and I need to change the "Your name" field to something different and make it a required field.  Can I do this from  hook in template.php or in a comments template?
529
Im working in a site, And I need to present many fields to be filled and the page, so accoding to a selecction before, I have all the field but I have the Api Name, and the object name, but, With this api object field name, how can I get the label????  Example. I have "Student__c", I need to present "Student" to the user.  Thanks a lot for ur help!    Ok, thanks for ur answuers but I think I did not explain well this situation.   I have a list of string, where I have the information but in Api's name.  I present this fields in a table, so the user is filling the fields but with an inputText and not with an inputfield!.. So, in this moment, I dont know what is the label of each field.  My question basically, if by means of a query I could know the label of a field, if I know the api field name and the object name.. My question is if there is a way to consult this info!...  I know if I have the object is enough using an inputfield, But I cant do that. Neither set the label with HTML directly 'cause this is something dynamic.   Anyone knows how can I know, or consult, I guess by means of a query, how to get this label names???